Gentoo Archives: gentoo-user

From: Alan McKinnon <alan@××××××××××××××××.za>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] strange [ file
Date: Tue, 25 Jul 2006 13:50:08
Message-Id: 1153834916.17716.4.camel@localhost.localdomain
In Reply to: Re: [gentoo-user] strange [ file by Neil Bothwick
1 On Tue, 2006-07-25 at 14:16 +0100, Neil Bothwick wrote:
2 > On Tue, 25 Jul 2006 09:26:52 -0300, Mauro Faccenda wrote:
3 >
4 > > > > You see? They cant be the same, because the closing "]" is needed
5 > > > > by /usr/bin[ and not by /usr/bin/test
6 > > >
7 > > > It's quite common for a program to change its behaviour according to
8 > > > the name used to run it. For example, zcat and gunzip are links to
9 > > > gzip, yet the three programs behave differently.
10 > >
11 > > but this isn't the case:
12 >
13 > I was disagreeing with the "cant be the same" comment. I know they are
14 > different files, but the slightly different behaviour is insufficient
15 > reason for that. Alexander asked why one was not a link to the other, I'd
16 > like to know too, but this isn't the reason.
17
18 For such a simple question, this sure is generating a lot of traffic :-)
19
20 The answer is simple:
21
22 'test' is a bash builtin. When a bash script executes 'test', it is
23 not /usr/bin/test that runs, but a function internal to bash.
24
25 /usr/bin/test/ is provided for environments that want to run bash
26 scripts that use test but bash is not the shell in use.
27
28 test and [ are not links to each other as they have different syntax
29 (the closing ]), so they cannot be the same command. If they were
30 linked, one of them would fail on execution with invalid syntax errors
31
32 alan
33
34
35 --
36 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] strange [ file Etaoin Shrdlu <shrdlu@×××××××××××××.org>
Re: [gentoo-user] strange [ file Alexander Skwar <listen@×××××××××××××××.name>
Re: [gentoo-user] strange [ file Neil Bothwick <neil@××××××××××.uk>