[prog] bash: string comparisons in conditionals

Riccarda Cassini riccarda.cassini at gmx.de
Fri Apr 23 14:46:24 EST 2004

Conor Daly wrote:
> AIUI, test is not a bash builtin;
> [cdaly at bofh cdaly]$ which [
> /usr/bin/[
> [cdaly at bofh cdaly]$ ls -l /usr/bin/[
> lrwxrwxrwx    1 root     root            4 Nov  4 11:56 /usr/bin/[ -> test
> Since you're calling 'test' as '[', should you be looking for '[' in
> strace's output rather than 'test'?  I don't know, just wondering.

Actually, I did try both variants... same result: no trace of 'test'
or '[' whatsoever (also no exec*() other than the main script...).

But what's that /usr/bin/[  then for?  Hm... maybe for some other
ancient shells?

Another question that just occurred to me: is there any difference
whether I write 'test' (for example) on the interactive commandline,
or stick it into some shell script (that I run via #!/bin/sh). Or,
put differently, is a builtin always treated as a builtin, even on the
commandline, or would I interactively run some corresponding binary,
if one is found along the search path for executables?  Hmm, hope you
understand what I mean... (I guess I can force the binary to be run 
by writing /usr/bin/test, but what about plain 'test'?)



...got to do some 'real' work now (java-GUI) -  unfortunately, I'm
currently not being paid for doing investigations of this sort... ;-) 
Will carry on with this as soon as I get around to it in the evening.

NEU : GMX Internet.FreeDSL
Ab sofort DSL-Tarif ohne Grundgebühr: http://www.gmx.net/dsl

More information about the Programming mailing list