diff --git a/get_modules.sh b/get_modules.sh
index 82c9354294c44e092573b1d11c4054dcc6a85ff8..d853a4679305d44b9d1a1d23a3dd24b3cb6ce7f5 100755
--- a/get_modules.sh
+++ b/get_modules.sh
@@ -27,11 +27,11 @@ else
     for dir in "$MODULEBASE"/*
     do
       # Exclude following directories
-      if [ $(basename $dir) = "all" ]; then
+      if [ "$(basename "$dir")" == "all" ]; then
         continue
       fi
       # In case that it's directory
-      if [ -d $dir ]; then
+      if [ -d "$dir" ]; then
         if [ -z $MODULEPATH ]; then
           MODULEPATH=$dir
         else