[Bug 12486] New: awk: length without () does not work properly

bugzilla at busybox.net bugzilla at busybox.net
Sat Jan 18 00:52:28 UTC 2020


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

            Bug ID: 12486
           Summary: awk: length without () does not work properly
           Product: Busybox
           Version: 1.31.x
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Standard Compliance
          Assignee: unassigned at busybox.net
          Reporter: wolf+busybox at wolfsden.cz
                CC: busybox-cvs at busybox.net
  Target Milestone: ---

Created attachment 8346
  --> https://bugs.busybox.net/attachment.cgi?id=8346&action=edit
Additions to the test suite

While 8371 did solve part of length without parentheses behaviour, there are
still other cases that do not work, for example:

```
+$ echo | busybox awk '{ print length, 1 }'
awk: cmd. line:1: Unexpected token
+$ echo | awk '{ print length, 1 }'
0 1
+$ echo | busybox awk '{ print length 1 }'
awk: cmd. line:1: Unexpected token
+$ echo | awk '{ print length 1 }'
01
```

the length is also legal in the pattern part:

```
+$ echo | busybox awk 'length == 0 { print "foo" }'
awk: cmd. line:1: Unexpected token
+$ echo | awk 'length == 0 { print "foo" }'
foo
```

and in ifs

```
+$ echo | busybox awk '{ if (length == 0) { print "bar" } }'
awk: cmd. line:1: Unexpected token
:$ echo | awk '{ if (length == 0) { print "bar" } }'
bar
```

Comparisons are done on up-to-date Archlinux on amd64 using:

```
+   $ busybox --help | head -1
BusyBox v1.31.1 () multi-call binary.
+   $ awk --version | head -n 1
GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)
```


I did try to make a patch for this, but after few hours I've concluded that I
have no idea how. What I have is addition to the test suite for awk, which is
attached to this bug report.

EDIT: Well... I figured out something. It's ugly, but it works. It would
probably be better to solve it in more elegant way, but still attaching it for
completeness' sake.

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


More information about the busybox-cvs mailing list