Bug 195792 - awk mishandles [[:cntrl:]]
Summary: awk mishandles [[:cntrl:]]
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 9.1-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Andrey A. Chernov
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2014-12-08 01:09 UTC by eggert
Modified: 2016-09-06 00:55 UTC (History)
2 users (show)

See Also:
ache: mfc-stable11+
ache: mfc-stable10+
ache: mfc-stable9+


Attachments
Skip NUL to avoid preemptive truncation (613 bytes, patch)
2016-09-02 22:53 UTC, kd-dev
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description eggert 2014-12-08 01:09:36 UTC
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
Comment 1 kd-dev 2016-09-02 22:53:05 UTC
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.
Comment 2 commit-hook freebsd_committer freebsd_triage 2016-09-03 23:05:40 UTC
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
Comment 3 commit-hook freebsd_committer freebsd_triage 2016-09-06 00:33:16 UTC
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
Comment 4 commit-hook freebsd_committer freebsd_triage 2016-09-06 00:34:17 UTC
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
Comment 5 commit-hook freebsd_committer freebsd_triage 2016-09-06 00:54:20 UTC
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