This is a standard Unix feature. The parent process never inherits anything from a child. Shell variables are local. That said, the only way for a process to inherit variables from a script is to source the script. Bash supports the 'source' built-in command as well as the . builtin. On 7 Nov 2002 at 15:19, Price, Erik wrote:
> Hi, > > I know there's some hardcore shell heads on this list, so I was hoping I could >solicit some assistance here... > > I've isolated the problem to an inability to make a variable declaration accessible >outside of the script. It's almost as if there were a bash form of "use strict" >going on that was keeping my variables within the scope of the script. If I try to >echo $newPWD, I get nothing -- but I can see that $newPWD is getting set in the script. I've tried "export newPWD", which doesn't do anything either. > > This is obviously some fundamental rule of variable scope in bash that I just don't >know, so can someone set me right? > > Bash v. 2.02 on Solaris. > > Thanks, > Erik > > > > #!/usr/local/bin/bash > #(yes, that's the location of bash on my system) > > # How many characters of the $PWD should be kept > pwdmaxlen=30 > > # indicator that there has been directory truncation > trunc_symbol="..." > if [ ${#PWD} -gt $pwdmaxlen ] > then > pwdoffset=$(( ${#PWD} - $pwdmaxlen )) > newPWD="${trunc_symbol}${PWD:${pwdoffset}:${pwdmaxlen}}" > else > newPWD=${PWD} > fi > _______________________________________________ > gnhlug-discuss mailing list > [EMAIL PROTECTED] > http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss -- Jerry Feldman <[EMAIL PROTECTED]> Associate Director Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9 _______________________________________________ gnhlug-discuss mailing list [EMAIL PROTECTED] http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss