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

Re: Bash true/false builtings undocumented? "false" not working?



On Fri, Aug 17, 2018 at 10:51:03AM +0200, Nicolas George wrote:
> Zenaan Harkness (2018-08-17):
> > But whilst the subsequent list of Bash builtin commands DOES include
> > entries for ":" (the very first entry) and "test", it appears to fail
> > to include entries for "true" and for "false".
> 
> Maybe because it does the same thing as the standard and non-builtin
> true and false?
> 
> > $ test $? &&
> 
> Stop right there. "test $?" does not do what you think it does.

Aha. It's actually the Special Parameter "?", aka "$?" that I did not
understand - I was treating it as a value, when actually it is
something that expands, i.e. into a string, and not something that is
treated as true or false.

D∀nka shøn ⨟⟩


So!  I guess the way to test the EXPANSION of the the most recent
exit status, is to test it as a string value, assuming use of the
token "$?".

Seems clunky.

Is there a "cleaner" way to test the true/ error exit status other
than using "$?", with bonus points for working in posix sh as well as
Bash, ?

TIA,


Reply to: