Mail Archives: djgpp/2003/02/07/18:06:20
> Date: Fri, 7 Feb 2003 20:36:10 GMT
> From: abc AT anchorageinternet DOT org
>
> DJGPP v2.03/Windows98
>
> $ awk 'BEGIN { system("date '+%y'`echo $$`") }'
>
> the line above crashes with the message:
>
> date.exe: too many non-option arguments
>
> however, it shouldn't crash according to RH Linux/FreeBSD.
That's because the command you pas to the `system' function is
executed by the shell, not by Gawk. On Windows, the stock shell
doesn't understand the `echo $$` part, so you get the error message.
On GNU/Linux, the shell is Bash, which does support `command`
substitution.
Solution: install the DJGPP port of Bash, set the SHELL environment
variable to point to it, and then the above AWK command will work on
Windows as well.
> $ awk 'BEGIN { system("echo $$") }'
>
> outputs: $$
>
> the (g)awk system call doesn't do $variable expansion,
> as it should ....
For the same reason: $$ is expanded by the shell, not by Gawk. Same
solution.
- Raw text -