--- makepkg.orig	2006-08-31 10:07:32.000000000 +0200
+++ makepkg	2006-08-31 10:07:50.000000000 +0200
@@ -452,14 +452,15 @@
 msg "Retrieving Sources..."
 mkdir -p src
 cd $startdir/src
-for netfile in ${source[@]}; do
-	file=`strip_url $netfile`
-	if [ -f ../$file ]; then
+for netfile in "${source[@]}"; do
+	test "$netfile" == " " && continue
+	file=`strip_url "$netfile"`
+	if [ -f "../$file" ]; then
 		msg "    Found $file in build dir"
-		cp ../$file .
-	elif [ -f /var/cache/pacman/src/$file ]; then
+		cp "../$file" .
+	elif [ -f "/var/cache/pacman/src/$file" ]; then
 		msg "    Using local copy of $file"
-		cp /var/cache/pacman/src/$file .
+		cp "/var/cache/pacman/src/$file" .
 	else
 		# check for a download utility
 		if [ -z "$FTPAGENT" ]; then
@@ -473,23 +474,23 @@
 			msg "Aborting..."
 			exit 1
 		fi
-		proto=`echo $netfile | sed 's|://.*||'`
+		proto=`echo "$netfile" | sed 's|://.*||'`
 		if [ "$proto" != "ftp" -a "$proto" != "http" -a "$proto" != "https" ]; then
 			error "$netfile was not found in the build directory and is not a proper URL."
 			msg "Aborting..."
 			exit 1
 		fi
 		msg "    Downloading $file"
-		$FTPAGENT $netfile 2>&1
-		if [ ! -f $file ]; then
+		$FTPAGENT "$netfile" 2>&1
+		if [ ! -f "$file" ]; then
 			error "Failed to download $file"
 			msg "Aborting..."
 			exit 1
 		fi
 		if [ "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
-			mkdir -p /var/cache/pacman/src && cp $file /var/cache/pacman/src
+			mkdir -p /var/cache/pacman/src && cp "$file" /var/cache/pacman/src
 		else
-			cp $file ..
+			cp "$file" ..
 		fi
 	fi
 done
@@ -507,8 +508,8 @@
 			msg "Validating source files with MD5sums"
 			errors=0
 			idx=0
-			for netfile in ${source[@]}; do
-				file=`strip_url $netfile`
+			for netfile in "${source[@]}"; do
+				file=`strip_url "$netfile"`
 				echo -n "    $file ... " >&2
 				echo "${md5sums[$idx]}  $file" | md5sum -c - >/dev/null 2>&1
 				if [ $? -ne 0 ]; then
@@ -529,28 +530,28 @@
 		fi
 		# extract sources
 		msg "Extracting Sources..."
-		for netfile in ${source[@]}; do
+		for netfile in "${source[@]}"; do
 			unziphack=0
-			file=`strip_url $netfile`
+			file=`strip_url "$netfile"`
 			unset cmd
-			case $file in
+			case "$file" in
 				*.tar.gz|*.tar.Z|*.tgz)
-				cmd="tar --use-compress-program=gzip -xf $file" ;;
+				cmd="tar --use-compress-program=gzip -xf" ;;
 				*.tar.bz2|*.tbz2)
-				cmd="tar --use-compress-program=bzip2 -xf $file" ;;
+				cmd="tar --use-compress-program=bzip2 -xf" ;;
 				*.tar)
-				cmd="tar -xf $file" ;;
+				cmd="tar -xf" ;;
 				*.zip)
 				unziphack=1
-				cmd="unzip -qqo $file" ;;
+				cmd="unzip -qqo" ;;
 				*.gz)
-				cmd="gunzip $file" ;;
+				cmd="gunzip" ;;
 				*.bz2)
-				cmd="bunzip2 $file" ;;
+				cmd="bunzip2" ;;
 			esac
 			if [ "$cmd" != "" ]; then
-				msg "    $cmd"
-				$cmd
+				msg "    $cmd \"$file\""
+				$cmd "$file"
 				if [ $? -ne 0 ]; then
 					# unzip will return a 1 as a warning, it is not an error
 					if [ "$unziphack" != "1" -o $? -ne 1 ]; then
@@ -573,9 +574,9 @@
 	ct=0
 	newline=0
 	numsrc=${#source[@]}
-	for netfile in ${source[@]}; do
-		file=`strip_url $netfile`
-		sum=`md5sum $file | cut -d' ' -f 1`
+	for netfile in "${source[@]}"; do
+		file=`strip_url "$netfile"`
+		sum=`md5sum "$file" | cut -d' ' -f 1`
 		if [ $ct -eq 0 ]; then
 			echo -n "md5sums=("
 		else
