[tex-live] how robustly call awk script?
Sanjoy Mahajan
sanjoy at mrao.cam.ac.uk
Sun Jan 14 18:45:41 CET 2007
> It means that env took the "-f" option which you want to pass to awk.
Right. I straced x.sh which is a simple script to total the numbers
on stdin (I use it to unbalance my checkbook):
#!/usr/bin/env awk -f
BEGIN {total=0};
{total += $1}
END {print total}
and it had these lines as it tried to find awk on the path:
...
execve("/usr/bin/awk -f", ["awk -f", "./x.sh"], [/* 36 vars */]) = -1
ENOENT (No such file or directory)
So env stupidly combines the -f with the program name, making argv[0]
= "awk -f", and searches for a binary named "/usr/bin/awk -f" (!)
which will never be found.
Without the -f, i.e. "#! /usr/bin/env awk", it won't work at all
because awk thinks the rest of the file are lines to be processed,
rather than pattern text. So I think your solution is the only
portable one.
-Sanjoy
`Not all those who wander are lost.' (J.R.R. Tolkien)
More information about the tex-live
mailing list