[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: true,false: --version,--help exit code
From: |
Eric Blake |
Subject: |
Re: true,false: --version,--help exit code |
Date: |
Tue, 03 Jun 2014 05:34:11 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
On 06/03/2014 03:56 AM, Pádraig Brady wrote:
> On 06/03/2014 08:50 AM, Bernhard Voelker wrote:
>> Q: Why does 'true --help >/dev/full' return 1?
Because use of '--help' is a non-POSIX extension, so we'd rather make it
behave consistently and diagnose write errors.
>> ... despite true's spec [2] which is quite clear about the exit code, too:
>>
>> The true utility shall return with exit code zero.
The POSIX spec only applies when there is no non-POSIX extension in
effect. We are free to make 'true --help' behave how we want, rather
than returning 0.
>>
>> This looks like a (well, little) contradiction to me: the options
>> --help and --version are GNU extensions and therefore may or may
>> not lead to a different exit code than specified for the normal
>> operation of the tool, but I'd expect behaving them the same for
>> all utilities (under all circumstances): either let 'false --version'
>> return 0 (because the GNU extension operation succeeded), or let
>> 'true --version >/dev/full' return 0 (because POSIX says that 'true'
>> should always return 0).
>> WDYT?
Ah, so you caught on to the same argument that we are outside the bounds
of POSIX, so we are free to choose the behavior for both utilities. You
also make a fair point that we are inconsistent on slamming the return
code for false, but not for true - either we should do it for both (true
always succeeds even on write failure) or neither (false always fails
even for version output).
I'm 50:50 on which way to go.
> Now I don't think anyone would ever be using `env true --version > blah`
> in a script, but it would be better to be consistent here
> and have the exit code dependent on the name rather than the environment.
>
> I also see that the test script for `false` was only
> checking the shell builtin :/
>
> The attached fixes up both issues in your name.
> OK to push?
My first reaction was to go the other way (make 'false --version' give
status 0), but I don't know that it makes a difference either way, so I
can live with your proposed fix.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: true,false: --version,--help exit code, (continued)
- Re: true,false: --version,--help exit code, Pádraig Brady, 2014/06/03
- Re: true,false: --version,--help exit code, Jim Meyering, 2014/06/03
- Re: true,false: --version,--help exit code, Bernhard Voelker, 2014/06/03
- Re: true,false: --version,--help exit code, Jim Meyering, 2014/06/03
- Re: true,false: --version,--help exit code, Eric Blake, 2014/06/03
- Re: true,false: --version,--help exit code, Pádraig Brady, 2014/06/03
- Re: true,false: --version,--help exit code, Eric Blake, 2014/06/03
- Re: true,false: --version,--help exit code, Pádraig Brady, 2014/06/03
- Re: true,false: --version,--help exit code, Jim Meyering, 2014/06/03
- Re: true,false: --version,--help exit code, Bernhard Voelker, 2014/06/04
Re: true,false: --version,--help exit code,
Eric Blake <=