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