Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [typeset]

typeset is a shell builtin to declare (or display) shell variables and their attributes. In bash typeset is a synonym for declare.

0
votes
1answer
46 views

get an error typeset: not found when i launch my script by crontab?

I use this portion of code to set default values in my config on my script.sh # Copyright (c) 2015 # Licence MIT ( http://choosealicense.com/licenses/mit/ ). #!/bin/sh typeset -A config # init ...
3
votes
1answer
157 views

How safe is the idiom `ssh … “$(typeset -f foo); foo”`?

Suppose that some shell function foo is defined in the current shell session. Then the command typeset -f foo prints out the source code of this function. This means that, at least in principle, ...
6
votes
1answer
1k views

typeset in ksh93 not working as expected

I thought typeset was ksh's local, but this fails in ksh93 although it works in all my other typeset-supporting shells (bash, yash, zsh, pdksh) #!/bin/ksh -ex foo(){ typeset a b a=0; b=1 ...
1
vote
0answers
198 views

ksh type with herestring

I wanted to use Here String in conjunction with custom type in KSH. Unfortunately I am not able to tell what I am doing wrong. #!/bin/ksh typeset -T Type_t=( typeset string='aaa' function fc { ...
7
votes
1answer
403 views

Circular name references in bash shell function, but not in ksh

I'm writing a set of shell functions that I want to have working in both Bash and KornShell93, but with Bash I'm running into a "circular name reference" warning. This is the essence of the problem: ...
3
votes
1answer
785 views

typeset and return status in ksh

I'd like to be able to declare a local var as the result of a command AND to be able to capture return status of command. Something like this: #!/bin/ksh typeset -r command_output=$(command) typeset ...
2
votes
2answers
1k views

Create array in bash with variables as array name

I'm not sure if this has been answered, I've looked and haven't found anything that looks like what I'm trying to do. I have a number of shell scripts that are capable of running against a ksh or ...
0
votes
1answer
2k views

typeset -A is giving error in script

I was using associative arrays in my script, hence I used to declare them by the typeset -A <array_name> command, and it worked fine in the bash prompt But when I use it in my script, I get ...
5
votes
4answers
20k views

Pad a number with a zero

I'm trying to pad zero to a number a=010 printf "%04d" $a 0008 I need the "output" as "0010" it's converting the value. and even tried with typeset a=010 typeset -RZ2 a echo $a when I use the ...
15
votes
2answers
25k views

What is the difference between declare and typeset

Can anyone explain difference between declare and typeset with real life examples .