bug-bash
[Top][All Lists]
Advanced

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

Re: Why sh does not return a false value?


From: Maarten Billemont
Subject: Re: Why sh does not return a false value?
Date: Sat, 5 Feb 2011 14:18:20 +0100

On 05 Feb 2011, at 13:47, ali hagigat wrote:
> 
> if (sh -c exit 34) then echo ppppppppp;fi
> ppppppppp
> The following condition should be false, because our exit value is
> non-zero. but 'if' considers the condition as true and executes 'echo'
> command. Why?
> 

You are giving -c the argument 'exit' and setting "34" as the zero'th argument 
to the script.  It's vital to understand what word splitting is.  Quotes are 
used to keep words together so they are passed as a single argument.  -c takes 
only one single argument, so to pass the command exit 34 to -c, you quote it.


reply via email to

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