[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reimplementing AS_BASENAME
From: |
Paolo Bonzini |
Subject: |
Re: Reimplementing AS_BASENAME |
Date: |
Fri, 10 Oct 2008 09:15:01 +0200 |
User-agent: |
Thunderbird 2.0.0.17 (Macintosh/20080914) |
Ralf Wildenhues wrote:
> Hi Eric,
>
> * Eric Blake wrote on Thu, Oct 09, 2008 at 11:10:53PM CEST:
>> as_func_basename ()
>> {
>> test "x$1" = "x--" && shift
>> case $1 in
>> / | // ) result=$1 ;; # root dir corner cases
>> *[!/]*/ ) # trailing slash, but not root
>> result=${1##*[!/]} # compute the suffix of slashes
>> result=${1%"$result"} # strip the trailing slashes
>> result=${result##*/} ;; # compute the basename
>> */ ) result=/ ;; # collapse alternate spelling of root
>> * ) result=${result##*/} ;; # no trailing slash
>> esac
>> # add code here for stripping $2, if wanted
>> }
>
> What if \ also serves as directory separator? Are you going to rule
> that out for the new AS_BASENAME?
I don't think so. A replacement ${1/'\'/'/'} does not work in dash, but
I'm sure you can find a portable version.
Paolo
Re: [PATCH] more cleanup before adding shell functions, Paul Eggert, 2008/10/09