[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: That '[' file in /usr/bin

From: Eric Blake
Subject: Re: That '[' file in /usr/bin
Date: Sat, 23 Feb 2013 13:56:20 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 02/23/2013 10:25 AM, Salvador Girbau wrote:
> Hi all,
> would it be possible to replace /usr/bin/[ with a symlink to /usr/bin/test ?

Not really.  Although [ and test are compiled from the same sources,
they are compiled with different macro definitions, and have different
behavior (namely, whether --help is supported, and whether a ] must
appear as the last command line argument).  GNU Coding Standards
recommend that programs never inspect argv[0] as a means of dynamically
changing their behavior, and coreutils follows this rule by compiling
two separate binaries with the two different behaviors, regardless of
what the resulting binary finally gets named.

If you want to go for minimal binary size, then busybox is a better
project - that project has intentionally decided to base behavior on the
name of argv[0], and hence can symlink both [ and test to the same
busybox binary (along with a host of other utilties all crammed into one
super-binary).  But coreutils will not be adopting that approach.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]