bin/169500: /bin/expr improperly requires forward slash to be escaped

Garrett Wollman wollman at hergotha.csail.mit.edu
Thu Jun 28 01:40:09 UTC 2012


The following reply was made to PR bin/169500; it has been noted by GNATS.

From: Garrett Wollman <wollman at hergotha.csail.mit.edu>
To: rfg at tristatelogic.com
Cc: freebsd-gnats-submit at freebsd.org
Subject: Re: bin/169500: /bin/expr improperly requires forward slash to be
	escaped
Date: Wed, 27 Jun 2012 21:36:24 -0400 (EDT)

 In article <20120627214105.A1EA35081B at segfault.tristatelogic.com>,
 rfg at tristatelogic.com writes:
 
 >According to my reading of Sections 2.8.3.1.1 and 2.8.3.1.2 of the ANSI/IEEE
 >standard 1003.2, a forward slash character (/) is an "ordinary" basic
 >regular expression (BRE) character, and as such can be used in a BRE alone
 >to match itself.
 
 IEEE Std.1003.2 was obsoleted by the publication of IEEE
 Std.1003.1-2001; your reference is at least fifteen years old.
 
 >As far as I can tell, backslash-escaping of this specific character
 >should not be required within BREs.
 
 Nothing to do with the BRE-ness.  As the 2001 edition of the standard
 states (page 429, lines 16598-16599):
 
 	A string argument is an argument that cannot be identified as
 	an integer argument or as one of the expression operator
 	symbols shown in the OPERANDS section.
 
 '/' is "one of the expression operator symbols shown", and thus is not
 permitted as the second (or first!) operand of the ':' operator, which
 must both be "string arguments" meeting this defintion.  As the
 APPLICATION USAGE section states (same page, lines 16609ff):
 
 	After argument processing by the shell, expr is not required
 	to be able to tell the difference between an operator and an
 	operand except by the value. If "$a" is '=', the command:
 
 	    expr $a = '='
 
 	looks like:
 
 	    expr = = =
 
 	as the arguments are passed to expr (and they all may be taken
 	as the '=' operator).
 
 -GAWollman
 
 -- 
 Garrett A. Wollman    | What intellectual phenomenon can be older, or more oft
 wollman at bimajority.org| repeated, than the story of a large research program
 Opinions not shared by| that impaled itself upon a false central assumption
 my employers.         | accepted by all practitioners? - S.J. Gould, 1993


More information about the freebsd-bugs mailing list