Re: exported shell variables and scope
On Wed, 25 Jul 2001, Dale Scheetz wrote:
> I've had a problem with this issue for a long time now, and have never
> been able to properly resolve the issue. I am not able to get a broad
> enough scope to shell defined variables.
>
> Simple process: one shell script defines a bunch of variables and the next
> shell script uses them to perform the work.
>
> Here is the first script:
>
> #!/bin/sh
> #
> pwd >/tmp/pwd
> export DBXDEV=`pwd`
> export DBXSYS=LINUX
> export TPGM=`cat /tmp/pwd`
> export PATH="$PATH:$TPGM:$TPGM/bin"
This is not valid shell syntax. If you do it like the above, please specifiy
#!/bin/bash as the first line.
The proper way, is 'DBXDEV=$(pwd); export DBXDEV'
Also, PATH="${PATH:+$PATH:}$TPGM:$TPGM/bin"
Assigning PATH that way, handles the case where PATH is empty, and keeps PATH
from having a leading empty : value.
Reply to: