diff --git a/finddeps.in b/finddeps.in
index 0d596348ad2522d69698f20bc40d5c3b1857171a..ec8cde4f05fc6b52686ce433c0266a2393a05dae 100644
--- a/finddeps.in
+++ b/finddeps.in
@@ -4,7 +4,6 @@
 #
 
 match=$1
-tld=$(pwd)
 
 if [[ -z $match ]]; then
 	echo 'usage: finddeps <depname>'
@@ -16,10 +15,9 @@ if [[ -z $match ]]; then
 fi
 
 for d in "$(find . -type d)"; do
-	cd "$d"
-	if [[ -f PKGBUILD ]]; then
+	if [[ -f "$d/PKGBUILD" ]]; then
 		unset pkgname depends makedepends
-		. PKGBUILD
+		. "$d/PKGBUILD"
 		for dep in "${depends[@]}"; do
 			# lose the version comparator, if any
 			depname=${dep%%[<>=]*}
@@ -36,5 +34,4 @@ for d in "$(find . -type d)"; do
 			[[ $depname = $match ]] && echo "$d (optdepends)"
 		done
 	fi
-	cd "$tld"
 done