#!/usr/bin/env etsh : : etsh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;; : : " @(#)$Id: 21b6f72e583f941c0fe2de91391888284f94d6b2 $ " : : " 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 $# != 1 if { exit } pusage $0 string if X$1 = X if { exit } echo . echo $1 | sed 's,/*$,,' | egrep '^$|/' >/dev/null if $? != 0 if { exit } echo . echo $1 | sed 's,/*$,, ; s,[^/]*$,, ; s,/*$,,' | grep '^$' >/dev/null if $? = 0 if { exit } echo / echo $1 | sed 's,/*$,, ; s,[^/]*$,, ; s,/*$,,'