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