> rsalz>                */* ) echo "$I" | sed -e 's@\(.*\)/.*@\1@' ;;
> 
> Why such a complicated sed?  's@/[^/]*$@@' is perfecty sufficient, and
> a little bit more efficient :-).

Because it makes the implementation of "basename" pretty obvious :)

As for efficiency :) here's an implementation that uses all shell 
builtins ...

#! /bin/sh
export IFS
case "$1" in
*/*)
     OLDIFS="$IFS" ; IFS=/ ; set $1 ; IFS="$OLDIFS"
     p=''
     while : ;  do
         case "$2" in
         "") break ;;
         esac
         case "$p" in
         "") p="$1" ;;
         *) p="$p/$1" ;;
         esac
         shift
     done
     echo $p
     ;;
*)
     echo .
     ;;
esac

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to