[Top][All Lists]

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

Re: Consequences of shell errors

From: Eric Blake
Subject: Re: Consequences of shell errors
Date: Thu, 18 Jun 2015 07:08:41 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

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:

such as when trying to modify a readonly variable:

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

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.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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