-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #21242: Add REPL flag to quit after evaluating init script #22636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1a9ba3a
Add REPL flag to quit after evaluating init script
noti0na1 28c877f
Remove repl bin; rename flag
noti0na1 e8b1d1e
Fix arguments
noti0na1 7c4a701
Rename setting name
noti0na1 fbd34ec
Update compiler/test/dotty/tools/scripting/BashExitCodeTests.scala
noti0na1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >& /dev/null && pwd)/.." | ||
. $ROOT/bin/commonQ | ||
|
||
java -Dscala.usejavacp=true -cp $cp dotty.tools.repl.Main -usejavacp "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
noti0na1 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/usr/bin/env bash | ||
|
||
#set -o nounset ; set -o errexit | ||
|
||
# Try to autodetect real location of the script | ||
if [ -z "${PROG_HOME-}" ] ; then | ||
## resolve links - $0 may be a link to PROG_HOME | ||
PRG="$0" | ||
|
||
# need this for relative symlinks | ||
while [ -h "$PRG" ] ; do | ||
ls=`ls -ld "$PRG"` | ||
link=`expr "$ls" : '.*-> \(.*\)$'` | ||
if expr "$link" : '/.*' > /dev/null; then | ||
PRG="$link" | ||
else | ||
PRG="`dirname "$PRG"`/$link" | ||
fi | ||
done | ||
|
||
saveddir=`pwd` | ||
|
||
PROG_HOME=`dirname "$PRG"`/.. | ||
|
||
# make it fully qualified | ||
PROG_HOME=`cd "$PROG_HOME" && pwd` | ||
|
||
cd "$saveddir" | ||
fi | ||
|
||
source "$PROG_HOME/libexec/common" | ||
default_java_opts="-Xmx768m -Xms768m" | ||
withCompiler=true | ||
|
||
CompilerMain=dotty.tools.dotc.Main | ||
DecompilerMain=dotty.tools.dotc.decompiler.Main | ||
ReplMain=dotty.tools.repl.Main | ||
ScriptingMain=dotty.tools.scripting.Main | ||
JVM_CP_ARGS="$PROG_HOME/lib/scaladoc.jar" | ||
|
||
PROG_NAME=$CompilerMain | ||
|
||
addJava () { | ||
java_args+=("'$1'") | ||
} | ||
addScala () { | ||
scala_args+=("'$1'") | ||
} | ||
addResidual () { | ||
residual_args+=("'$1'") | ||
} | ||
addScrip() { | ||
script_args+=("'$1'") | ||
} | ||
|
||
#for A in "$@" ; do echo "A[$A]" ; done ; exit 2 | ||
|
||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
--) shift; for arg; do addResidual "$arg"; done; set -- ;; | ||
-v|-verbose) verbose=true && addScala "-verbose" && shift ;; | ||
-q|-quiet) quiet=true && shift ;; | ||
|
||
-colors) colors=true && shift ;; | ||
-no-colors) unset colors && shift ;; | ||
# break out -D and -J options and add them to java_args so | ||
# they reach the JVM in time to do some good. The -D options | ||
# will be available as system properties. | ||
-D*) addJava "$1" && shift ;; | ||
-J*) addJava "${1:2}" && shift ;; | ||
*) addResidual "$1" | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
eval "\"$JAVACMD\"" \ | ||
${JAVA_OPTS:-$default_java_opts} \ | ||
"${java_args[@]}" \ | ||
-classpath "${JVM_CP_ARGS}" \ | ||
-Dscala.expandjavacp=true \ | ||
-Dscala.usejavacp=true \ | ||
"dotty.tools.repl.Main" \ | ||
"${scala_args[@]}" \ | ||
"${residual_args[@]}" \ | ||
"${scripting_string-}" | ||
scala_exit_status=$? | ||
onExit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
@echo off | ||
setlocal enabledelayedexpansion | ||
|
||
@rem ######################################################################### | ||
@rem ## Environment setup | ||
|
||
set _EXITCODE=0 | ||
|
||
for %%f in ("%~dp0.") do ( | ||
set "_PROG_HOME=%%~dpf" | ||
@rem get rid of the trailing slash | ||
set "_PROG_HOME=!_PROG_HOME:~0,-1!" | ||
) | ||
call "%_PROG_HOME%\libexec\common.bat" | ||
if not %_EXITCODE%==0 goto end | ||
|
||
set _DEFAULT_JAVA_OPTS=-Xmx768m -Xms768m | ||
|
||
call :args %* | ||
|
||
@rem ######################################################################### | ||
@rem ## Main | ||
|
||
if defined JAVA_OPTS ( set _JAVA_OPTS=%JAVA_OPTS% | ||
) else ( set _JAVA_OPTS=%_DEFAULT_JAVA_OPTS% | ||
) | ||
|
||
@rem we need to escape % in the java command path, for some reason this doesnt work in common.bat | ||
set "_JAVACMD=!_JAVACMD:%%=%%%%!" | ||
|
||
call "%_JAVACMD%" %_JAVA_OPTS% %_JAVA_DEBUG% %_JAVA_ARGS% ^ | ||
-classpath "%_LIB_DIR%\scaladoc.jar" ^ | ||
-Dscala.expandjavacp=true ^ | ||
-Dscala.usejavacp=true ^ | ||
dotty.tools.repl.Main %_SCALA_ARGS% %_RESIDUAL_ARGS% | ||
if not %ERRORLEVEL%==0 ( | ||
@rem echo Error: Scaladoc execution failed 1>&2 | ||
set _EXITCODE=1 | ||
goto end | ||
) | ||
goto end | ||
|
||
@rem ######################################################################### | ||
@rem ## Subroutines | ||
|
||
:args | ||
set _JAVA_DEBUG= | ||
set _HELP= | ||
set _VERBOSE= | ||
set _QUIET= | ||
set _COLORS= | ||
set _SCALA_ARGS= | ||
set _JAVA_ARGS= | ||
set _RESIDUAL_ARGS= | ||
|
||
:args_loop | ||
if "%~1"=="" goto args_done | ||
set "__ARG=%~1" | ||
if "%__ARG%"=="--" ( | ||
@rem for arg; do addResidual "$arg"; done; set -- ;; | ||
) else if "%__ARG%"=="-h" ( | ||
set _HELP=true | ||
call :addScala "-help" | ||
) else if "%__ARG%"=="-help" ( | ||
set _HELP=true | ||
call :addScala "-help" | ||
) else if "%__ARG%"=="-v" ( | ||
set _VERBOSE=true | ||
call :addScala "-verbose" | ||
) else if "%__ARG%"=="-verbose" ( | ||
set _VERBOSE=true | ||
call :addScala "-verbose" | ||
) else if "%__ARG%"=="-debug" ( set "_JAVA_DEBUG=%_DEBUG_STR%" | ||
) else if "%__ARG%"=="-q" ( set _QUIET=true | ||
) else if "%__ARG%"=="-quiet" ( set _QUIET=true | ||
) else if "%__ARG%"=="-colors" ( set _COLORS=true | ||
) else if "%__ARG%"=="-no-colors" ( set _COLORS= | ||
) else if "%__ARG:~0,2%"=="-D" ( call :addJava "%__ARG%" | ||
) else if "%__ARG:~0,2%"=="-J" ( call :addJava "%__ARG:~2%" | ||
) else ( | ||
if defined _IN_SCRIPTING_ARGS ( call :addScripting "%__ARG%" | ||
) else ( call :addResidual "%__ARG%" | ||
) | ||
) | ||
shift | ||
goto args_loop | ||
:args_done | ||
goto :eof | ||
|
||
@rem output parameter: _SCALA_ARGS | ||
:addScala | ||
set _SCALA_ARGS=%_SCALA_ARGS% %~1 | ||
goto :eof | ||
|
||
@rem output parameter: _JAVA_ARGS | ||
:addJava | ||
set _JAVA_ARGS=%_JAVA_ARGS% %~1 | ||
goto :eof | ||
|
||
@rem output parameter: _RESIDUAL_ARGS | ||
:addResidual | ||
set _RESIDUAL_ARGS=%_RESIDUAL_ARGS% %~1 | ||
goto :eof | ||
|
||
@rem ######################################################################### | ||
@rem ## Cleanups | ||
|
||
:end | ||
exit /b %_EXITCODE% | ||
endlocal |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.