[PLUG] Maybe not so dumb BASH question
Jason R. Martin
nsxfreddy at verizon.net
Fri May 6 05:52:50 UTC 2005
The backtick (command substitution) operator generates it's own
environment (I think). You'll have to export TMPDIR to mark it for the
environment passed to the child process.
Of course, it's late, and my processor has gone to sleep (S5?).
Jason
William A Morita wrote:
> I have written the script below and am puzzled by the fact that the shell
> variable TMPFILE is not global in nature.
> According to all documentation I can find, it is explicitly stated that with
> regard to function, all variables are global unless the "local" keyword is
> used.
> I am not seeing a global effect when the script below is run on White Box
> Linux (Bash 2.05) or Fedora Core 3 (Bash 3.05). Is there a setting I may
> have wrong someplace?
>
> ==============================
> #!/bin/bash
> # Script to get unique number using files in a temp directory
> #
>
> set -x
>
> TMPDIR=~/tmp
>
> function GetNumber
> {
> set -xv
> for n in 0 1 2 3 4 5 6 7 8 9
> do
> TMPFILE=$TMPDIR/TagFile$n
> if [ -f $TMPFILE ]
> then
> continue
> else
> touch $TMPFILE
> echo $n
> trap "rm -f $TMPFILE" INT TERM
> exit
> fi
> done
> }
>
> TMPFILE=None
> Num=`GetNumber`
>
> echo $Num $TMPFILE
> ==============================
>
>
>
>
> - Bill
>
> wamorita at hevanet.com
> Home: (503) 697-6994
> Cell: (503) 260-3876
>
>
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>
More information about the PLUG
mailing list