[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: declare a="$b" if $a previously set as array
From: |
Stephane Chazelas |
Subject: |
Re: declare a="$b" if $a previously set as array |
Date: |
Tue, 9 Dec 2014 11:22:53 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
2014-12-09 10:59:14 +0000, Stephane Chazelas:
[...]
> $ a=0 ksh -c 'function f { typeset a=1; g; h; echo "f: $a"; }; function g {
> a=2; }; function h { typeset a=3; };f'
> f: 1
>
> "f" doesn't have to worry about alien functions changing its
> local variables under its feet.
[...]
(for clarification)
It still has to worry about alien functions declared using the
Bourne syntax though (as those are interpreted in their parent's
scope and don't have a separate scope except for the positional
parameters):
$ ksh -c 'function f { typeset a=1; g; echo $a; }; g() a=2; f'
2
(or sourced scripts or "eval"ed variables...).
--
Stephane
- Re: declare a="$b" if $a previously set as array, (continued)
- Re: declare a="$b" if $a previously set as array, Dan Douglas, 2014/12/16
- Re: declare a="$b" if $a previously set as array, Stephane Chazelas, 2014/12/16
- Re: declare a="$b" if $a previously set as array, Stephane Chazelas, 2014/12/16
- Re: declare a="$b" if $a previously set as array, Chet Ramey, 2014/12/22
- Re: declare a="$b" if $a previously set as array, Chet Ramey, 2014/12/16
- Re: declare a="$b" if $a previously set as array, Chet Ramey, 2014/12/22
Re: declare a="$b" if $a previously set as array, konsolebox, 2014/12/08
- Re: declare a="$b" if $a previously set as array, Stephane Chazelas, 2014/12/09
- Re: declare a="$b" if $a previously set as array,
Stephane Chazelas <=
- Re: declare a="$b" if $a previously set as array, konsolebox, 2014/12/09
- Re: declare a="$b" if $a previously set as array, Greg Wooledge, 2014/12/09
- Re: declare a="$b" if $a previously set as array, Stephane Chazelas, 2014/12/09
- Re: declare a="$b" if $a previously set as array, konsolebox, 2014/12/09
- Re: declare a="$b" if $a previously set as array, Stephane Chazelas, 2014/12/10
- Re: declare a="$b" if $a previously set as array, Stephane Chazelas, 2014/12/10
- Re: declare a="$b" if $a previously set as array, konsolebox, 2014/12/10
- Re: declare a="$b" if $a previously set as array, Chet Ramey, 2014/12/14
- Re: declare a="$b" if $a previously set as array, konsolebox, 2014/12/14
Re: declare a="$b" if $a previously set as array, Chet Ramey, 2014/12/14