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

Garrett Wollman wollman at
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>
To: rfg at
Cc: freebsd-gnats-submit at
Subject: Re: bin/169500: /bin/expr improperly requires forward slash to be
Date: Wed, 27 Jun 2012 21:36:24 -0400 (EDT)

 In article <20120627214105.A1EA35081B at>,
 rfg at writes:
 >According to my reading of Sections and 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).
 Garrett A. Wollman    | What intellectual phenomenon can be older, or more oft
 wollman at| 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