autoconf
[Top][All Lists]
Advanced

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

OT Re: what's the effect of test in ac_define_dir.m4


From: Guido Draheim
Subject: OT Re: what's the effect of test in ac_define_dir.m4
Date: Mon, 24 Jun 2002 14:31:13 +0200

Before things get messy:

for a newbie it might be best to think of every shell command line
to expand into setting finally the integer-variable $? representing
the final value of the command. Therefore, a line like that written
below will expand to

$? = ( xxx == TRUE && yyy == TRUE )

and in a shell, the "&&" works like you used to from C as that it
is short-circuting - if the first execution (xxx == TRUE) returns
false, the second will never get executed. As homework, explain
the following line, and notice that the "test" command will only 
receive arguments up to but _not_ including "||".

test -d "/tmp/my" || mkdir "/tmp/my"

and note that shell-assignments survive a "&&" as long as you do
not try to put them into a subshell with the innocent-looking
round paratheses, so that in the follwoing snippets the first
one has a different results on the terminal than the latter two:

prefix=NONE
test "x$prefix" = xNONE && prefix="/usr/local"
echo $prefix

- vs. -

prefix=NONE
(test "x$prefix" = xNONE && prefix="/usr/local")
echo $prefix

- vs. -

prefix=NONE
(test "x$prefix" = xNONE) && (prefix="/usr/local")
echo $prefix



Es schrieb Ionutz Borcoman:
> 
> Evrika :-)
> 
> Yes, you're right. But I've been for too long a C programmer (and never
> a shell one). I've thought '&&' was for test command. Something like in:
>    if ( xxx == TRUE && yyy == TRUE ) {};
> 
> So the C++ equivalent of this bash line:
>    test xxx="xxx" && xxx="zzz"
> is
>    if( xxx == "xxx" ) { xxx  = "zzz"; }
> 
> Right ?
> 
> TIA,
> 
> Ionutz
> 
> Andreas Schwab wrote:
> >
> > ??? Of course, it is used, in a conditional.



reply via email to

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