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

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

Zenaan Harkness (2018-08-17):
> 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.

That is how all parameters work, not just $?. It seems your problem was
more basic than I expected.

> 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.

That is shell.

> 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, ?

$? is the correct parameter to test, and testing it as a string is

You could use expr to make numerical computations, but in this instance
it is completely overkill.


  Nicolas George

Attachment: signature.asc
Description: Digital signature

Reply to: