Subject: Re: HPPA toolchain.
To: None <>
From: Havard Eidnes <>
List: tech-toolchain
Date: 10/07/2003 13:00:25
> > There is one "nit" I've discovered. 
> [...]
> Thanks for the hint. 
> > on linux it returns "" but on netbsd and solaris8 it returns
> > a null string.  
> Tru64 5.1 and IRIX 6.5.20 sed returns a null string too, GNU sed version
> 3.02 from the IRIX FreeWare returns "". 

I've looked around a bit, and first off I'll say that I think it's a
bit difficult to find in our documentation where the forms of the
pattern expressions sed supports can be found.  sed(1) refers to the
definition of basic regular expressions (BREs) in regex(3), but you
need to follow the reference to re_format(7) in that manual page to
get to the actual definition of BREs.

From re_format(7), it appears that BREs do not support the logical or
operator, as expressed by the \| construct, and some simplification
and testing with our sed reveals that

this line:

echo "a|b" | sed -n 's,^a\|b$,c,p'

will emit "c", while this line:

echo "a" | sed -n 's,^a\|b$,c,p'

emits nothing.

I've looked at SUSv2' description of sed at

and the description of Basic Regular Expressions (which sed
implements) at

and...  It turns out that the \| construct *is* actually *not* part of
BREs.  Thus, it appears that the gcc configure script relies on a GNU
extension of sed.

The mechanical transoformation of the original line which is

               ld_vers=`echo $ld_ver | sed -n 's,^.*[   ]\([0-9][0-9]*\.[0-9][0-9]*\(\|\.[0-9][0-9]*\(\|\.[0-9][0-9]*\)\)\)\([  ].*\|\)$,\1,p'`

into portable sed would be

		ld_vers=`echo $ld_ver | sed -n \
-e 's,^.*[	]\([0-9][0-9]*\.[0-9][0-9]*\)$,\1,p' \
-e 's,^.*[	]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)$,\1,p' \
-e 's,^.*[	]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)$,\1,p' \
-e 's,^.*[	]\([0-9][0-9]*\.[0-9][0-9]*\)[ 	].*$,\1,p' \
-e 's,^.*[	]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)[ 	].*$,\1,p' \
-e 's,^.*[ 	]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)[ 	].*$,\1,p'`


- Håvard