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")) {