Re: Stupid bash question

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

 



On Tue, 2007-12-11 at 23:26 -0500, Joe Smith wrote:
> Tony Nelson wrote:
>  > The reason seems weak to me, but test does not require a closing
>  > square bracket, while [ does, and:
>  > ...
>  >> GNU Coding Standards now declare that the behaviour of binary
>  >> should not depend on its name.
> 
>  From http://www.gnu.org/prep/standards/html_node/User-Interfaces.html:
> > Please don't make the behavior of a utility depend on the name used to
> > invoke it. It is useful sometimes to make a link to a utility with a
> > different name, and that should not change what it does.
> 
> Sounds more like a request than a declaration ;-)
> 
> I wish they had provided some rationale,
It's simplicity and usage-safety.

>  seeing as how the practice has 
> a long history on Unix,
Right, some (actually very few) packages apply this working principle.

>  and I (at least) have not run into any situation 
> where it caused a problem.
It would be quite easy to provoke:

Assume a program to change its behavior depending on whether it's called
"X", "Y" or "Z". Now rename it to "A" or try to use copy of X under the
name "myX".

Which behavior will "A" or "myX" expose? The results will be random.


IMO, the fact you haven't seen such effects only is the result of only
very few programs applying "change behavior upon program name" ;)

> Requiring the closing bracket or not seems like a trivial difference in 
> behavior, no?
> 
> Yep, I'll go with 'weak' as well.
> 
> Over a few hundred systems, this must be wasting almost a penny's worth 
> of space.

... until people notice that they hardly ever use an external
test-binary but are almost always using a shell's builtin, instead ;)

Ralf



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux