>> 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