bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Consequences of shell errors


From: Chet Ramey
Subject: Re: Consequences of shell errors
Date: Thu, 18 Jun 2015 10:22:21 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

-----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 CAN fail:
> http://austingroupbugs.net/view.php?id=351

Introducing declaration commands that treat arguments as assignments
implies that these are variable assignment errors, not return status
values from export.  This interpretation doesn't change the description
of export, which continues to list `zero' as the only possible exit
status.

> http://austingroupbugs.net/view.php?id=654

This applies to variable assignments preceding `export'.

> such as when trying to modify a readonly variable:
> 
> $ 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:

You should have tried it in posix mode to test posix behavior.


- -- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: GPGTools - http://gpgtools.org

iEYEARECAAYFAlWC1BYACgkQu1hp8GTqdKvI8ACeIuzDSILRWu4tdVTj8Jqa05zN
vp4An3AKEfU1mdC67ForbSKLWUdHU0IH
=b45C
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]