[PLUG] BASH Busted??
Steve Beattie
steve at wirex.net
Tue Jun 14 04:43:32 UTC 2005
On Mon, Jun 13, 2005 at 07:06:36PM -0700, William A Morita wrote:
> According to the documentation on BASH, the shell variables are Global with
> respect to functions. To have a "local" in a function, it must be declared
> as such. This is consistent with KSH. However, the following script does
> not seem to demonstrate this
>
> #!/bin/bash
> # Script to test "global" variable
> #
>
> set -x
>
> JUNK="Initial Value"
>
> function SomeFunction
> {
> set -x
> JUNK="Set in function"
> echo $JUNK
> }
>
> Value="`SomeFunction`"
The backticks are messing you up, they're running SomeFunction in an
entirely seperate process. Try:
SomeFunction
Value=$?
--
Steve Beattie
<sbeattie at novell.com>
http://www.NxNW.org/~steve/
More information about the PLUG
mailing list