[pacman-dev] [PATCH] makepkg: use basename instead of a sed command

Cedric Staniewski cedric at gmx.ca
Sat Oct 17 13:41:45 EDT 2009


The basename command is easier to understand than a sed command and it
is even slightly faster than sed.

Signed-off-by: Cedric Staniewski <cedric at gmx.ca>
---
or if you prefer bashisms, see next patch

 scripts/makepkg.sh.in |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 24fddf6..62d0923 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -190,7 +190,7 @@ get_filename() {
 	# if a filename is specified, use it
 	local filename=$(echo $1 | sed 's|::.*||')
 	# if it is just an URL, we only keep the last component
-	echo "$filename" | sed 's|^.*://.*/||g'
+	basename "$filename"
 }
 
 # extract the URL from a source entry
@@ -321,7 +321,7 @@ download_file() {
 	# destination file
 	local file=$3
 	# temporary download file, default to last component of the URL
-	local dlfile=$(echo "$url" | sed 's|^.*://.*/||g')
+	local dlfile=$(basename "$url")
 
 	# replace %o by the temporary dlfile if it exists
 	if echo "$dlcmd" | grep -q "%o" ; then
-- 
1.6.5



More information about the pacman-dev mailing list