Skip to content

Commit c568fbd

Browse files
Quote every string in script
1 parent 1f97c77 commit c568fbd

File tree

3 files changed

+36
-35
lines changed

3 files changed

+36
-35
lines changed

bin/common

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ ERROR_LOG=error.log
4040
trap onTerminate SIGTERM
4141

4242
onTerminate() {
43-
if [ -f $ERROR_LOG ]; then
44-
cat $ERROR_LOG
45-
rm -f $ERROR_LOG
43+
if [ -f "$ERROR_LOG" ]; then
44+
cat "$ERROR_LOG"
45+
rm -f "$ERROR_LOG"
4646
fi
4747
exit 1 # $? is lost from subprocess in command substitution.
4848
}
@@ -52,7 +52,7 @@ function build_jar {
5252
# build_jar package path/to/jar/dir ['/some/sed/command']
5353
#
5454
# Last arg is optional
55-
cd $DOTTY_ROOT >& /dev/null
55+
cd "$DOTTY_ROOT" >& /dev/null
5656
local build_output=$(sbt "$1" || (echo "failed to run: sbt $1" >> $ERROR_LOG; kill -SIGTERM $$))
5757
local jar=$(echo $build_output | sed -n 's/.*Packaging //g; s/ \.\.\..*//g; /^\/.*/p')
5858

@@ -68,14 +68,14 @@ function build_jar {
6868

6969
cd - >& /dev/null
7070

71-
echo $jar
71+
echo "$jar"
7272
}
7373

7474
function update_packages {
75-
echo "$INTERFACES_JAR" > $DOTTY_ROOT/.packages
76-
echo "$MAIN_JAR" >> $DOTTY_ROOT/.packages
77-
echo "$DOTTY_LIB_JAR" >> $DOTTY_ROOT/.packages
78-
echo "$TEST_JAR" >> $DOTTY_ROOT/.packages
75+
echo "$INTERFACES_JAR" > "$DOTTY_ROOT/.packages"
76+
echo "$MAIN_JAR" >> "$DOTTY_ROOT/.packages"
77+
echo "$DOTTY_LIB_JAR" >> "$DOTTY_ROOT/.packages"
78+
echo "$TEST_JAR" >> "$DOTTY_ROOT/.packages"
7979
}
8080

8181
function build_all {
@@ -124,17 +124,17 @@ function check_jar {
124124
local new_files="$(find "$DOTTY_ROOT/$3" \( -iname "*.scala" -o -iname "*.java" \) -newer "$2")"
125125
if [ ! -z "$new_files" ]; then
126126
printf "New files detected in $1, rebuilding..."
127-
rm $2
127+
rm "$2"
128128
eval "$4"
129129
printf "done\n"
130130
update_packages
131131
fi
132132
}
133133

134-
check_jar "dotty-interfaces" $INTERFACES_JAR "interfaces/src" 'INTERFACES_JAR=$(build_jar dotty-interfaces/package interfaces/target)'
135-
check_jar "dotty-compiler" $MAIN_JAR "compiler/src" 'MAIN_JAR=$(build_jar dotty-compiler/package compiler/target/scala-$SCALA_BINARY_VERSION)'
136-
check_jar "dotty-library" $DOTTY_LIB_JAR "library/src" 'DOTTY_LIB_JAR=$(build_jar dotty-library/package library/target/scala-$SCALA_BINARY_VERSION)'
137-
check_jar "dotty-tests" $TEST_JAR "compiler/test" 'TEST_JAR=$(build_jar dotty-compiler/test:package compiler/target/scala-$SCALA_BINARY_VERSION /dotty.*-tests\.jar/p)'
134+
check_jar "dotty-interfaces" "$INTERFACES_JAR" "interfaces/src" 'INTERFACES_JAR=$(build_jar dotty-interfaces/package interfaces/target)'
135+
check_jar "dotty-compiler" "$MAIN_JAR" "compiler/src" 'MAIN_JAR=$(build_jar dotty-compiler/package compiler/target/scala-$SCALA_BINARY_VERSION)'
136+
check_jar "dotty-library" "$DOTTY_LIB_JAR" "library/src" 'DOTTY_LIB_JAR=$(build_jar dotty-library/package library/target/scala-$SCALA_BINARY_VERSION)'
137+
check_jar "dotty-tests" "$TEST_JAR" "compiler/test" 'TEST_JAR=$(build_jar dotty-compiler/test:package compiler/target/scala-$SCALA_BINARY_VERSION /dotty.*-tests\.jar/p)'
138138

139139
# Autodetecting the scala-library location, in case it wasn't provided by an environment variable
140140
if [ "$SCALA_LIBRARY_JAR" == "" ]; then

bin/dotc

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
2+
23
# This script is used for running compiler standalone(outside of sbt)
34
# it's based on miniboxing script and paulp's launcher script
45

@@ -10,10 +11,10 @@ fi
1011
DOTTY_ROOT="$(dirname "$DOTTY_ROOT")"
1112
DOTTY_ROOT="$( cd "$DOTTY_ROOT" >& /dev/null && pwd )/.." # absolute
1213

13-
source $DOTTY_ROOT/bin/common
14+
source "$DOTTY_ROOT/bin/common"
1415

1516
# dotc.build test places bootstrapped jar here
16-
DOTTY_JAR=$DOTTY_ROOT/dotty.jar
17+
DOTTY_JAR="$DOTTY_ROOT/dotty.jar"
1718

1819
CompilerMain=dotty.tools.dotc.Main
1920
FromTasty=dotty.tools.dotc.FromTasty
@@ -29,13 +30,13 @@ then
2930
fi
3031

3132
ifdebug () {
32-
[[ -n $debug ]] && eval "$@"
33+
[[ -n "$debug" ]] && eval "$@"
3334
}
3435
echoErr () {
3536
echo >&2 "$@"
3637
}
3738
dlog () {
38-
[[ -n $debug ]] && echoErr "$@"
39+
[[ -n "$debug" ]] && echoErr "$@"
3940
}
4041

4142
die() {
@@ -52,7 +53,7 @@ echoErr ""
5253
execCommand () {
5354
ifdebug echoArgs "$@"
5455
ignore="$(cat "$HOME/.scala_ignore_crashes" 2>/dev/null)"
55-
if [[ $ignore == "true" ]]; then
56+
if [[ "$ignore" == "true" ]]; then
5657
"$@" 2>&1 | scala-crash-filter
5758
else
5859
$@
@@ -62,11 +63,11 @@ execCommand () {
6263
# restore stty settings (echo in particular)
6364
restoreSttySettings () {
6465
dlog "" && dlog "[restore stty] $saved_stty"
65-
stty $saved_stty && saved_stty=""
66+
stty "$saved_stty" && saved_stty=""
6667
}
6768

6869
onExit () {
69-
[[ -n $saved_stty ]] && restoreSttySettings
70+
[[ -n "$saved_stty" ]] && restoreSttySettings
7071
exit $scala_exit_status
7172
}
7273

@@ -103,7 +104,7 @@ addResidual () {
103104
}
104105

105106
onExit() {
106-
[[ -n $saved_stty ]] && restoreSttySettings
107+
[[ -n "$saved_stty" ]] && restoreSttySettings
107108
exit $scala_exit_status
108109
}
109110

@@ -113,8 +114,8 @@ trap onExit INT
113114
# If using the boot classpath, also pass an empty classpath
114115
# to java to suppress "." from materializing.
115116
classpathArgs () {
116-
if [[ "true" == $bootstrapped ]]; then
117-
check_jar "dotty-bootstrapped" $DOTTY_JAR "target" 'build_jar "test:runMain dotc.build" target' &> /dev/null
117+
if [[ "true" == "$bootstrapped" ]]; then
118+
check_jar "dotty-bootstrapped" "$DOTTY_JAR" "target" 'build_jar "test:runMain dotc.build" target' &> /dev/null
118119
toolchain="$DOTTY_JAR:$DOTTY_LIB_JAR:$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$SBT_INTERFACE_JAR"
119120
else
120121
toolchain="$SCALA_LIBRARY_JAR:$DOTTY_LIB_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$SBT_INTERFACE_JAR"
@@ -129,7 +130,7 @@ classpathArgs () {
129130
format=windows
130131
fi
131132

132-
if [[ -n $bootcp ]]; then
133+
if [[ -n "$bootcp" ]]; then
133134
boot_classpath="$(cygpath --path --$format "$toolchain:$bcpJars")"
134135
classpath="$(cygpath --path --$format "$cpJars")"
135136
cpArgs="-Xbootclasspath/a:$boot_classpath -classpath $classpath"
@@ -138,7 +139,7 @@ classpathArgs () {
138139
cpArgs="-classpath $classpath"
139140
fi
140141
else
141-
if [[ -n $bootcp ]]; then
142+
if [[ -n "$bootcp" ]]; then
142143
cpArgs="-Xbootclasspath/a:$toolchain:$bcpJars -classpath $cpJars"
143144
else
144145
cpArgs="-classpath $toolchain:$cpJars"
@@ -159,7 +160,7 @@ require_arg () {
159160
}
160161

161162

162-
main_class=$CompilerMain
163+
main_class="$CompilerMain"
163164

164165
while [[ $# -gt 0 ]]; do
165166
case "$1" in
@@ -172,11 +173,11 @@ case "$1" in
172173

173174
# Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
174175
-Oshort) addJava "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" && shift ;;
175-
-repl) main_class=$ReplMain && shift ;;
176-
-tasty) main_class=$FromTasty && shift ;;
177-
-compile) main_class=$CompilerMain && shift ;;
178-
-run) main_class=$ReplMain && shift ;;
179-
-fsc) main_class=$FscMain && shift ;;
176+
-repl) main_class="$ReplMain" && shift ;;
177+
-tasty) main_class="$FromTasty" && shift ;;
178+
-compile) main_class="$CompilerMain" && shift ;;
179+
-run) main_class="$ReplMain" && shift ;;
180+
-fsc) main_class="$FscMain" && shift ;;
180181
-bootcp) bootcp=true && shift ;;
181182
-nobootcp) unset bootcp && shift ;;
182183
-colors) colors=true && shift ;;

bin/dotr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ DOTTY_ROOT="$(dirname "$DOTTY_ROOT")"
99
DOTTY_ROOT="$( cd "$DOTTY_ROOT" >& /dev/null && pwd )/.." # absolute
1010

1111
# Load common functions and variables
12-
source $DOTTY_ROOT/bin/common
12+
source "$DOTTY_ROOT"/bin/common
1313

1414
CLASS_PATH="-classpath .:$DOTTY_LIB_JAR:.:$SCALA_LIBRARY_JAR"
1515

1616
function runMain {
1717
local jbin=$(which "java")
1818

1919
if [ ! -z "$JAVA_BIN" ]; then
20-
jbin=$JAVA_BIN
20+
jbin="$JAVA_BIN"
2121
fi
2222

2323
if [ "$jbin" == "" ]; then
@@ -28,7 +28,7 @@ function runMain {
2828
fi
2929
}
3030

31-
first_arg=$1
31+
first_arg="$1"
3232

3333
if [ -z "$1" ]; then
3434
echo "Starting dotty REPL..."

0 commit comments

Comments
 (0)