summaryrefslogtreecommitdiffstats
path: root/scripts/patchfns.in
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2003-02-18 20:50:58 +0000
committerAndreas Gruenbacher <agruen@suse.de>2003-02-18 20:50:58 +0000
commitd631bf76adcd02c3a783ecbec5f221cbb3dd4b98 (patch)
treea108bc0b2e25c4b0d5d097125d922ce1f16dd491 /scripts/patchfns.in
parenta1744e6e43b6ad2a6fac1a80e46011a97b9c6c42 (diff)
downloadquilt-d631bf76adcd02c3a783ecbec5f221cbb3dd4b98.tar.gz
Add bash versions of basename and dirname
Diffstat (limited to 'scripts/patchfns.in')
-rw-r--r--scripts/patchfns.in24
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()
{