Bug 10596

Summary: awk is broken
Product: Busybox Reporter: Steffen Nurpmeso <steffen>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.27.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description Steffen Nurpmeso 2017-12-16 16:07:47 UTC
Busybox awk is the only awk which fails in the following:

 ?1[steffen@essex tmp]$ AWK='/bin/busybox awk' mdocmx.sh -vv < /home/steffen/src/nail.git/nail.1 2>/dev/null | openssl sha1
 (stdin)= 5b31d23821fa65d58516728c73d4c3f95590589e
 ?0[steffen@essex tmp]$ AWK='nawk' mdocmx.sh -vv < /home/steffen/src/nail.git/nail.1 2>/dev/null | openssl sha1
 (stdin)= c7a6231c1df5ed65ff4a5ad67e36f05b139f2ace
 ?0[steffen@essex tmp]$ AWK='mawk' mdocmx.sh -vv < /home/steffen/src/nail.git/nail.1 2>/dev/null | openssl sha1
 (stdin)= c7a6231c1df5ed65ff4a5ad67e36f05b139f2ace
 ?0[steffen@essex tmp]$ AWK='gawk' mdocmx.sh -vv < /home/steffen/src/nail.git/nail.1 2>/dev/null | openssl sha1
 (stdin)= c7a6231c1df5ed65ff4a5ad67e36f05b139f2ace

The output is very different from the expected.
I have no idea what to tell you more, i seem to recall that i had tested it at the beginning of 2015 and it was fine?  But i may falsely remember that.

To reproduce, you could install the s-nail package on AlpineLinux, for example.  The script itself is available at [1], for example.  (Repo clone at repo.or.cz.)  Should be standalone.

 [1] https://git.sdaoden.eu/cgit/s-roff.git/plain/mdocmx.sh?h=next
Comment 1 Denys Vlasenko 2018-01-04 14:08:45 UTC
Can you give me the input file which displays this behavior?
Comment 2 Steffen Nurpmeso 2018-01-04 15:06:31 UTC
You can use the mdocmx.1 file from the same URL [1] mdocmx.sh is at, it is the smallest (3010 bytes) i have that can be processed by the script:

?0[steffen@essex roff.git]$ AWK=nawk ./mdocmx.sh <mdocmx.1 | openssl sha1
(stdin)= e949a0a362d409f79a171583ff5354a678032dcc
?0[steffen@essex roff.git]$ AWK=mawk ./mdocmx.sh <mdocmx.1 | openssl sha1
(stdin)= e949a0a362d409f79a171583ff5354a678032dcc
?0[steffen@essex roff.git]$ AWK=gawk ./mdocmx.sh <mdocmx.1 | openssl sha1
(stdin)= e949a0a362d409f79a171583ff5354a678032dcc
?0[steffen@essex roff.git]$ AWK='/bin/busybox awk' ./mdocmx.sh <mdocmx.1 | openssl sha1
(stdin)= ee1f17a703d6fa8260854e69f129eabe12db7271
?0[steffen@essex roff.git]$

 [1] https://git.sdaoden.eu/cgit/s-roff.git/plain/mdocmx.1?h=next
Comment 3 Denys Vlasenko 2018-01-07 00:20:53 UTC
Thanks!
Fixed in git: "delete arr[v--]" was evaluating index expression twice.