On Tue, Feb 18, 2003 at 12:39:22PM +0100, Poul-Henning Kamp wrote: > > > Running: > > #!/bin/sh > set -ex > > for p in ad2 ad0 ad1 > do > a0=`expr $p : '^ad\([0-9]\)$'` > done > > I get: > > syv# sh _ > + expr ad2 : ^ad\([0-9]\)$ > + a0=2 > + expr ad0 : ^ad\([0-9]\)$ > + a0=0 > syv# echo $? > 1 > syv# > > That looks like a bug to me...
Confusing but documented behaviour: 1. expr ad0 : ad\([0-9]\) => expr 0 man expr If the match succeeds and the pattern contains at least one regu- lar expression subexpression ``\(...\)'', the string correspond- ing to ``\1'' is returned; otherwise the matching operator 2. `expr 0` => exit status = 1 man expr The expr utility exits with one of the following values: 0 the expression is neither an empty string nor 0. 1 the expression is an empty string or 0. This behaviour is the same on linux, *BSD and probably other systems too. Regards Adi To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message