diff --git a/makechrootpkg.in b/makechrootpkg.in
index ba893bf51a4eac44ccabc2b0be0e6ec2f4eed582..b172bdf4c5e34b4834f876bc6d1d37d7be17669e 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -243,12 +243,12 @@ cp PKGBUILD "$copydir/build/"
 	done
 
 	# Find all changelog and install files, even inside functions
-	for i in changelog install; do
-		sed -n "s/^[[:space:]]*$i=//p" PKGBUILD | while IFS= read -r file; do
+	for i in 'changelog' 'install'; do
+		while read -r file; do
 			# evaluate any bash variables used
-			eval file="$file"
+			eval file=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$file")\"
 			[[ -f $file ]] && cp "$file" "$copydir/build/"
-		done
+		done < <(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD)
 	done
 )