bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gawk] Additional parameters in a #! line throwing unexpected error


From: Tim Chase
Subject: [bug-gawk] Additional parameters in a #! line throwing unexpected error
Date: Sat, 21 Dec 2013 15:15:53 -0600

While this works:

  #!/usr/bin/awk -f
  BEGIN {FS="."}
  {print $1}

the following doesn't

  #!/usr/bin/awk -F. -f
  {print $1}

failing with the following message:

  bash$ echo "hello.world" | ./demo.awk
  awk: cmd. line:1: ./demo.awk
  awk: cmd. line:1: ^ syntax error
  awk: cmd. line:1: ./demo.awk
  awk: cmd. line:1:   ^ unterminated regexp

It gives the same results if I put an extra space between the "-F"
and the desired separator.  Also, using /usr/bin/awk
vs. /usr/bin/gawk makes no difference.

The same code works as expected when it's all on the command-line:

  bash$ echo "hello.world" | awk -F. '{print $1}'
  hello

According to the man/info pages, the syntax should allow for options
before the "-f", and at least short options appear to be permissible
within the #! line according to "Additionally, each long option has a
corresponding short option, so that the option's functionality may be
used from within #! executable scripts."

I don't seen any mention in the man/info pages as to why this
wouldn't work.  Is this a documentation bug or a functionality bug?

-tkc







reply via email to

[Prev in Thread] Current Thread [Next in Thread]