Here's a shell session illustrating the problem: $ export LC_ALL=C $ export PATH=/usr/bin:/bin $ echo x | awk '/[[:cntrl:]]/' x The output should be empty, but awk mistakenly acts as if "x" is a control character. This bug broke a script that we use in GNU Emacs development; please see: http://lists.gnu.org/archive/html/emacs-devel/2014-12/msg00704.html
Created attachment 174328 [details] Skip NUL to avoid preemptive truncation The NUL character in cntrl is truncates the pattern, and an empty pattern matches anything. The attached patch skips NUL as a quick fix.
A commit references this bug: Author: ache Date: Sat Sep 3 23:04:56 UTC 2016 New revision: 305365 URL: https://svnweb.freebsd.org/changeset/base/305365 Log: The bug: $ echo x | awk '/[[:cntrl:]]/' x The NUL character in cntrl class truncates the pattern, and an empty pattern matches anything. The patch skips NUL as a quick fix. PR: 195792 Submitted by: kdrakehp@zoho.com Approved by: bwk@cs.princeton.edu (the author) MFC after: 3 days Changes: head/contrib/one-true-awk/b.c
A commit references this bug: Author: ache Date: Tue Sep 6 00:32:34 UTC 2016 New revision: 305447 URL: https://svnweb.freebsd.org/changeset/base/305447 Log: MFC r305365 The bug: $ echo x | awk '/[[:cntrl:]]/' x The NUL character in cntrl class truncates the pattern, and an empty pattern matches anything. The patch skips NUL as a quick fix. PR: 195792 Submitted by: kdrakehp@zoho.com Approved by: bwk@cs.princeton.edu (the author) Changes: _U stable/10/ stable/10/contrib/one-true-awk/b.c
A commit references this bug: Author: ache Date: Tue Sep 6 00:33:54 UTC 2016 New revision: 305448 URL: https://svnweb.freebsd.org/changeset/base/305448 Log: MFC r305365 The bug: $ echo x | awk '/[[:cntrl:]]/' x The NUL character in cntrl class truncates the pattern, and an empty pattern matches anything. The patch skips NUL as a quick fix. PR: 195792 Submitted by: kdrakehp@zoho.com Approved by: bwk@cs.princeton.edu (the author) Changes: _U stable/11/ stable/11/contrib/one-true-awk/b.c
A commit references this bug: Author: ache Date: Tue Sep 6 00:53:21 UTC 2016 New revision: 305450 URL: https://svnweb.freebsd.org/changeset/base/305450 Log: MFC r305365 The bug: $ echo x | awk '/[[:cntrl:]]/' x The NUL character in cntrl class truncates the pattern, and an empty pattern matches anything. The patch skips NUL as a quick fix. PR: 195792 Submitted by: kdrakehp@zoho.com Approved by: bwk@cs.princeton.edu (the author) Changes: _U stable/9/ _U stable/9/contrib/ _U stable/9/contrib/one-true-awk/ stable/9/contrib/one-true-awk/b.c