Most of times, I see use of typeset command in ksh scripts, but I don't know what it exactly does. I would be thankful if any body could provide me a brief explanation of typeset in ksh and all of its options, like typeset -A, typeset -r, typeset -Z, typetset -L etc.
Most of times, I see use of typeset command in ksh scripts, but I don't know what it exactly does. I would be thankful if any body could provide me a brief explanation of typeset in ksh and all of its options, like typeset -A, typeset -r, typeset -Z, typetset -L etc.
(Taken from HP-docs)
This command creates a shell variable, assigns it a value, and specifies certain attributes for the variable, such as integer and read-only.
The syntax is:
Where name is the shell variable to be created, value is to be assigned according to the options set.
The following example makes year read-only
The following list of attributes may be specified by the designated option or flag:
Using + rather than - causes these flags to be turned off. If no name arguments are given but flags are specified, a list of names (and optionally the values) of the parameters which have these flags set is printed. (Using + rather than - keeps the values to be printed.) If no names and options are given, the names and attributes of all parameters are printed.
The following example covers some of the attributes set above:
As a corollary to this, could anyone please explain the -t option? I've always wondered about what that really did, but all I've ever found was the description in the man page.
As a corollary to this, could anyone please explain the -t option? I've always wondered about what that really did, but all I've ever found was the description in the man page.
It doesn't really do anything.
typeset -i abc # sets the variable to be integer type
typeset -t def # sets the variable to be tagged type
Setting the integer type affects the way the variable works. The tagged type has no effect. But as with any variable type, it responds to naked typeset commands.
typeset +i # list all integer variables
typeset +t # list all tagged variables
And you could do "typeset -i" or "typeset -t" to list the variables with their values. That's about all there is to it. Everyone expects more but there is no more.
Thanks for the info. It seems strange -- I guess I could use it to track a list of variables for some user-defined purpose, but considering there are zillions of other ways to do something like that... ok. Thanks again, though.
I'm getting different behaviors for "typeset -i" on different systems. In one case unset parameters are 0, and in another case they're empty. Is one of these behaviors correct, or is the behavior here unspecified?
First system:
$ typeset -i x
$ print $x
0
$ print ${.sh.version}
Version M... (13 Replies)
Hi,
All the scripts we have here use typeset instead of normal variables.
They don't have any parameters, they just get declared at the beginning of the scripts like this: typeset var1 var2 var3Could anyone tell me why this is done? I don't see the advantage in this over using normal variables. (1 Reply)
Hi all,
Am trying to convert a script written in ksh to a bash shell.
At the moment, am stumped with the typeset -u command and I can't find an equivalent of it in bash.
integer function is also not working as is the following if statement
if ] && ]; then
continue
fi
Is... (3 Replies)
Hi,
typeset -l sgf # all lowercase letters
typeset -u SGF # all uppercase letters
sgf=$1
SGF=$sgf
these lines used in my scripts . It ran fine in ksh but when we convert this to bash it erroring out.
I like to know what the use of typeset ??
Thanks & Regards
kanagaraj (3 Replies)
Hi,
Could any one please explain about typeset or share any link from where i can study about typeset i.e how to use it, how to define it.. etc?
Thanks-
Yogi (3 Replies)
I have found this command *typeset* and the option * -f *, which should provide me the list of all the currently defined functions. Is there any possibility of specifying the file in which this command to search ? (1 Reply)
Hi all,
I have problem understanding shell script.Written that
$bindir/put_load.ksh ; typeset RV= $?
I dont have any other document about script. How can i find that $bindir is exist or not what is the content of that, i am working on new box . how can i search that in old box what... (4 Replies)