GNU bug report logs -
#23090
true and false not POSIX
Previous Next
Reported by: Ruediger Meier <sweet_f_a <at> gmx.de>
Date: Tue, 22 Mar 2016 12:44:02 UTC
Severity: normal
Tags: notabug
Done: Eric Blake <eblake <at> redhat.com>
Bug is archived. No further changes may be made.
Full log
Message #33 received at submit <at> debbugs.gnu.org (full text, mbox):
On Tuesday 22 March 2016, Eric Blake wrote:
> On 03/22/2016 06:43 AM, Ruediger Meier wrote:
> > Hi,
> >
> > Is there any good reason why coreutils true and false are not
> > POSIX?
>
> No, because coreutils' true and false ARE compliant with POSIX.
>
> > But coreutils true has --version and --help implemented. It needs
> >
> >> /dev/null redirection to work as expected.
>
> Not true. POSIX says that behavior is unspecified for 'true --help'.
> Therefore, whatever coreutils does in that case does not violate
> POSIX.
I've seen many existing scripts where people do something like this:
cmd=whatever
# ignore if not exist
type "$cmd" || cmd="true"
[...]
$cmd --something --we --want --to --do --if --possible
[...]
Similar use case would be to set cmd="echo debug whatever: ".
You can't decline that you implicitly accept such usage, otherwise
$ true --blabla
would not return true (without error message) and
$ false --help
would not return false.
These exit codes are not good GNU Coding Standards I guess. Also not
non-getopt behavior like "echo string --help".
> 'true -- --help', on the other hand, must be silent - but coreutils
> obeys that rule.
>
> > Also these options are the reason why true.c is using many library
> > functions like setlocale, etc. The binary is bloated and the risk
> > that something goes wrong/crashs is much higher. I was looking for
> > a minimal and rock-solid true command to be used in scripts.
>
> If coreutils' true crashes due to wrong file permissions causing
> setlocale() to fail, your system is already going to have severe
> problems with other utilities. Coreutils is complying with GNU
> Coding Standards at the same time as POSIX, and we do not feel that
> it is bloated for doing so.
>
> > IMO it is not worth to violate POSIX just because of cosmetical
> > reasons (--help/--version). Moreover since the true command usually
> > comes from the shell I guess that almost no person on earth ever
> > had seen your nice --help output anyways.
>
> On many GNU/Linux systems, 'man true' displays the coreutils' man
> page for true, which in turn was generated from 'true --help' output.
> So a lot more people read it than you might think, even if they
> don't directly invoke it.
I'm sure that's possible to write manpages without --help ...
BTW this man page does not match to the most probably used built-in
command. This confuses the reader even more and is IMO another argument
why coreutils shouldn't have added --help options for these kind of
commands.
cu,
Rudi
This bug report was last modified 9 years and 61 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.