diff --git a/m4/fp_settings.m4 b/m4/fp_settings.m4
index 719a991d2718f1ea96e8c5bb0f81d120c7ac0e09..26b42d6c603262ceb0038764b62c0f3e3726bb3b 100644
--- a/m4/fp_settings.m4
+++ b/m4/fp_settings.m4
@@ -44,7 +44,7 @@ dnl ghc-toolchain.
 AC_DEFUN([SUBST_TOOLDIR],
 [
     dnl and Note [How we configure the bundled windows toolchain]
-    $1=`echo "$$1" | sed 's%'"$mingw_prefix"'%'"$mingw_install_prefix"'%g'`
+set -- "$(echo "$$1" | sed 's%'"$mingw_prefix"'%'"$mingw_install_prefix"'%g')"
 ])
 
 # FP_SETTINGS