[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reimplementing AS_BASENAME
From: |
Ralf Wildenhues |
Subject: |
Re: Reimplementing AS_BASENAME |
Date: |
Fri, 10 Oct 2008 06:32:03 +0200 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
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?
Cheers,
Ralf
Re: [PATCH] more cleanup before adding shell functions, Paul Eggert, 2008/10/09