On 02-06-05 15:43:45 CEST, Rich Salz wrote: > Richard Levitte via RT wrote: > >Can I assume that sed exists and works properly? dirname can be > >coded like this: > > > echo $$i | sed -e 's|[^/]*$||' -e 's|/$||' > > "dirname foo" returns "." which the above doesn't catch. > I can only think of the following short shell script > #! /bin/sh > for I > do > case "$I" in > */* ) echo "$I" | sed -e 's@\(.*\)/.*@\1@' ;; > *) echo "." > esac > done
i remember on my SVR3 machine dirname(1) was a shell script: -r-xr-xr-x 1 sys bin 93 Oct 11 1985 /bin/dirname* expr \ ${1-.}'/' : '\(/\)[^/]*/$' \ \| ${1-.}'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \ \| . the solaris 1 dirname is: #! /bin/sh # # @(#)dirname.sh 1.5 89/03/22 SMI; from S5R2 1.2 # PATH=/bin:/usr/bin expr \ ${1-.}'/' : '\(/\)[^/]*//*$' \ \| ${1-.}'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \ \| . i.e. the same with attribution. unlike sed expr usually is a sh built-in. rj ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]