diff --git a/test/go.sh b/test/go.sh
index 3f57aaa..d2563d4 100755
--- a/test/go.sh
+++ b/test/go.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-DIR=`readlink -f $0 | xargs dirname`
+DIR=`cd $(dirname "$0"); pwd`
 QBE=$DIR/../src/qbe
 
 TMP=/tmp/qbe.zzzz
diff --git a/tools/abifuzz.sh b/tools/abifuzz.sh
index 5945082..ef1f26a 100755
--- a/tools/abifuzz.sh
+++ b/tools/abifuzz.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 OCAMLC=${OCAMLC:-/usr/bin/ocamlc}
-DIR=`readlink -f $0 | xargs dirname`
+DIR=`cd $(dirname "$0"); pwd`
 QBE=$DIR/../src/qbe
 
 failure() {