diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2003-02-18 20:50:58 +0000 |
---|---|---|
committer | Andreas Gruenbacher <agruen@suse.de> | 2003-02-18 20:50:58 +0000 |
commit | d631bf76adcd02c3a783ecbec5f221cbb3dd4b98 (patch) | |
tree | a108bc0b2e25c4b0d5d097125d922ce1f16dd491 | |
parent | a1744e6e43b6ad2a6fac1a80e46011a97b9c6c42 (diff) | |
download | quilt-d631bf76adcd02c3a783ecbec5f221cbb3dd4b98.tar.gz |
Add bash versions of basename and dirname
-rw-r--r-- | scripts/patchfns.in | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/scripts/patchfns.in b/scripts/patchfns.in index d9862fb..1148c97 100644 --- a/scripts/patchfns.in +++ b/scripts/patchfns.in @@ -41,16 +41,20 @@ quote_re() echo "$1" | sed -e 's:\([][?{(|)}^$/.+*\\]\):\\\1:g' } -#basename() -#{ -# local path=${1%/} -# echo "${path/*\/}" -#} - -#dirname() -#{ -# local path=${1%/} -#} +basename() +{ + local path="${1%%/}" + echo "${path##*/}" +} + +dirname() +{ + local path="${1%%/}" + local basename="${path##*/}" + path="${path:0:${#path}-${#basename}}" + [ x"$path" != x"/" ] && path="${path%/}" + echo "${path:-.}" +} patch_file_name() { |