Gentoo Archives: gentoo-user

From: Etaoin Shrdlu <shrdlu@×××××××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] strange [ file
Date: Tue, 25 Jul 2006 14:18:50
Message-Id: 200607251635.21607.shrdlu@unlimitedmail.org
In Reply to: Re: [gentoo-user] strange [ file by Neil Bothwick
1 On Tuesday 25 July 2006 15:16, Neil Bothwick wrote:
2
3 > I was disagreeing with the "cant be the same" comment. I know they are
4 > different files, but the slightly different behaviour is insufficient
5 > reason for that. Alexander asked why one was not a link to the other,
6 > I'd like to know too, but this isn't the reason.
7
8 [slowly getting OT...]
9
10 Looking at coreutils sources, it turns out that there are two files:
11 test.c and lbracket.c.
12 test.c is the actual program, and lbracket.c is as follows:
13
14 $ cat lbracket.c
15 #define LBRACKET 1
16 #include "test.c"
17
18 so, test.c does all the work.
19
20 After taking a quick look at the code, seems that the only times LBRACKET
21 is checked are in the following fragments:
22
23
24 ...
25 /* The official name of this program (e.g., no `g' prefix). */
26 #if LBRACKET
27 # define PROGRAM_NAME "["
28 #else
29 # define PROGRAM_NAME "test"
30 #endif
31
32 ...
33
34 if (LBRACKET)
35 {
36 /* Recognize --help or --version, but only when invoked in the
37 "[" form, and when the last argument is not "]". POSIX
38 allows "[ --help" and "[ --version" to have the usual GNU
39 behavior, but it requires "test --help" and "test --version"
40 to exit silently with status 1. */
41 if (margc < 2 || !STREQ (margv[margc - 1], "]"))
42 {
43 parse_long_options (margc, margv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
44 usage, AUTHORS, (char const *) NULL);
45 test_syntax_error (_("missing `]'\n"), NULL);
46 }
47
48 --margc;
49 }
50
51 argc = margc;
52 pos = 1;
53 ...
54
55 Again, the above could have been implemented by looking at argv[0].
56 --
57 gentoo-user@g.o mailing list