[tex-live] how robustly call awk script?

Sanjoy Mahajan sanjoy at mrao.cam.ac.uk
Sun Jan 14 23:26:22 CET 2007


> #!/usr/bin/env foo=bar awk -f
> works.

It was a convincing argument.  I tried

#!/usr/bin/env foo=bar awk -f
BEGIN {total=0}
{total += $1}
END {print total}

It infinite loops (linux i386 + bash 3.1.17).  strace shows how it
fills the time:

$ strace -eprocess /tmp/x.sh
execve("/tmp/x.sh", ["/tmp/x.sh"], [/* 36 vars */]) = 0
execve("/tmp/x.sh", ["/tmp/x.sh"], [/* 37 vars */]) = 0
execve("/tmp/x.sh", ["/tmp/x.sh"], [/* 37 vars */]) = 0
execve("/tmp/x.sh", ["/tmp/x.sh"], [/* 37 vars */]) = 0
execve("/tmp/x.sh", ["/tmp/x.sh"], [/* 37 vars */]) = 0
execve("/tmp/x.sh", ["/tmp/x.sh"], [/* 37 vars */]) = 0
execve("/tmp/x.sh", ["/tmp/x.sh"], [/* 37 vars */]) = 0
...

It keeps re-execing itself instead of trying to run awk.  Or maybe I'm
just being dense.  But I don't see a simple way to do this simple
task.  And even if I find one that works on my system, I'd be highly
skeptical that it would work on any other system.

-Sanjoy

`Not all those who wander are lost.' (J.R.R. Tolkien)


More information about the tex-live mailing list