Permalink
Browse files

quote path variables in shell script

  • Loading branch information...
1 parent 8d43071 commit 3a00b6c432714ff3b350805a63ef5011e678c19f @ctSkennerton committed Feb 13, 2015
Showing with 8 additions and 8 deletions.
  1. +8 −8 minced
View
16 minced
@@ -4,11 +4,11 @@
# readlink is different between BSD and Linux,
# therefore this loop recreates `readlink -f`
-ORIG_DIR=$(pwd $(dirname $0))
+ORIG_DIR=$(pwd $(dirname "$0"))
-cd $(dirname $0)
+cd $(dirname "$0")
-TARGET_FILE=$(basename $0)
+TARGET_FILE=$(basename "$0")
# Iterate down a (possible) chain of symlinks
i=0
while [ -L "$TARGET_FILE" ]
@@ -18,16 +18,16 @@ do
echo "Link cycle detected in path, more than 1000 links traversed, exiting" >&2
exit 1
fi
- TARGET_FILE=$(readlink $TARGET_FILE)
- cd $(dirname $TARGET_FILE)
- TARGET_FILE=$(basename $TARGET_FILE)
+ TARGET_FILE=$(readlink "$TARGET_FILE")
+ cd $(dirname "$TARGET_FILE")
+ TARGET_FILE=$(basename "$TARGET_FILE")
i=$((i + 1))
done
# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
PHYS_DIR=`pwd -P`
-cd $ORIG_DIR
+cd "$ORIG_DIR"
-java -jar $PHYS_DIR/minced.jar "$@"
+java -jar "$PHYS_DIR"/minced.jar "$@"

0 comments on commit 3a00b6c

Please sign in to comment.