[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "unset var" pops var off variable stack instead of unsetting it
From: |
Peter & Kelly Passchier |
Subject: |
Re: "unset var" pops var off variable stack instead of unsetting it |
Date: |
Mon, 20 Mar 2017 08:51:23 +0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
On 20/03/2560 04:51, Stephane Chazelas wrote:
> On comp.unix.shell ot http://unix.stackexchange.com, I've posted
> many articles describing how to do splitting in POSIX-like
> shells:
>
> ( # subshell for local scope
> unset -v IFS # restore default splitting behaviour
> set -o noglob # disable globbing
> cmd -- $var # split+glob with default IFS and glob disabled
> )
>
> I'm now considering adding a note along the lines of:
>
> "Beware that with current versions of bash, pdksh and yash,
> the above may not work if used in scripts that otherwise use
> typeset/declare/local on $IFS or call a function with
> `IFS=... my-function' (or IFS=... eval... or IFS=...
> source...)"
>
Wouldn't it be better to avoid using a function like 'unset' (that works
in the way you purport to expect) in a dynamically scoped language as a
matter of principle?? If unset works like you would want/expect it, it
would also discard all values of all higher scopes. Would it not be
better to set IFS to the value desired (whatever default splitting
behaviour you need)??
--
Peter
- Re: "unset var" pops var off variable stack instead of unsetting it, (continued)
Re: "unset var" pops var off variable stack instead of unsetting it, Chet Ramey, 2017/03/18
Re: "unset var" pops var off variable stack instead of unsetting it,
Peter & Kelly Passchier <=
Re: "unset var" pops var off variable stack instead of unsetting it, 渡邊裕貴, 2017/03/20
Re: "unset var" pops var off variable stack instead of unsetting it, Stephane Chazelas, 2017/03/20
Re: "unset var" pops var off variable stack instead of unsetting it, Greg Wooledge, 2017/03/20