想要一个AWK实现“@include” [英] Want an AWK that implements '@include'
问题描述
在gawk的手册我把它描述了一个 @include 运营商。这可让您.awk模块和共享脚本等包含文件。
In the gawk manual I have it describes an @include operator. This lets you make .awk modules and share scripts, etc. Include files.
到目前为止最新的cgywin,MinGW和GNU AWK-S(AWK,GAWK,mawk,NAWK,...)我已经找到了失败的Windows上的第一个: @include 语句。
So far the latest cgywin, mingw and gnu awk-s (awk, gawk, mawk, nawk, ...) I've found for Windows fail on the first: @include statement.
有人点我到实现的Windows全NAWK和awk实现一个版本?我是pretty确保有至少有一个NAWK,早在一天,我们已经下载到运行Windows NT的。
Can someone point me to a version that implements the whole nawk or awk implementation for Windows? I am pretty sure there was at least one nawk, back in the day, that we had downloaded to run Windows NT.
另外一种解决方法是在此期间有帮助的。 (说一个pre-测试AWK includer程序?)
Alternately a work around would be helpful in the meantime. (Say a pre-tested awk includer program??)
的 TIA 的,
请问
tia, Will
推荐答案
据我所知, @include
文件本身不支持GAWK直到4.x版。然而,至少在Linux上,它附带一个名为shell脚本 igawk
,您可以使用替代;它preprocesses awk脚本,并替换 @include
s的包含文件(通过 $ AWKPATH
中的内容)。也许Cygwin的也有这个脚本?
As far as I can tell, @include
files are not supported natively by gawk until 4.x. However, at least on Linux, it ships with a shell script called igawk
that you can use instead; it preprocesses awk scripts and replaces @include
s with the contents of the included file (found via $AWKPATH
). Perhaps Cygwin also has this script?
$ cat foo.awk
@include bar.awk
$ cat bar.awk
BEGIN {print "Hello, world!" }
$ awk -f foo.awk
awk: foo.awk:1: @include bar.awk
awk: foo.awk:1: ^ invalid char '@' in expression
$ gawk -f foo.awk
gawk: foo.awk:1: @include bar.awk
gawk: foo.awk:1: ^ invalid char '@' in expression
$ igawk -f foo.awk
Hello, world!
请注意,但是, igawk
和呆子4的 @include
语法不兼容。在GAWK 4本机 @include
要求对文件名包含带引号的字符串; igawk
的需要裸词,并会尝试找到其名称中引号的文件,如果你引用它。
Note, however, that igawk
and gawk 4's @include
syntaxes are not compatible. The native @include
in gawk 4 requires a quoted string for the included filename; igawk
's takes a bareword, and will try to find a file with quotation marks in its name if you quote it.
这篇关于想要一个AWK实现“@include”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!