NetBSD-Bugs archive

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

bin/59766: awk does not handle RS="\0"



>Number:         59766
>Category:       bin
>Synopsis:       awk does not handle RS="\0"
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 16 19:20:00 +0000 2025
>Originator:     David A. Holland
>Release:        NetBSD 11.99.4 (20251116)
>Organization:
Windmill containment office
>Environment:
System: n/a
Architecture: irrelevant
Machine: irrelevant

>Description:

Awk does the wrong thing if you try to set the record separator to
NUL; it prints only the first record. This would be useful to have
working in conjunction with find -print0.

>How-To-Repeat:

valkyrie% mkdir /tmp/test
valkyrie% cd /tmp/test
valkyrie% mkdir foo
valkyrie% mkdir bar
valkyrie% mkdir bar/baz
valkyrie% touch foo/foo.c
valkyrie% touch bar/baz.c
valkyrie% find . -type f -print0 | hexdump -C
00000000  2e 2f 66 6f 6f 2f 66 6f  6f 2e 63 00 2e 2f 62 61  |./foo/foo.c../ba|
00000010  72 2f 62 61 7a 2e 63 00                           |r/baz.c.|
00000018
valkyrie% find . -type f -print0 | awk 'BEGIN { RS="\0"; } { print; }'
./foo/foo.c
valkyrie% 

(In fact, that's what it prints with the default RS too, probably
because it treats the whole input as one line but loses the part after
the first NUL)

>Fix:

Likely a pain :-)

>Unformatted:
 


Home | Main Index | Thread Index | Old Index