Subject: GNU's /bin/true

From: Shlomi Fish <[email-masked]>
Date: Sat, 23 Feb 2008 10:51:27 +0200

Hi all.

Inspired by the bit about the Solaris true here:

http://thedailywtf.com/Articles/The-Comcast-Bill,-A-Buggy-Traffic-Light,-and-More.aspx

I decided to see how my GNU/Linux's /bin/true is all about. "less /bin/true" 
indicated it was a binary executable and had many symbols to show for 
(including many printf-formats). And:

<<<<
$ ls -l /bin/true
-rwxr-xr-x 1 root root 23468 2008-01-29 13:21 /bin/true

I wondered why it should be so large, given all it had to do was "return 0;", 
and so I did "man true":

<<<<<<<<<<<<<<
NAME
       true - do nothing, successfully

SYNOPSIS
       true [ignored command line arguments]
       true OPTION

DESCRIPTION
       Exit with a status code indicating success.

       --help display this help and exit

       --version
              output version information and exit

       NOTE: your shell may have its own version of true, which usually super‐
       sedes the version described here.  Please refer to your  shell's  docu‐
       mentation for details about the options it supports.

I laughed quite a bit seeing it accepts some command-line arguments.

Then I tried "true --help" and "true --version" which didn't print anything 
because they were the shell's built-in true command. So I did the same 
with "/bin/true --help" and "/bin/true --version":

<<<<<<<<<<<<<<<<<<<
shlomi:~$ /bin/true --help
Usage: /bin/true [ignored command line arguments]
  or:  /bin/true OPTION
Exit with a status code indicating success.

      --help     display this help and exit
      --version  output version information and exit

NOTE: your shell may have its own version of true, which usually supersedes
the version described here.  Please refer to your shell's documentation
for details about the options it supports.

Report bugs to <[email-masked]>.
shlomi:~$ /bin/true --version
true (GNU coreutils) 6.10
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jim Meyering.
shlomi:~$

So now I no longer wonder why it is so bloated.

What would we do without GNU?

Regards,

	Shlomi Fish

---------------------------------------------------------------------
Shlomi Fish      [email-masked]
Homepage:        http://www.shlomifish.org/

I'm not an actor - I just play one on T.V.

---

From: "Amit Aronovitch" <[email-masked]>
Date: Sun, 24 Feb 2008 02:46:29 +0200

>  I wondered why it should be so large, given all it had to do was "return 0;",

Funny or not - it has to. Thats the GNU Coding Standards for you...

http://www.gnu.org/prep/standards/standards.html#Command_002dLine-Interfaces

Sec. 4.7: "... All programs should support two standard options:
'--version' and '--help'. ..."

---

From: "Michael Tewner" <[email-masked]>
Date: Sun, 24 Feb 2008 02:59:30 -0500

Well - according to
http://www.koders.com/c/fidDF83F838AA5D91F9B07D35DD6353BCA20BD2B48B.aspx

/bin/true and /bin/false are the same program:

/* Act like "true" by default; false.c overrides this.  */
#ifndef EXIT_STATUS
# define EXIT_STATUS EXIT_SUCCESS
#endif

#if EXIT_STATUS == EXIT_SUCCESS
# define PROGRAM_NAME "true"
#else
# define PROGRAM_NAME "false"
#endif

False.c is simply:
#define EXIT_STATUS EXIT_FAILURE
#include "true.c"

sure enough, they have the same size
-rwxr-xr-x 1 root root 15736 2007-03-05 08:13 false
-rwxr-xr-x 1 root root 15736 2007-03-05 08:13 true

... though they have a decent binary diff - due to 1-byte shifts on
some segments - "true" being one character less than false.

On Sat, Feb 23, 2008 at 3:51 AM, Shlomi Fish <[email-masked]> wrote:
>  Yahoo! Groups Links