$OpenBSD: patch-awklib_eg_prog_igawk_sh,v 1.1.1.1 2002/02/12 15:45:45 wilfried Exp $ --- awklib/eg/prog/igawk.sh.orig Sun May 13 17:42:06 2001 +++ awklib/eg/prog/igawk.sh Tue Feb 12 11:37:36 2002 @@ -4,13 +4,25 @@ # Arnold Robbins, arnold@gnu.org, Public Domain # July 1993 +# Temporary file handling modifications for Owl by +# Jarno Huuskonen and Solar Designer, still Public Domain +# May 2001 + +if [ ! -x /usr/bin/mktemp ]; then + echo "$0 needs mktemp to create temporary files." + exit 1 +fi + +STEMPFILE=`/usr/bin/mktemp $@{TMPDIR:-/tmp@}/igawk.s.XXXXXX` || exit 1 +ETEMPFILE=`/usr/bin/mktemp $@{TMPDIR:-/tmp@}/igawk.e.XXXXXX` || exit 1 + if [ "$1" = debug ] then set -x shift else # cleanup on exit, hangup, interrupt, quit, termination - trap 'rm -f /tmp/ig.[se].$$' 0 1 2 3 15 + trap 'rm -f $STEMPFILE $ETEMPFILE' EXIT HUP INT QUIT TERM fi while [ $# -ne 0 ] # loop over arguments @@ -27,26 +39,26 @@ do -[vF]*) opts="$opts '$1'" ;; - -f) echo @include "$2" >> /tmp/ig.s.$$ + -f) echo @include "$2" >> $STEMPFILE shift;; -f*) f=`echo "$1" | sed 's/-f//'` - echo @include "$f" >> /tmp/ig.s.$$ ;; + echo @include "$f" >> $STEMPFILE ;; -?file=*) # -Wfile or --file f=`echo "$1" | sed 's/-.file=//'` - echo @include "$f" >> /tmp/ig.s.$$ ;; + echo @include "$f" >> $STEMPFILE ;; -?file) # get arg, $2 - echo @include "$2" >> /tmp/ig.s.$$ + echo @include "$2" >> $STEMPFILE shift;; -?source=*) # -Wsource or --source t=`echo "$1" | sed 's/-.source=//'` - echo "$t" >> /tmp/ig.s.$$ ;; + echo "$t" >> $STEMPFILE ;; -?source) # get arg, $2 - echo "$2" >> /tmp/ig.s.$$ + echo "$2" >> $STEMPFILE shift;; -?version) @@ -61,19 +73,19 @@ do shift done -if [ ! -s /tmp/ig.s.$$ ] +if [ ! -s $STEMPFILE ] then if [ -z "$1" ] then echo igawk: no program! 1>&2 exit 1 else - echo "$1" > /tmp/ig.s.$$ + echo "$1" > $STEMPFILE shift fi fi -# at this point, /tmp/ig.s.$$ has the program +# at this point, $STEMPFILE has the program gawk -- ' # process @include directives @@ -124,7 +136,7 @@ BEGIN { } close(input[stackptr]) } -}' /tmp/ig.s.$$ > /tmp/ig.e.$$ -eval gawk -f /tmp/ig.e.$$ $opts -- "$@" +}' $STEMPFILE > $ETEMPFILE +eval gawk -f $ETEMPFILE $opts -- "$@" exit $?