
05-02-2007
|
|
Shell programmer, author
|
|
|
Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,372
|
|
Quote:
|
Originally Posted by hitmansilentass
Hi ,
how can i reduce the or conditions:
if [[ -z $XXXX || -z $YYYYY || -z $TTTT || -z $NNNN || -z $QQQQ ]]; then
whatever
fi
|
To exit the script if any var is empty or unset:
Code:
: ${XXXX:?} ${YYYYY:?} ${TTTT:?} ${NNNN:?} ${QQQQ:?}
To execute something if any parameter is empty or unset:
Code:
var=${XXXX:+A}${YYYYY:+A}${TTTT:+A}${NNNN:+A}${QQQQ:+A}
if [ ${#var} -ne 5 ]; then
|