source: trunk/essentials/sys-apps/gawk/pc/awklib/igawk

Last change on this file was 3076, checked in by bird, 18 years ago

gawk 3.1.5

File size: 1.6 KB
Line 
1#! /bin/sh
2
3# igawk --- like gawk but do @include processing
4# Arnold Robbins, arnold@gnu.ai.mit.edu, Public Domain
5# July 1993
6
7igs=${TMP:-/tmp}/igs$$
8ige=${TMP:-/tmp}/ige$$
9
10if [ "$1" = debug ]
11then
12 set -x
13 shift
14else
15 # cleanup on exit, hangup, interrupt, quit, termination
16 #trap 'rm -f $igs $ige' 0 1 2 3 15
17 trap 'rm -f $igs $ige' 0 2 15
18fi
19
20while [ $# -ne 0 ] # loop over arguments
21do
22 case $1 in
23 --) shift; break;;
24
25 -W) shift
26 set -- -W"$@"
27 continue;;
28
29 -[vF]) opts="$opts $1 '$2'"
30 shift;;
31
32 -[vF]*) opts="$opts '$1'" ;;
33
34 -f) echo @include "$2" >> $igs
35 shift;;
36
37 -f*) f=`echo "$1" | sed 's/-f//'`
38 echo @include "$f" >> $igs ;;
39
40 -?file=*) # -Wfile or --file
41 f=`echo "$1" | sed 's/-.file=//'`
42 echo @include "$f" >> $igs ;;
43
44 -?file) # get arg, $2
45 echo @include "$2" >> $igs
46 shift;;
47
48 -?source=*) # -Wsource or --source
49 t=`echo "$1" | sed 's/-.source=//'`
50 echo "$t" >> $igs ;;
51
52 -?source) # get arg, $2
53 echo "$2" >> $igs
54 shift;;
55
56 -?version)
57 echo igawk: version 1.0 1>&2
58 gawk --version
59 exit 0 ;;
60
61 -[W-]*) opts="$opts '$1'" ;;
62
63 *) break;;
64 esac
65
66 shift
67done
68
69if [ ! -s $igs ]
70then
71 if [ -z "$1" ]
72 then
73 echo igawk: no program! 1>&2
74 exit 1
75 else
76 echo "$1" > $igs
77 shift
78 fi
79fi
80
81# at this point, $igs has the program
82gawk -f igawk.awk $igs > $ige
83eval gawk -f '$ige' $opts -- "$@"
84
85exit $?
Note: See TracBrowser for help on using the repository browser.