Source
#=============================================================================
#-----------------------------------------------------------------------------
# affirm: Determine the Boolean value of a set of arguments
#-----------------------------------------------------------------------------
#
# Copyright (C) 1993,1994
# Associated Universities, Inc. Washington DC, USA.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Correspondence concerning AIPS++ should be addressed as follows:
# Internet email: aips2-request@nrao.edu.
# Postal address: AIPS++ Project Office
# National Radio Astronomy Observatory
# 520 Edgemont Road
# Charlottesville, VA 22903-2475 USA
#
#-----------------------------------------------------------------------------
# Usage: affirm [-a | -o ] [-s] [string1 [string2...]]
#-----------------------------------------------------------------------------
# affirm tests all of 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.
#
# Options:
# -a Produce the logical AND of all arguments (default).
# -o Produce the logical OR of all arguments.
# -s Silent, just produce the exit status.
#
# Status return values correspond to the various phases of the operation
# 0: true
# 1: false
# 2: unrecognized argument
#
# Notes:
# 1) The "-a" option returns immediately if it encounters a false argument;
# remaining arguments are not checked for validity. It can best be
# thought of as searching for a "false" argument. Even if the argument
# list contains an unrecognized value the search still continues for a
# "false" value. If none are found and there were no unrecognized
# arguments then it returns "true".
#
# 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
#