On Tuesday 25 July 2006 15:16, Neil Bothwick wrote:

> I was disagreeing with the "cant be the same" comment. I know they are
> different files, but the slightly different behaviour is insufficient
> reason for that. Alexander asked why one was not a link to the other,
> I'd like to know too, but this isn't the reason.

[slowly getting OT...]

Looking at coreutils sources, it turns out that there are two files: 
test.c and lbracket.c.
test.c is the actual program, and lbracket.c is as follows:

$ cat lbracket.c
#define LBRACKET 1
#include "test.c"

so, test.c does all the work.

After taking a quick look at the code, seems that the only times LBRACKET 
is checked are in the following fragments:


...
/* The official name of this program (e.g., no `g' prefix).  */
#if LBRACKET
# define PROGRAM_NAME "["
#else
# define PROGRAM_NAME "test"
#endif

...

if (LBRACKET)
    {
      /* Recognize --help or --version, but only when invoked in the
   "[" form, and when the last argument is not "]".  POSIX
   allows "[ --help" and "[ --version" to have the usual GNU
   behavior, but it requires "test --help" and "test --version"
   to exit silently with status 1.  */
      if (margc < 2 || !STREQ (margv[margc - 1], "]"))
  {
    parse_long_options (margc, margv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
            usage, AUTHORS, (char const *) NULL);
    test_syntax_error (_("missing `]'\n"), NULL);
  }

      --margc;
    }

  argc = margc;
  pos = 1;
...

Again, the above could have been implemented by looking at argv[0].
-- 
[email protected] mailing list

Reply via email to