On 3/8/15 5:44 PM, Stephane Chazelas wrote:
BTW, to get back on topic:
$ bash --norc -o posix
bash-4.3$ unset zzz
bash-4.3$ zzz=x eval
bash-4.3$ env | grep zzz
zzz=x
ksh93, zsh (in sh emulation), dash, mksh, the Bourne shell (the
port of opensolaris' to Linux at least) do retain the
2015-03-07 16:46:52 -0600, Alan Wild:
I'm really curious to see if anyone else offers better ideas, but the ways
I've done this are
1) exactly what you propose.
2) use a subshell (parantheses):
$ ( for x in a b c; { echo $x; } )
a
b
c
$ typeset -p x
bash: typeset: x: not found
Hi, I use unset to remove x from the environment once the for loop is
finished. Is it the best way to do in bash? Thanks.
for x in a b c
do
echo $x
done
unset x
--
Regards,
Peng
On Sat, Mar 07, 2015 at 04:31:54PM -0600, Peng Yu wrote:
Hi, I use unset to remove x from the environment once the for loop is
finished. Is it the best way to do in bash? Thanks.
First, use the help-bash mailing list for this kind of queries.
Second, unless you used 'export x', then the 'x'
I'm really curious to see if anyone else offers better ideas, but the ways
I've done this are
1) exactly what you propose.
2) use a subshell (parantheses):
$ ( for x in a b c; { echo $x; } )
a
b
c
$ typeset -p x
bash: typeset: x: not found
3) use a function and declare x local to the function