From 49118c191205c572ab152f3855684dea1b79777d Mon Sep 17 00:00:00 2001 From: Eugene Susla Date: Wed, 21 Feb 2018 23:01:50 -0800 Subject: [PATCH] Fixed space-containing argument propagation https://github.com/holgerbrandl/kscript/issues/98 --- kscript | 2 +- src/main/kotlin/kscript/app/Kscript.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kscript b/kscript index e2bcec94..088c7590 100755 --- a/kscript +++ b/kscript @@ -25,4 +25,4 @@ jarPath=$(dirname $abs_kscript_path)/kscript.jar if [[ $(uname) == CYGWIN* ]]; then jarPath=$(cygpath -w ${jarPath}); fi ## run it using command substitution to have just the user process once kscript is done -exec $(kotlin -classpath ${jarPath} kscript.app.KscriptKt "$@") +eval "exec $(kotlin -classpath ${jarPath} kscript.app.KscriptKt "$@")" diff --git a/src/main/kotlin/kscript/app/Kscript.kt b/src/main/kotlin/kscript/app/Kscript.kt index 21b45098..f549015b 100644 --- a/src/main/kotlin/kscript/app/Kscript.kt +++ b/src/main/kotlin/kscript/app/Kscript.kt @@ -237,8 +237,8 @@ fun main(args: Array) { } - // print the final command to be run by exec - val joinedUserArgs = userArgs.joinToString(" ") + // print the final command to be run by eval+exec + val joinedUserArgs = userArgs.map { "\"${it.replace("\"", "\\\"")}\"" }.joinToString(" ") //if requested try to package the into a standalone binary if (docopt.getBoolean("package")) {