Alan McKinnon wrote:
> On Tue, 2006-07-25 at 14:16 +0100, Neil Bothwick wrote:
>> On Tue, 25 Jul 2006 09:26:52 -0300, Mauro Faccenda wrote:
>> 
>> > > > You see? They cant be the same, because the closing "]" is needed
>> > > > by /usr/bin[ and not by /usr/bin/test
>> > >
>> > > It's quite common for a program to change its behaviour according to
>> > > the name used to run it. For example, zcat and gunzip are links to
>> > > gzip, yet the three programs behave differently.
>> > 
>> > but this isn't the case:
>> 
>> 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.
> 
> For such a simple question, this sure is generating a lot of traffic :-)
> 
> The answer is simple:
> 
> 'test' is a bash builtin. When a bash script executes 'test', it is
> not /usr/bin/test that runs, but a function internal to bash.

True. Same for [.

> /usr/bin/test/ is provided for environments that want to run bash
> scripts that use test but bash is not the shell in use.

Nothing to argue here.

> test and [ are not links to each other as they have different syntax
> (the closing ]), so they cannot be the same command.

That's not true. /usr/bin/[ and /usr/bin/test *COULD* be the
same commands. If a program is invoked, it gets in $0 the name
the user has used to call the program. Depending on this name/value,
the program could behave differntly.

> If they were
> linked, one of them would fail on execution with invalid syntax errors

Wrong.

Alexander Skwar
-- 
The politician is someone who deals in man's problems of adjustment.
To ask a politician to lead us is to ask the tail of a dog to lead the dog.
                -- Buckminster Fuller
-- 
[email protected] mailing list

Reply via email to