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:07:23
Message-Id: 200607251618.58212.shrdlu@unlimitedmail.org
In Reply to: Re: [gentoo-user] strange [ file by Alan McKinnon
1 On Tuesday 25 July 2006 15:41, Alan McKinnon wrote:
2
3 > The answer is simple:
4 >
5 > 'test' is a bash builtin. When a bash script executes 'test', it is
6 > not /usr/bin/test that runs, but a function internal to bash.
7 >
8 > /usr/bin/test/ is provided for environments that want to run bash
9 > scripts that use test but bash is not the shell in use.
10
11 This makes sense.
12
13 > test and [ are not links to each other as they have different syntax
14 > (the closing ]), so they cannot be the same command. If they were
15 > linked, one of them would fail on execution with invalid syntax errors
16
17 This is not 100% true. As Neil Bothwick said, *the same program* can
18 behave differently based on the name it was invoked with, so [ could
19 very well have been implemented as a link to test (or viceversa), but
20 this is not the case, as you can see with a
21 ls -l /usr/bin/test /usr/bin/[
22
23 --
24 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] strange [ file Alan McKinnon <alan@××××××××××××××××.za>