Re: [ in /usr/bin Question
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Bob McGowan wrote:
> bdeferme wrote:
>> Tom Grove <debian@voidmain.net> wrote:
>>
>>> Hello all...I am new to this Debian thing :-) I used it in the Woody
>>> days but moved over to the FreeBSD world for the last few years. I
>>> recently installed Testing (Lenny) and see the left bracket in my
>>> /usr/bin directory and do not know what it is. When I ls -al it I get:
>>>
>>> -rwxr-xr-x 1 root root 24752 2007-01-30 13:51 /usr/bin/[
>>>
>>> This leads me to believe that it was installed with the base system or
>>> some package because I just installed the system earlier this week.
>>> Any help is much appreciated. Thanks.
>>>
>>> -Tom Grove
>>
>> Weird,
>> Why don't you try to run it and see what it is?
>>
>> P.S. Don't run it as root, just to be sure :-)
Why would you run anything without knowing what it is? Just in case
someone made it 'sudo rm -rf /' or whatever.
> I'm not sure why 'test' and '[' exist as separate files, today. In the
> 'old' days, '[' and 'test' were simply hard links to the same file. This
> allowed the code to look at the name used to run it and set some
> specific default behaviors. The most important of these was that the
> name '[' required a final argument of ']'. This was done to make shell
> scripting cleaner and easier to read.
>
> Today, most shells have these built in, so there's no exec overhead to
> worry about, so performance is improved. But this now means you have to
> worry about quoting and escape processing. Old Bourne shells didn't
> have these built in, so it didn't try to interpret them and escaping was
> not needed.
>
> Other responses to this question have included a number of command line
> examples with various amounts of escaping applied. I have some comments
> on those:
>
> 1. ls /usr/bin/[ and ls /usr/bin/\[ are identical (the escape is not
> needed). This is because the shell only treats '[' specially when it is
> stand alone. And ls itself doesn't process special characters.
>
> 2. When the command in question does do regex processing, it is much
> easier to escape the string from the shell with single quotes than with
> multiple backslashes.
>
> dpkg -S '/usr/bin\['
>
> is much easier to read (and type correctly), than
>
> dpkg -S /usr/bin/\\\[
There was a bit of discussion about this some time ago on this list [1],
when another guy asked a similar question to OP ;-)
- From the man pages
/-------------
NOTE: your shell may have its own version of test and/or [, which
usually supersedes
the version described here. Please refer to your shell's documentation
for details about the options it supports.
\-------------
So there are two versions of test and [ and they are all not the same.
Johannes
[1] http://lists.debian.org/debian-user/2006/08/msg00886.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFGQf05C1NzPRl9qEURAuMMAJ9yvwKm3nwYBe05A5wnI1blQ5NcXwCfQdH4
9w2gl3pLSLazPklUDGbM/3k=
=DT4z
-----END PGP SIGNATURE-----
Reply to: