[PLUG] Maybe not so dumb BASH question
Jason R. Martin
nsxfreddy at verizon.net
Sat May 7 17:20:57 UTC 2005
Bill -
I don't know what to tell you then, since making that change caused your
script to function on my Fedora Core 3 box.
Jason
William A Morita wrote:
> Jason,
>
> Making the change does not affect the output of the script.
> If I am reading the documentation correctly, the value set in the function
> should override the initial value of "None".
>
> - Bill
> wamorita at hevanet.com
>
>
>
> -----Original Message-----
> From: Jason R. Martin [mailto:nsxfreddy at verizon.net]
> Sent: Thursday, May 05, 2005 11:10 PM
> To: General Linux/UNIX discussion and help; civil and on-topic
> Cc: wamorita at hevanet.com
> Subject: Re: [PLUG] Maybe not so dumb BASH question
>
> BTW, since I was too tired to mention it in the last email, changing
>
> Num=`GetNumber`
>
> to
>
> Num=$(GetNumber)
>
> will also solve your problem, this time without exporting TMPDIR.
>
> Jason
>
> Jason R. Martin wrote:
>
>>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
>>>
>>
>>_______________________________________________
>>PLUG mailing list
>>PLUG at lists.pdxlinux.org
>>http://lists.pdxlinux.org/mailman/listinfo/plug
>>
>
>
>
More information about the PLUG
mailing list