From 67c9b8be811e53890964a3e7cf05c3b533ec8ec8 Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Fri, 26 May 2006 10:18:47 +0000 Subject: - quilt/scripts/patchfns.in: Fix bugs in basename() and dirname(). --- quilt.changes | 5 +++++ quilt/scripts/patchfns.in | 31 +++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/quilt.changes b/quilt.changes index c4ca730..cffc7b8 100644 --- a/quilt.changes +++ b/quilt.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri May 26 12:16:18 CEST 2006 - agruen@suse.de + +- quilt/scripts/patchfns.in: Fix bugs in basename() and dirname(). + ------------------------------------------------------------------- Thu May 25 09:12:08 CEST 2006 - khali@linux-fr.org diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in index 64c2a11..fa591c1 100644 --- a/quilt/scripts/patchfns.in +++ b/quilt/scripts/patchfns.in @@ -87,19 +87,38 @@ quote_re() basename() { - local path="${1//\/\//}" - path="${path%%/}" + local path=$1 + while [ "${path:(-1)}" = "/" ] + do + path=${path%/} + done echo "${path##*/}" } dirname() { - local path="${1//\/\//}" - path="${path%%/}" + local path=$1 + while [ "${path:(-1)}" = "/" ] + do + path=${path%/} + done local basename="${path##*/}" path="${path:0:${#path}-${#basename}}" - [ x"$path" != x"/" ] && path="${path%/}" - echo "${path:-.}" + while [ "${path:(-1)}" = "/" ] + do + path=${path%/} + done + if [ -n "$path" ] + then + echo "$path" + else + if [ ${1:0:1} = "/" ] + then + echo "/" + else + echo "." + fi + fi } patch_file_name() -- cgit