[Bug 13346] New: awk doesn't support calling length() without parentheses

bugzilla at busybox.net bugzilla at busybox.net
Mon Nov 30 11:37:26 UTC 2020


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

            Bug ID: 13346
           Summary: awk doesn't support calling length() without
                    parentheses
           Product: Busybox
           Version: 1.30.x
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Standard Compliance
          Assignee: unassigned at busybox.net
          Reporter: richard.noble at safe-mail.net
                CC: busybox-cvs at busybox.net
  Target Milestone: ---

The following should print all lines in /etc/motd that are longer than
50 characters:

$ busybox awk 'length > 50' /etc/motd

Instead you get an error:

awk: cmd. line:1: Unexpected token

If you call length as length() it works:

$ busybox awk 'length() > 50' /etc/motd

Note the following from the GAWK manual:

"NOTE: In older versions of awk, the length() function could be called
without any parentheses. Doing so is considered poor practice, although
the 2008 POSIX standard explicitly allows it, to support historical
practice. For programs to be maximally portable, always supply the
parentheses."

<https://www.gnu.org/software/gawk/manual/html_node/String-Functions.html>

The parens are optional according to the 2018 POSIX standard too:

"length[([s])]
    Return the length, in characters, of its argument taken as a string,
    or of the whole record, $0, if there is no argument."

<https://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html>

(tested on BusyBox v1.30.1 (Debian 1:1.30.1-4))

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


More information about the busybox-cvs mailing list