Date: Sat, 08 Feb 2003 01:01:54 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: abc AT anchorageinternet DOT org Message-Id: <2950-Sat08Feb2003010153+0200-eliz@is.elta.co.il> X-Mailer: emacs 21.3.50 (via feedmail 8 I) and Blat ver 1.8.9 CC: djgpp AT delorie DOT com In-reply-to: <200302072036.h17KaAHw096385@en26.groggy.anc.acsalaska.net> (abc AT anchorageinternet DOT org) Subject: Re: Bug: bash? date? awk? References: <200302072036 DOT h17KaAHw096385 AT en26 DOT groggy DOT anc DOT acsalaska DOT net> Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > 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.