autoconf-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] Use expr where possible


From: Akim Demaille
Subject: Re: [PATCH] Use expr where possible
Date: Thu, 16 Jun 2005 10:10:26 +0200
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

>>> "Peter" == Peter O'Gorman <address@hidden> writes:

 > Peter O'Gorman wrote:
 >> Paul Eggert wrote:
 >> 
 >>> "Peter O'Gorman" <address@hidden> writes:
 >>> 
 >>> 
>>> % expr "Xpowerpc-apple-darwin8.1.0" : 'X[^--]*-[^--]*-\(.*\)'
 >>> 
 >>> 
 >>> 
 >>> How about the following instead?  I'd rather use a simpler regexp if
 >>> it works.  Can you please verify that this works on the broken
 >>> implementation?  Thanks.
 >>> 
 >>> $ expr 'Xpowerpc-apple-darwin8.1.0' : '.*-\(.*\)'
 >>> darwin8.1.0
 >>> $ expr 'Xpowerpc-apple-darwin8.1.0' : '.*-\(.*\)-.*'
 >>> apple
 >>> $ expr 'Xpowerpc-apple-darwin8.1.0' : 'X\(.*\)-.*-'
 >>> powerpc
 >>> 
 >> Yes, this works also. Thank you.

 > To reply to myself, Bill Fenner just mentioned on irc that this will
 > give a bad result for "i686-pc-linux-gnu" he instead suggests using
 > [.-.] as in:
 > expr "Xpowerpc-apple-darwin8.1.0" : 'X[^.-.]*-[^.-.]*-\(.*\)'
 > expr "Xpowerpc-apple-darwin8.1.0" : 'X[^.-.]*-\([^.-.]*\)-.*'
 > expr "Xpowerpc-apple-darwin8.1.0" : 'X\([^.-.]*\)-.*-.*'


 > irc paste, sorry
 > 22:29 < fenestro> although if you want all 3 parts, using set and echo | sed 
 > is
 >                    probably less processes (if expr isn't builtin)
 > 22:30 < fenestro> set `echo foo-bar-baz-boo | sed -e
 >                    's/\([^-]*\)-\([^-]*\)-\(.*\)/$1 $2 $3/'
 > 22:30 < fenestro> a=$1
 > 22:30 < fenestro> b=$2
 > 22:30 < fenestro> c=$3

 > Or simply reverting and using echo | sed... (I prefer this solution)

How about using IFS?

IFS=-
host=powerpc-apple-darwin8.1.0
set X $host; shift
a=$1; shift
b=$1; shift
c="$@"





reply via email to

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