autoconf-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] more cleanup before adding shell functions


From: Paolo Bonzini
Subject: Re: [PATCH] more cleanup before adding shell functions
Date: Thu, 09 Oct 2008 22:24:00 +0200
User-agent: Thunderbird 2.0.0.17 (Macintosh/20080914)

>> Since AS_BASENAME is undocumented, and since it is most useful in variable 
>> assignments, perhaps it is time to redefine it as follows (untested)
>>
>> # AS_BASENAME(var, name, [ext])
>> # -----------------------------
>> # Compute the basename of NAME, with trailing EXT removed, and assign
>> # the result to the shell variable VAR.
> 
> I like this idea.  It's been on my mental to-do list for quite some
> time, and it's an obvious improvement.  We can't simply use "${1##*/}",
> though, as that mishandles the basenames of strings like "a/b/" and "///".

So that would rule out no-fork AS_BASENAME, unless we can rely also on
extglob and ${1%%*(/)}.  Or unless a case statement and a rarely
executed while loop would be faster than a fork:

  case $x in
    */) while :; do
           x=${x%/}
           case $x in */) ;; *) break ;;
        esac; done
  esac

I honestly have no idea if this is the case.

Paolo




reply via email to

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