Re: Consequences of shell errors

2015-06-18 Thread Stephane Chazelas
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; readon

Re: Consequences of shell errors

2015-06-18 Thread Eric Blake
On 06/18/2015 08:40 AM, Eric Blake wrote: > $ readonly -p > /dev/full > bash: readonly: write error: No space left on device > $ echo $? > 1 > $ > > and that is certainly not a variable assignment error :) > > At any rate, I'm opening a new Austin Group bug today on this topic. http://austingrou

Re: Consequences of shell errors

2015-06-18 Thread Chet Ramey
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 6/18/15 10:40 AM, Eric Blake wrote: > On 06/18/2015 08:22 AM, Chet Ramey wrote: >> On 6/18/15 9:08 AM, Eric Blake wrote: >>> On 06/18/2015 06:51 AM, Chet Ramey wrote: >> Neither of these are failures; the export command returns succ

Re: Consequences of shell errors

2015-06-18 Thread Eric Blake
On 06/18/2015 08:22 AM, Chet Ramey wrote: > On 6/18/15 9:08 AM, Eric Blake wrote: >> On 06/18/2015 06:51 AM, Chet Ramey wrote: > >>> >>> Neither of these are failures; the export command returns success. In >>> fact, according to Posix, the export command cannot fail. > >> Not quite true; export

Re: Consequences of shell errors

2015-06-18 Thread Chet Ramey
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 6/18/15 9:08 AM, Eric Blake wrote: > On 06/18/2015 06:51 AM, Chet Ramey wrote: > >> >> Neither of these are failures; the export command returns success. In >> fact, according to Posix, the export command cannot fail. > > Not quite true; export C

Re: Consequences of shell errors

2015-06-18 Thread Eric Blake
On 06/18/2015 06:51 AM, Chet Ramey wrote: > > Neither of these are failures; the export command returns success. In > fact, according to Posix, the export command cannot fail. Not quite true; export CAN fail: http://austingroupbugs.net/view.php?id=351 http://austingroupbugs.net/view.php?id=654

Re: Consequences of shell errors

2015-06-18 Thread Eric Blake
On 06/17/2015 04:33 PM, Nick Stoughton wrote: > I was surprised when the following script did NOT exit at the indicated > line: > > set -e > export X=$(false) > # should not reach here Why not? > The export utility is a special built-in, and according to POSIX XCU 2.8

Re: Consequences of shell errors

2015-06-18 Thread Chet Ramey
X=$(false) > # should not reach here > export X > echo did not exit Because http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01 calls it out as a special case. > The export utility is a special built-in, and according to POSIX XCU 2.8.1 >

Re: Consequences of shell errors

2015-06-18 Thread isabella parakiss
On 6/18/15, Nick Stoughton wrote: > > set -e > export X=$(false) > # should not reach here > echo did not exit > > But every shell I tested behaves the same way (sh, bash, dash, ksh, mksh, > yash and zsh), so I feel I must be missing something. Can someone explain > why the first 2 examples do no

Consequences of shell errors

2015-06-17 Thread Nick Stoughton
expected and exited on error: set -e X=$(false) # should not reach here export X echo did not exit The export utility is a special built-in, and according to POSIX XCU 2.8.1 "Consequences of Shell Errors", special built-ins should exit (with a diagnostic message) on both variable assignment