1#!/bin/bash 2 3if [[ -z "$AWK" || -z "$WORKDIR" ]]; then 4 printf '$AWK and $WORKDIR must be set\n' >&2 5 exit 1 6fi 7 8TEMP1=$WORKDIR/test.temp.1 9 10RESULT=0 11 12fail() { 13 echo "$1" >&2 14 RESULT=1 15} 16 17echo T.flags: test some commandline flags 18 19$AWK > $TEMP1 2>&1 20grep '[Uu]sage' $TEMP1 >/dev/null || fail 'T.flags: bad usage' 21 22$AWK -f > $TEMP1 2>&1 23grep 'no program' $TEMP1 >/dev/null || fail 'T.flags: bad no program' 24 25$AWK -f glop/glop > $TEMP1 2>&1 26grep 'can.t open' $TEMP1 >/dev/null || fail 'T.flags: bad can.t open program' 27 28$AWK -fglop/glop > $TEMP1 2>&1 29grep 'can.t open' $TEMP1 >/dev/null || fail 'T.flags: bad can.t open program 2' 30 31$AWK -zz 'BEGIN{}' > $TEMP1 2>&1 32grep 'unknown option' $TEMP1 >/dev/null || fail 'T.flags: bad unknown option' 33 34$AWK -F > $TEMP1 2>&1 35grep 'field separator.*empty' $TEMP1 >/dev/null || fail 'T.flags: bad null field separator' 36 37exit $RESULT 38