1 |
Alan McKinnon wrote: |
2 |
> On Tue, 2006-07-25 at 14:16 +0100, Neil Bothwick wrote: |
3 |
>> On Tue, 25 Jul 2006 09:26:52 -0300, Mauro Faccenda wrote: |
4 |
>> |
5 |
>> > > > You see? They cant be the same, because the closing "]" is needed |
6 |
>> > > > by /usr/bin[ and not by /usr/bin/test |
7 |
>> > > |
8 |
>> > > It's quite common for a program to change its behaviour according to |
9 |
>> > > the name used to run it. For example, zcat and gunzip are links to |
10 |
>> > > gzip, yet the three programs behave differently. |
11 |
>> > |
12 |
>> > but this isn't the case: |
13 |
>> |
14 |
>> I was disagreeing with the "cant be the same" comment. I know they are |
15 |
>> different files, but the slightly different behaviour is insufficient |
16 |
>> reason for that. Alexander asked why one was not a link to the other, I'd |
17 |
>> like to know too, but this isn't the reason. |
18 |
> |
19 |
> For such a simple question, this sure is generating a lot of traffic :-) |
20 |
> |
21 |
> The answer is simple: |
22 |
> |
23 |
> 'test' is a bash builtin. When a bash script executes 'test', it is |
24 |
> not /usr/bin/test that runs, but a function internal to bash. |
25 |
|
26 |
True. Same for [. |
27 |
|
28 |
> /usr/bin/test/ is provided for environments that want to run bash |
29 |
> scripts that use test but bash is not the shell in use. |
30 |
|
31 |
Nothing to argue here. |
32 |
|
33 |
> test and [ are not links to each other as they have different syntax |
34 |
> (the closing ]), so they cannot be the same command. |
35 |
|
36 |
That's not true. /usr/bin/[ and /usr/bin/test *COULD* be the |
37 |
same commands. If a program is invoked, it gets in $0 the name |
38 |
the user has used to call the program. Depending on this name/value, |
39 |
the program could behave differntly. |
40 |
|
41 |
> If they were |
42 |
> linked, one of them would fail on execution with invalid syntax errors |
43 |
|
44 |
Wrong. |
45 |
|
46 |
Alexander Skwar |
47 |
-- |
48 |
The politician is someone who deals in man's problems of adjustment. |
49 |
To ask a politician to lead us is to ask the tail of a dog to lead the dog. |
50 |
-- Buckminster Fuller |
51 |
-- |
52 |
gentoo-user@g.o mailing list |