[Bug 9861] New: Posix 12.2 Guideline 9 violation: options parsed after operands (found on awk)

bugzilla at busybox.net bugzilla at busybox.net
Thu May 11 19:19:59 UTC 2017


https://bugs.busybox.net/show_bug.cgi?id=9861

            Bug ID: 9861
           Summary: Posix 12.2 Guideline 9 violation: options parsed after
                    operands (found on awk)
           Product: Busybox
           Version: 1.23.x
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Standard Compliance
          Assignee: unassigned at busybox.net
          Reporter: camerisdump at gmail.com
                CC: busybox-cvs at busybox.net
  Target Milestone: ---

busybox, at least its awk utility, does not conform to Posix 12.2 Guideline 9
(http://pubs.opengroup.org/onlinepubs/9699919799/), options come before
operands, hence arguments after the first operand should not tried to be parsed
as options:  
  $ awk 'BEGIN { for(i=1; i<ARGC; ++i) { print i ": " ARGV[i] }}' -some --args
  awk: invalid option -- s

  $ gawk 'BEGIN { for(i=1; i<ARGC; ++i) { print i ": " ARGV[i] }}' -some --args
  1: -some
  2: --args

the awk-program clearly is the first operand. another example:

  $ awk 'BEGIN { for(i=1; i<ARGC; ++i) { print i ": " ARGV[i] }}' -- -some
--args
  1: -some
  2: --args

  $ gawk 'BEGIN { for(i=1; i<ARGC; ++i) { print i ": " ARGV[i] }}' -- -some
--args
  1: --
  2: -some
  3: --args

workaround, explicitly declare end of options before the program:

  $ awk -- 'BEGIN { for(i=1; i<ARGC; ++i) { print i ": " ARGV[i] }}' -some
--args
  1: -some
  2: --args

  $ gawk -- 'BEGIN { for(i=1; i<ARGC; ++i) { print i ": " ARGV[i] }}' -some
--args
  1: -some
  2: --args

In other words, the first argument that is not an option or option-argument
should have the same effect as encountering the -- argument.

Unfortunatley I can't think of any other utility that could also be affected by
this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list