Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

General cleanups for shell wrappers

- Use appropriate quoting to avoid whitespace within arguments,
  environment variables from being string-split.
- Better compatibility with baseline POSIX sh.
- Improve editor syntax highlighter compatibility.
- Readability cleanups (avoid workarounds for bugs fixed
  pre-POSIX-standardization).
  • Loading branch information...
commit 5c8e1d4ece4f660fdd5b62dc5861c8dc76b7b27c 1 parent 60139a3
@charles-dyfis-net charles-dyfis-net authored David Nolen committed
View
10 bin/cljsc
@@ -9,13 +9,13 @@ fi
CLJSC_CP=''
for next in lib/*: src/clj: src/cljs: test/cljs; do
- CLJSC_CP=$CLJSC_CP$CLOJURESCRIPT_HOME'/'$next
+ CLJSC_CP="${CLJSC_CP}${CLOJURESCRIPT_HOME}/${next}"
done
-if test $# -eq 0
+if test "$#" -eq 0
then
- echo "Usage: cljsc <file-or-dir>"
- echo " cljsc <file-or-dir> {:optimizations :advanced}"
+ echo 'Usage: cljsc <file-or-dir>'
+ echo ' cljsc <file-or-dir> "{:optimizations :advanced}"'
else
- java -server -cp $CLJSC_CP clojure.main $CLOJURESCRIPT_HOME/bin/cljsc.clj $*
+ java -server -cp "$CLJSC_CP" clojure.main "$CLOJURESCRIPT_HOME/bin/cljsc.clj" "$@"
fi
View
18 script/benchmark
@@ -1,28 +1,30 @@
+#!/bin/sh
+
rm -rf out
mkdir -p out
#bin/cljsc benchmark > out/core-benchmark.js
-bin/cljsc benchmark {:optimizations :advanced} > out/core-advanced-benchmark.js
+bin/cljsc benchmark "{:optimizations :advanced}" >out/core-advanced-benchmark.js
-if [ "$V8_HOME" == "" ]; then
+if [ "$V8_HOME" = "" ]; then
echo "V8_HOME not set, skipping V8 benchmarks"
else
echo "Benchmarking with V8"
- ${V8_HOME}/d8 out/core-advanced-benchmark.js
+ "${V8_HOME}/d8" out/core-advanced-benchmark.js
# TODO: figure out path problem when not in advanced mode
- # ${V8_HOME}/d8 out/core-benchmark.js
+ # "${V8_HOME}/d8" out/core-benchmark.js
fi
-if [ "$SPIDERMONKEY_HOME" == "" ]; then
+if [ "$SPIDERMONKEY_HOME" = "" ]; then
echo "SPIDERMONKEY_HOME not set, skipping SpiderMonkey benchmarks"
else
echo "Benchmarking with SpiderMonkey"
- ${SPIDERMONKEY_HOME}/js -m -n -a -f out/core-advanced-benchmark.js
+ "${SPIDERMONKEY_HOME}/js" -m -n -a -f out/core-advanced-benchmark.js
fi
-if [ "$JSC_HOME" == "" ]; then
+if [ "$JSC_HOME" = "" ]; then
echo "JSC_HOME not set, skipping JavaScriptCore benchmarks"
else
echo "Benchmarking with JavaScriptCore"
- ${JSC_HOME}/jsc -f out/core-advanced-benchmark.js
+ "${JSC_HOME}/jsc" -f out/core-advanced-benchmark.js
fi
View
14 script/bootstrap
@@ -17,18 +17,14 @@ rm clojure-1.4.0.zip
echo "Fetching Google Closure library..."
mkdir -p closure/library
cd closure/library
-if [ "x$1" = "x--closure-library-head" ] ; then
+if [ "$1" = "--closure-library-head" ] ; then
echo "Building against HEAD of Google Closure library..."
# Check if svn present
type svn >/dev/null 2>&1 || { echo >&2 "Need svn command to checkout HEAD of Google Closure library. Aborting."; exit 1; }
# Existing checkout?
- set +e
- svn info --non-interactive >/dev/null 2>&1
- declare -i r=$?
- set -e
- if [ 0 -eq $r ] ; then
+ if svn info --non-interactive >/dev/null 2>&1; then
echo "Updating Google Closure library from HEAD..."
svn update -q --non-interactive
else
@@ -39,10 +35,10 @@ if [ "x$1" = "x--closure-library-head" ] ; then
else
echo "Fetching Google Closure library..."
f=closure-library-20111110-r1376.zip
- curl -O -s http://closure-library.googlecode.com/files/$f
- unzip -qu $f
+ curl -O -s "http://closure-library.googlecode.com/files/$f"
+ unzip -qu "$f"
echo "Cleaning up Google Closure library archive..."
- rm $f
+ rm "$f"
fi
cd ..
View
2  script/build
@@ -47,7 +47,7 @@ sed -e s/CLOJURESCRIPT_VERSION/0.0-$REVISION/ < "$POM_TEMPLATE" > "$POM_FILE"
mvn install:install-file -Dfile="$JAR_FILE" -DpomFile="$POM_FILE"
# For Hudson server
-if [ "$HUDSON" == "true" ]; then
+if [ "$HUDSON" = "true" ]; then
echo "Creating tag $TAG"
git tag -f "$TAG"
git push origin "$TAG"
View
4 script/repl
@@ -6,8 +6,8 @@ fi
CLJSC_CP=''
for next in lib/*: src/clj: src/cljs: test/cljs; do
- CLJSC_CP=$CLJSC_CP$CLOJURESCRIPT_HOME'/'$next
+ CLJSC_CP="${CLJSC_CP}${CLOJURESCRIPT_HOME}/${next}"
done
-java -server -cp $CLJSC_CP clojure.main
+java -server -cp "$CLJSC_CP" clojure.main
View
4 script/repljs
@@ -6,10 +6,10 @@ fi
CLJSC_CP=''
for next in lib/*: src/clj: src/cljs: test/cljs; do
- CLJSC_CP=$CLJSC_CP$CLOJURESCRIPT_HOME'/'$next
+ CLJSC_CP="${CLJSC_CP}${CLOJURESCRIPT_HOME}/${next}"
done
-java -server -cp $CLJSC_CP clojure.main -e \
+java -server -cp "$CLJSC_CP" clojure.main -e \
"(require '[cljs.repl :as repl])
(require '[cljs.repl.rhino :as rhino])
(repl/repl (rhino/repl-env) :warn-on-undeclared true)"
View
18 script/test
@@ -1,23 +1,25 @@
+#!/bin/sh
+
rm -rf out
mkdir -p out
possible=3
ran=0
-#bin/cljsc test > out/core-test.js
-bin/cljsc test {:optimizations :advanced} > out/core-advanced-test.js
+#bin/cljsc test >out/core-test.js
+bin/cljsc test "{:optimizations :advanced}" >out/core-advanced-test.js
-if [ "$V8_HOME" == "" ]; then
+if [ "$V8_HOME" = "" ]; then
echo "V8_HOME not set, skipping V8 tests"
else
echo "Testing with V8"
- ${V8_HOME}/d8 out/core-advanced-test.js
+ "${V8_HOME}/d8" out/core-advanced-test.js
# TODO: figure out path problem when not in advanced mode
- # ${V8_HOME}/d8 out/core-test.js
+ # "${V8_HOME}/d8" out/core-test.js
ran=$[ran+1]
fi
-if [ "$SPIDERMONKEY_HOME" == "" ]; then
+if [ "$SPIDERMONKEY_HOME" = "" ]; then
echo "SPIDERMONKEY_HOME not set, skipping SpiderMonkey tests"
else
echo "Testing with SpiderMonkey"
@@ -25,11 +27,11 @@ else
ran=$[ran+1]
fi
-if [ "$JSC_HOME" == "" ]; then
+if [ "$JSC_HOME" = "" ]; then
echo "JSC_HOME not set, skipping JavaScriptCore tests"
else
echo "Testing with JavaScriptCore"
- ${JSC_HOME}/jsc -f out/core-advanced-test.js
+ "${JSC_HOME}/jsc" -f out/core-advanced-test.js
ran=$[ran+1]
fi
View
10 script/test-compile
@@ -3,7 +3,7 @@
echo "Generating sample javascript"
mkdir compilation
-cat <<EOF > compilation/test.js
+cat >compilation/test.js <<EOF
function create_alert(msg) {
alert(msg);
}
@@ -13,9 +13,9 @@ echo "Testing compilation"
cd compilation
for file in *
do
- if [ -f $file ] ; then
- name=${file%\.*}
- java -jar ../closure/compiler/compiler.jar --js $file --js_output_file $name-compiled.js
+ if [ -f "$file" ] ; then
+ name=${file%.*}
+ java -jar ../closure/compiler/compiler.jar --js "$file" --js_output_file "$name-compiled.js"
fi
done
cd ..
@@ -27,4 +27,4 @@ echo "\nOptimized:"
cat compilation/test-compiled.js
echo "\nCleaning up"
-rm -rf compilation
+rm -rf compilation
Please sign in to comment.
Something went wrong with that request. Please try again.