Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1556 |
|
Determine the Boolean value of a set of arguments.
affirm [-a | -o] [-s] [string1 [string2...]]
affirm tests its arguments for truth or falsehood. The arguments can be of the form true/false, t/f, yes/no, y/n, on/off, 1/0 and are case insensitive. It will print either true or false on stdout with a status return to match.
The -o option behaves similarly except that it searches for a true argument. Hence, to test the logical value of an environment variable which may be undefined use
affirm -a $VAR
(or just affirm $VAR) to get a true result if VAR is blank, and use
affirm -o $VAR
to get a false result if VAR is blank.
affirm -o $V1 $V2 -a $V3 $V4
returns true if either of V1 or V2 is true, or if V3 and V4 are both true or both blank.
Status return values reflect a true or false result, or invokation error
0
: true
1
: false
2
: unrecognized argument
To test an aipsrc (p) resource setting (Bourne shell):
ENABLED=`affirm -a \`getrc inhale.base.code.preserve 2> /dev/null\``
Sets ENABLED to true if the inhale.base.code.preserve was set to some variant of the affirmative, or if it was not defined. To get a false value by default the -o option could have been used instead.
aipsrc (p), AIPS++ resource database.
getrc (p), query AIPS++ resource database.
Original: 1993/09/01 by Mark Calabretta, ATNF