diff --git a/bin/install_module b/bin/install_module
index d5b9a8b491e3c8834bb4144ee8b9cac6e0732709..a0bbb6f3f30e8a7775716597a251c47dabf0acdf 100755
--- a/bin/install_module
+++ b/bin/install_module
@@ -11,7 +11,7 @@ DIRS_TO_MAKE=
 DIR="$TO"
 while :
 do
-  DIR=`echo $DIR | sed -e 's@/[^/]*$@@'`
+  DIR=`echo $DIR | sed -e 's@/[^/]*$@@' -e 's@/$@@'`
 
   case "$DIR" in
     *.pmod)