[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Consequences of shell errors
From: |
Stephane Chazelas |
Subject: |
Re: Consequences of shell errors |
Date: |
Thu, 18 Jun 2015 14:45:43 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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
Re: Consequences of shell errors, Eric Blake, 2015/06/18