Steffen Daode Nurpmeso dixit:
…
Well, don’t do that then.
tg@blau:~ $ mksh -c 'unset KSH_VERSION'
mksh: read-only: KSH_VERSION
>I'd consider this a bug, since POSIX says „Read-only variables
>cannot be unset“ but i fail to see why this should result in
>anything more than $? being 1, especially without set -e?
unset is a POSIX special built-in utility. It says:
EXIT STATUS
0
All name operands were successfully unset.
>0
At least one name could not be unset.
CONSEQUENCES OF ERRORS
Default.
And, for special built-in utilities:
1. A syntax error in a special built-in utility may cause a shell
executing that utility to abort, while a syntax error in a regular
built-in utility shall not cause a shell executing that utility to
abort. (See [229]Consequences of Shell Errors for the consequences
of errors on interactive and non-interactive shells.) If a special
built-in utility encountering a syntax error does not abort the
shell, its exit value shall be non-zero.
On the other hand, I don’t know whether it’s a syntax error or not…
but then, it’s been always this way:
tg@blau:~ $ mksh-R20 -c 'readonly foo=bar; unset foo; echo bla'; echo $?
mksh-R20: unset: foo is read only
1
There are even checks in the testsuite for that, so you’d probably
better accept this and move on and just Don’t Do That Then ;-)
bye,
//mirabilos
--
“It is inappropriate to require that a time represented as
seconds since the Epoch precisely represent the number of
seconds between the referenced time and the Epoch.”
-- IEEE Std 1003.1b-1993 (POSIX) Section B.2.2.2