BLFS Version svn-20060830 - Chapter 3. After LFS Configuration Issues - The Bash Shell Startup Files

Mag. Leonhard Landrock 1977-Hamlet at gmx.at
Mon Sep 4 10:51:07 PDT 2006


Am Montag, 4. September 2006 06:56 schrieb Bruce Dubbs:
> Mag. Leonhard Landrock wrote:
> > Hi!
> >
> > When is the following expression true?
> >
> > if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then
> >         INPUTRC=/etc/inputrc
> > fi
>
> I think you are getting confused by the -a here.

Exactly that was the point where I missed the right way.

> It *is* a bit ambiguous. 

> The [ expr ] construct is a synonym for 'test'. 

I know that, thanks. :-)

> Look at the 
> 'test' builtin in the bash man page (quite a way down):
>
> expr1 -a expr2
>             True if both expr1 and expr2 are true.

Yes!!! That's the point. :-) Funny that I missed it.

> The -a here is an expression operator between two operands, not a
> literal conditional expression like -z or ! -f  in this example.
>
> Note:  We could have made it really confusing by the valid statement:
>
> if [ -z "$INPUTRC" -a ! -a "$HOME/.inputrc" ] ; then
> ...

OK. Let's see wether I can decrypt that. ;-)

If 

1.) <-z "$INPUTRC"> says: length of string "$INPUTRC" is zero
2.) <-a> says: True if both "expr1" and "expr2" are true. "expr1" beeing 
<-z "$INPUTRC"> and "expr2" beeing <! "expr3">
3.) <! "expr3"> says: Not "expr3" with <-a "$HOME/.inputrc"> beeing "expr3".
4.) <-a "$HOME/.inputrc"> says: True if file "$HOME/.inputrc" exists.

then do ...

> :)
>
>   -- Bruce

Leonhard.



More information about the blfs-support mailing list