diff --git a/Makefile b/Makefile
index 2602d6dc513a564d9648cf313c1da5f7e278e57d..ba8110f7666934669abf254ba2be1df2e6fe2b4e 100644
--- a/Makefile
+++ b/Makefile
@@ -622,7 +622,7 @@ oldmodcheck:
 	fi
 
 badshell:
-ifneq ($(findstring ~,$(DESTDIR)),)
+ifneq ($(filter ~%,$(DESTDIR)),)
 	@echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
 	@echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
 	@exit 1