2015-06-18 07:08:41 -0600, Eric Blake:
[...]
> $ bash -c 'a=1; readonly a; export a=2; echo $?'
> bash: a: readonly variable
> 1
> 
> In fact, bash _didn't_ abort, while other shells do:
> 
> $ dash -c 'a=1; readonly a; export a=2; echo $?'
> dash: 1: export: a: is read only
> $ ksh -c 'a=1; readonly a; export a=2; echo $?'
> ksh: a: is read only
> 
> so that's arguably a bug in bash.
[...]

No, "special builtins" failures only cause bash to exit when in
POSIX mode (like when called as "sh" or with POSIXLY_CORRECT in
the environment or with --posix...). That's a feature.

$ (exec -a sh bash -c 'a=1; readonly a; export a=2; echo $?')
sh: a: readonly variable

-- 
Stephane


Reply via email to