Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #35745

The difference between /bin/test and /bin/[

From Lew Pitcher <lew.pitcher@digitalfreehold.ca>
Newsgroups comp.os.linux.misc
Subject The difference between /bin/test and /bin/[
Date 2022-10-18 14:58 +0000
Organization A noiseless patient Spider
Message-ID <timeu8$3o485$2@dont-email.me> (permalink)
References (1 earlier) <eli$2210171923@qaz.wtf> <ygailkh8om8.fsf@akutech.de> <tim4kr$3nq91$1@dont-email.me> <ygaedv58ewi.fsf@akutech.de> <timcia$3o485$1@dont-email.me>

Show all headers | View raw


On Tue, 18 Oct 2022 14:17:46 +0000, Lew Pitcher wrote:

> On Tue, 18 Oct 2022 15:01:01 +0200, Ralf Fassel wrote:
[snip]
>> (Of course there is also /usr/bin/[ and /usr/bin/test (2 different
>> programs on my Opensuse)
> 
> Although, they /don't/ have to be different programs. Historically,
> the [ command was just an alias (a hardlink or softlink) of the test
> command. I don't know why that changed.

The question intrigued me, so I checked the source for the /bin/test
on my Slackware installation. It appears that, for the GNU CoreUtils
version of test, GNU took "the long way around" in it's error reporting.

Specifically, the source includes conditional compilation logic to 
report name of the binary based on a value passed in at compilation time.
So, the compilation of test.c produces one of two slightly different
binaries (only the embedded program name changes), depending on whether
the compile includes a -DLBRACKET=1 or not.

The "classic Unix" way to determine the binary's name was to check or
report the contents of argv[0], with no difference in the binaries of
/bin/test and /bin/[ .


[snip]
-- 
Lew Pitcher
"In Skills, We Trust"

Back to comp.os.linux.misc | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

correct quoting for variables in bash scripts? Barry Stir <scooter@mealteam6.mil> - 2022-10-17 19:28 +0800
  Re: correct quoting for variables in bash scripts? Aragorn <telcontar@duck.com> - 2022-10-17 14:10 +0200
  Re: correct quoting for variables in bash scripts? Ralf Fassel <ralfixx@gmx.de> - 2022-10-17 14:15 +0200
    Re: correct quoting for variables in bash scripts? Jerry Peters <jerry@example.invalid> - 2022-11-01 20:27 +0000
  Re: correct quoting for variables in bash scripts? "Carlos E. R." <robin_listas@es.invalid> - 2022-10-17 14:39 +0200
  Re: correct quoting for variables in bash scripts? Rich <rich@example.invalid> - 2022-10-17 14:02 +0000
  Re: correct quoting for variables in bash scripts? Henning Hucke <h_hucke+spam.news@newsmail.aeon.icebear.org> - 2022-10-17 13:54 +0000
  Re: correct quoting for variables in bash scripts? Eli the Bearded <*@eli.users.panix.com> - 2022-10-17 23:35 +0000
    Re: correct quoting for variables in bash scripts? Ralf Fassel <ralfixx@gmx.de> - 2022-10-18 11:31 +0200
      Re: correct quoting for variables in bash scripts? Rich <rich@example.invalid> - 2022-10-18 12:02 +0000
        Re: correct quoting for variables in bash scripts? Ralf Fassel <ralfixx@gmx.de> - 2022-10-18 15:01 +0200
          Re: correct quoting for variables in bash scripts? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2022-10-18 14:17 +0000
            The difference between /bin/test and /bin/[ Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2022-10-18 14:58 +0000
              Re: The difference between /bin/test and /bin/[ Eli the Bearded <*@eli.users.panix.com> - 2022-10-21 04:41 +0000
            Re: correct quoting for variables in bash scripts? Ralf Fassel <ralfixx@gmx.de> - 2022-10-19 12:04 +0200

csiph-web