[Top][All Lists]
[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="$@"
- Re: [PATCH] Use expr where possible, Peter O'Gorman, 2005/06/15
- Re: [PATCH] Use expr where possible, Paul Eggert, 2005/06/15
- Re: [PATCH] Use expr where possible, Peter O'Gorman, 2005/06/15
- Re: [PATCH] Use expr where possible, Peter O'Gorman, 2005/06/15
- Re: [PATCH] Use expr where possible,
Akim Demaille <=
- Re: [PATCH] Use expr where possible, Paul Eggert, 2005/06/16
- Re: [PATCH] Use expr where possible, Akim Demaille, 2005/06/16
- Re: [PATCH] Use expr where possible, Peter O'Gorman, 2005/06/16
- Re: [PATCH] Use expr where possible, Ralf Wildenhues, 2005/06/19
- Re: [PATCH] Use expr where possible, Stepan Kasal, 2005/06/22