diff options
-rw-r--r-- | share/txr/stdlib/awk.tl | 3 | ||||
-rw-r--r-- | txr.1 | 32 |
2 files changed, 34 insertions, 1 deletions
diff --git a/share/txr/stdlib/awk.tl b/share/txr/stdlib/awk.tl index 23db2403..a2fa0785 100644 --- a/share/txr/stdlib/awk.tl +++ b/share/txr/stdlib/awk.tl @@ -31,7 +31,7 @@ fs ft kfs (ofs " ") (ors "\n") - (inputs (or *args* (list *stdin*))) + (inputs) (output *stdout*) (file-num 0) (file-rec-num 0) @@ -44,6 +44,7 @@ (dohash (k v self.streams) (close-stream v))) (:postinit (self) + (set self.inputs (or self.inputs (zap *args*) (list *stdin*))) (if (plusp self.rng-n) (set self.rng-vec (vector self.rng-n))) (unless (streamp self.output) @@ -41383,6 +41383,38 @@ is taken as the input sources. Otherwise, the .code *stdin* stream is taken as the one and only input source. +If the +.code awk +macro uses +.code *args* +via the above defaulting behavior, it copies +.code *args* +and sets that variable to +.codn nil . +This is done in order that if +.code awk +is used from the \*(TX command line, for example using the +.code -e +command line option, after +.code awk +terminates, \*(TX will not try to open the next argument +as a script file or treat it as an option. +Note: programs which want +.code awk +not to modify +.code *args* +can explicitly specify +.code *args* +as the argument to the +.code :inputs +keyword, rather than allow +.code *args* +to be used through the defaulting behavior. Only the +defaulting behavior consumes the arguments by overwriting +.code *args* +with +.codn nil . + It is an error to specify more than one .code :inputs clause. |