mirror of https://github.com/sbt/sbt.git
Make bootstrap safe for arguments including spaces (#882)
This commit is contained in:
parent
13582d6ee6
commit
c5b43d8d35
|
|
@ -69,32 +69,35 @@ object Bootstrap extends CaseApp[BootstrapOptions] {
|
|||
private def createJarBootstrapWithPreamble(javaOpts: Seq[String], output: File, content: Array[Byte]): Unit = {
|
||||
|
||||
val argsPartitioner =
|
||||
"""|sys_args=""
|
||||
|app_args=""
|
||||
|i=1; while [ "$i" -le $# ]; do
|
||||
| eval arg=\${$i}
|
||||
| case $arg in
|
||||
| -J-*)
|
||||
| sys_args="$sys_args ${arg#-J}"
|
||||
| ;;
|
||||
| *)
|
||||
| app_args="$app_args $arg"
|
||||
| ;;
|
||||
| esac
|
||||
| i=$((i + 1))
|
||||
|done
|
||||
"""|nargs=$#
|
||||
|
|
||||
|i=1; while [ "$i" -le $nargs ]; do
|
||||
| eval arg=\${$i}
|
||||
| case $arg in
|
||||
| -J-*) set -- "$@" "${arg#-J}" ;;
|
||||
| esac
|
||||
| i=$((i + 1))
|
||||
| done
|
||||
|
|
||||
|set -- "$@" -jar "$0"
|
||||
|
|
||||
|i=1; while [ "$i" -le $nargs ]; do
|
||||
| eval arg=\${$i}
|
||||
| case $arg in
|
||||
| -J-*) ;;
|
||||
| *) set -- "$@" "$arg" ;;
|
||||
| esac
|
||||
| i=$((i + 1))
|
||||
| done
|
||||
|
|
||||
|shift "$nargs"
|
||||
|""".stripMargin
|
||||
|
||||
val javaCmd = Seq("java") ++
|
||||
javaOpts
|
||||
// escaping possibly a bit loose :-|
|
||||
.map(s => "'" + s.replace("'", "\\'") + "'") ++
|
||||
Seq(
|
||||
"$sys_args",
|
||||
"-jar",
|
||||
"\"$0\"",
|
||||
"$app_args"
|
||||
)
|
||||
Seq("\"$@\"")
|
||||
|
||||
val shellPreamble = Seq(
|
||||
"#!/usr/bin/env sh",
|
||||
|
|
|
|||
|
|
@ -141,6 +141,11 @@ testBootstrap() {
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$(./cs-echo-launcher "-n foo")" != "-n foo" ]; then
|
||||
echo "Error: unexpected output from bootstrapped echo command (generated by proguarded launcher)." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# run via the launcher rather than via the sbt-pack scripts, because the latter interprets -Dfoo=baz itself
|
||||
# rather than passing it to coursier since https://github.com/xerial/sbt-pack/pull/118
|
||||
./coursier-test bootstrap -o cs-props -D other=thing -J -Dfoo=baz io.get-coursier:props:1.0.2
|
||||
|
|
|
|||
Loading…
Reference in New Issue