bug-bash
[Top][All Lists]
Advanced

[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: Martijn Dekker
Subject: Re: "unset var" pops var off variable stack instead of unsetting it
Date: Thu, 23 Mar 2017 03:48:55 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

Op 21-03-17 om 16:38 schreef Stephane Chazelas:
> IOW, the work around I was mentioning earlier (of using "local"
> before "unset" to make sure "unset" unsets) doesn't work in that
> case. You'd need to use the same work around as for mksh/yash
> (call unset in a loop until the variable is really unset (with
> the nasty side effect of unsetting the variable in a scope
> you're need meant to tamper with) so you'd want to do it in a
> subshell).

Note that this workaround needs to be applied conditionally on
cross-platform POSIX scripts because you'd get an infinite loop on
recent-ish versions of ksh93 (as of 2010, IIRC). Those ksh93 versions
have BUG_IFSISSET: it is not possible to determine in any normal way if
IFS is set, neither with "${IFS+set}" nor with [[ -v IFS ]]. They always
act as if IFS is set, even when it is unset. This applies to IFS only.

Upon detecting BUG_IFSISSET, modernish applies a workaround to isset()*
that involves analysing field splitting behaviour to distinguish between
empty IFS and unset IFS. So 'isset IFS' is fully cross-platform.

- M.

* https://github.com/modernish/modernish#working-with-variables




reply via email to

[Prev in Thread] Current Thread [Next in Thread]