Skip to content

Commit

Permalink
General cleanups for shell wrappers
Browse files Browse the repository at this point in the history
- 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
charles-dyfis-net authored and David Nolen committed Jul 16, 2012
1 parent 60139a3 commit 5c8e1d4
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 40 deletions.
10 changes: 5 additions & 5 deletions bin/cljsc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ fi


CLJSC_CP='' CLJSC_CP=''
for next in lib/*: src/clj: src/cljs: test/cljs; do 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 done


if test $# -eq 0 if test "$#" -eq 0
then then
echo "Usage: cljsc <file-or-dir>" echo 'Usage: cljsc <file-or-dir>'
echo " cljsc <file-or-dir> {:optimizations :advanced}" echo ' cljsc <file-or-dir> "{:optimizations :advanced}"'
else 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 fi
18 changes: 10 additions & 8 deletions script/benchmark
Original file line number Original file line Diff line number Diff line change
@@ -1,28 +1,30 @@
#!/bin/sh

rm -rf out rm -rf out
mkdir -p out mkdir -p out


#bin/cljsc benchmark > out/core-benchmark.js #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" echo "V8_HOME not set, skipping V8 benchmarks"
else else
echo "Benchmarking with V8" 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 # 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 fi


if [ "$SPIDERMONKEY_HOME" == "" ]; then if [ "$SPIDERMONKEY_HOME" = "" ]; then
echo "SPIDERMONKEY_HOME not set, skipping SpiderMonkey benchmarks" echo "SPIDERMONKEY_HOME not set, skipping SpiderMonkey benchmarks"
else else
echo "Benchmarking with SpiderMonkey" 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 fi


if [ "$JSC_HOME" == "" ]; then if [ "$JSC_HOME" = "" ]; then
echo "JSC_HOME not set, skipping JavaScriptCore benchmarks" echo "JSC_HOME not set, skipping JavaScriptCore benchmarks"
else else
echo "Benchmarking with JavaScriptCore" echo "Benchmarking with JavaScriptCore"
${JSC_HOME}/jsc -f out/core-advanced-benchmark.js "${JSC_HOME}/jsc" -f out/core-advanced-benchmark.js
fi fi
14 changes: 5 additions & 9 deletions script/bootstrap
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,18 +17,14 @@ rm clojure-1.4.0.zip
echo "Fetching Google Closure library..." echo "Fetching Google Closure library..."
mkdir -p closure/library mkdir -p closure/library
cd 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..." echo "Building against HEAD of Google Closure library..."


# Check if svn present # 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; } type svn >/dev/null 2>&1 || { echo >&2 "Need svn command to checkout HEAD of Google Closure library. Aborting."; exit 1; }


# Existing checkout? # Existing checkout?
set +e if svn info --non-interactive >/dev/null 2>&1; then
svn info --non-interactive >/dev/null 2>&1
declare -i r=$?
set -e
if [ 0 -eq $r ] ; then
echo "Updating Google Closure library from HEAD..." echo "Updating Google Closure library from HEAD..."
svn update -q --non-interactive svn update -q --non-interactive
else else
Expand All @@ -39,10 +35,10 @@ if [ "x$1" = "x--closure-library-head" ] ; then
else else
echo "Fetching Google Closure library..." echo "Fetching Google Closure library..."
f=closure-library-20111110-r1376.zip f=closure-library-20111110-r1376.zip
curl -O -s http://closure-library.googlecode.com/files/$f curl -O -s "http://closure-library.googlecode.com/files/$f"
unzip -qu $f unzip -qu "$f"
echo "Cleaning up Google Closure library archive..." echo "Cleaning up Google Closure library archive..."
rm $f rm "$f"
fi fi
cd .. cd ..


Expand Down
2 changes: 1 addition & 1 deletion script/build
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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" mvn install:install-file -Dfile="$JAR_FILE" -DpomFile="$POM_FILE"


# For Hudson server # For Hudson server
if [ "$HUDSON" == "true" ]; then if [ "$HUDSON" = "true" ]; then
echo "Creating tag $TAG" echo "Creating tag $TAG"
git tag -f "$TAG" git tag -f "$TAG"
git push origin "$TAG" git push origin "$TAG"
Expand Down
4 changes: 2 additions & 2 deletions script/repl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ fi


CLJSC_CP='' CLJSC_CP=''
for next in lib/*: src/clj: src/cljs: test/cljs; do 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 done


java -server -cp $CLJSC_CP clojure.main java -server -cp "$CLJSC_CP" clojure.main


4 changes: 2 additions & 2 deletions script/repljs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ fi


CLJSC_CP='' CLJSC_CP=''
for next in lib/*: src/clj: src/cljs: test/cljs; do 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 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 :as repl])
(require '[cljs.repl.rhino :as rhino]) (require '[cljs.repl.rhino :as rhino])
(repl/repl (rhino/repl-env) :warn-on-undeclared true)" (repl/repl (rhino/repl-env) :warn-on-undeclared true)"
18 changes: 10 additions & 8 deletions script/test
Original file line number Original file line Diff line number Diff line change
@@ -1,35 +1,37 @@
#!/bin/sh

rm -rf out rm -rf out
mkdir -p out mkdir -p out


possible=3 possible=3
ran=0 ran=0


#bin/cljsc test > out/core-test.js #bin/cljsc test >out/core-test.js
bin/cljsc test {:optimizations :advanced} > out/core-advanced-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" echo "V8_HOME not set, skipping V8 tests"
else else
echo "Testing with V8" 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 # 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] ran=$[ran+1]
fi fi


if [ "$SPIDERMONKEY_HOME" == "" ]; then if [ "$SPIDERMONKEY_HOME" = "" ]; then
echo "SPIDERMONKEY_HOME not set, skipping SpiderMonkey tests" echo "SPIDERMONKEY_HOME not set, skipping SpiderMonkey tests"
else else
echo "Testing with SpiderMonkey" echo "Testing with SpiderMonkey"
${SPIDERMONKEY_HOME}/js -m -n -a -f out/core-advanced-test.js ${SPIDERMONKEY_HOME}/js -m -n -a -f out/core-advanced-test.js
ran=$[ran+1] ran=$[ran+1]
fi fi


if [ "$JSC_HOME" == "" ]; then if [ "$JSC_HOME" = "" ]; then
echo "JSC_HOME not set, skipping JavaScriptCore tests" echo "JSC_HOME not set, skipping JavaScriptCore tests"
else else
echo "Testing with JavaScriptCore" 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] ran=$[ran+1]
fi fi


Expand Down
10 changes: 5 additions & 5 deletions script/test-compile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
echo "Generating sample javascript" echo "Generating sample javascript"
mkdir compilation mkdir compilation


cat <<EOF > compilation/test.js cat >compilation/test.js <<EOF
function create_alert(msg) { function create_alert(msg) {
alert(msg); alert(msg);
} }
Expand All @@ -13,9 +13,9 @@ echo "Testing compilation"
cd compilation cd compilation
for file in * for file in *
do do
if [ -f $file ] ; then if [ -f "$file" ] ; then
name=${file%\.*} name=${file%.*}
java -jar ../closure/compiler/compiler.jar --js $file --js_output_file $name-compiled.js java -jar ../closure/compiler/compiler.jar --js "$file" --js_output_file "$name-compiled.js"
fi fi
done done
cd .. cd ..
Expand All @@ -27,4 +27,4 @@ echo "\nOptimized:"
cat compilation/test-compiled.js cat compilation/test-compiled.js


echo "\nCleaning up" echo "\nCleaning up"
rm -rf compilation rm -rf compilation

0 comments on commit 5c8e1d4

Please sign in to comment.