[Top][All Lists]

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

[bug-gawk] In Regexps, Extra (Unmatched) Closing Parentheses Does Not Pr

From: Neil R. Ormos
Subject: [bug-gawk] In Regexps, Extra (Unmatched) Closing Parentheses Does Not Produce Error Message, Treated Literally
Date: Sun, 9 Jun 2019 13:05:41 -0500 (CDT)

In a regexp, an unmatched left parenthesis
provokes an error message.

 > ./gawk '/(abc/{ print "ok" };'
 gawk: cmd. line:1: error: Unmatched ( or \(: /(abc/

An unmatched right parenthesis does not provoke an
error message, and it must be matched literally.

 > echo "/abc"  | gawk '/abc)/{ print "ok" };'
 [no output]

 > echo "/abc)" | gawk '/abc)/{ print "ok" };'

This behavior is the same as grep's, so I assume
this is not an error, but rather an intended
behavior of the regexp library...

... but it would be nice if there were some hint
in the manual that a right parenthesis is treated
as special only when there's a matching left
parenthesis.  (Apologies in advance if it's there,
and I just missed it.)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]