coreutils
[Top][All Lists]
Advanced

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

true,false: --version,--help exit code


From: Bernhard Voelker
Subject: true,false: --version,--help exit code
Date: Tue, 03 Jun 2014 09:50:03 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

Q: Why does 'true --help >/dev/full' return 1?

Longer story:
I was wondering why 'false --version' exits with 1, so looking
up the POSIX specification [0] made it clear:

  The false utility shall always exit with a value other than zero.

So I looked at src/true.c and found the atexit handler detecting
write errors [1, line 67]:

      atexit (close_stdout);

... despite true's spec [2] which is quite clear about the exit code, too:

  The true utility shall return with exit code zero.

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?

[0] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/false.html
[1] 
http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/true.c?id=1239ac573d#n67
[2] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/true.html

Thanks & have a nice day,
Berny



reply via email to

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