#!/usr/bin/env osh : : osh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;; : : " @(#)$Id: d432e91035f2ca963b99eeb147cde6b88a7cbd38 $ " : : " The author of this file, J.A. Neitzel , " : " hereby grants it to the public domain. " : : : " Print the directory portion of a pathname. " : : " usage: dirname string " : : " Check for correct usage. " : >>$0'' <'' ; : >>$1'' <'' killer $0 dirname if $n != 1 if { exit } pusage $0 string if X$1 = X if { exit } echo . echo $1 | sed 's,/*$,,' | egrep '^$|/' >/dev/null if $s != 0 if { exit } echo . echo $1 | sed 's,/*$,, ; s,[^/]*$,, ; s,/*$,,' | grep '^$' >/dev/null if $s = 0 if { exit } echo / echo $1 | sed 's,/*$,, ; s,[^/]*$,, ; s,/*$,,'