LDP/LDP/guide/docbook/abs-guide/and-list2.sh

19 lines
624 B
Bash
Raw Permalink Normal View History

2001-07-10 14:25:50 +00:00
#!/bin/bash
2001-09-04 13:27:31 +00:00
ARGS=1 # Number of arguments expected.
2008-11-23 22:43:47 +00:00
E_BADARGS=85 # Exit value if incorrect number of args passed.
2001-07-10 14:25:50 +00:00
test $# -ne $ARGS && \
2008-11-23 22:43:47 +00:00
# ^^^^^^^^^^^^ condition #1
echo "Usage: `basename $0` $ARGS argument(s)" && exit $E_BADARGS
2008-11-23 22:43:47 +00:00
# ^^
# If condition #1 tests true (wrong number of args passed to script),
2005-06-05 14:39:50 +00:00
#+ then the rest of the line executes, and script terminates.
2001-07-10 14:25:50 +00:00
# Line below executes only if the above test fails.
echo "Correct number of arguments passed to this script."
exit 0
# To check exit value, do a "echo $?" after script termination.