@@ -19,7 +19,7 @@ import javax.xml.bind.DatatypeConverter
1919 * @author Holger Brandl
2020 */
2121
22- val KSCRIPT_VERSION = " 2.0.0"
22+ const val KSCRIPT_VERSION = " 2.0.0"
2323
2424val USAGE = """
2525kscript - Enhanced scripting support for Kotlin on *nix-based systems.
@@ -106,7 +106,7 @@ fun main(args: Array<String>) {
106106 val classpath = resolveDependencies(dependencies)
107107
108108 // Extract kotlin arguments
109- val kotlin_opts = scriptText.
109+ val kotlinOpts = scriptText.
110110 filter { it.startsWith(" //KOTLIN_OPTS " ) }.
111111 flatMap { it.split(" " ).drop(0 ) }.
112112 joinToString(" " )
@@ -115,9 +115,9 @@ fun main(args: Array<String>) {
115115 // Optionally enter interactive mode
116116 if (docopt.getBoolean(" interactive" )) {
117117 System .err.println (" Creating REPL from ${scriptFile} " )
118- System .err.println (" kotlinc ${kotlin_opts } -classpath '${classpath} '" )
118+ System .err.println (" kotlinc ${kotlinOpts } -classpath '${classpath} '" )
119119
120- println (" kotlinc ${kotlin_opts } -classpath ${classpath} " )
120+ println (" kotlinc ${kotlinOpts } -classpath ${classpath} " )
121121 }
122122
123123 val scriptFileExt = scriptFile.extension
@@ -160,6 +160,7 @@ fun main(args: Array<String>) {
160160
161161
162162 // infer KOTLIN_HOME if not set
163+ @Suppress(" LocalVariableName" )
163164 val KOTLIN_HOME = System .getenv(" KOTLIN_HOME" ) ? : guessKotlinHome()
164165 errorIf(KOTLIN_HOME == null ) {
165166 " KOTLIN_HOME is not set and could not be inferred from context"
@@ -215,7 +216,7 @@ fun main(args: Array<String>) {
215216 // map { "\""+it+"\"" }.
216217 joinToString(" " )
217218
218- println (" kotlin ${kotlin_opts } -classpath ${jarFile}${CP_SEPARATOR_CHAR }${KOTLIN_HOME }${File .separatorChar} lib${File .separatorChar} kotlin-script-runtime.jar${CP_SEPARATOR_CHAR }${classpath} ${execClassName} ${shiftedArgs} " )
219+ println (" kotlin ${kotlinOpts } -classpath ${jarFile}${CP_SEPARATOR_CHAR }${KOTLIN_HOME }${File .separatorChar} lib${File .separatorChar} kotlin-script-runtime.jar${CP_SEPARATOR_CHAR }${classpath} ${execClassName} ${shiftedArgs} " )
219220}
220221
221222/* * Determine the latest version by checking github repo and print info if newer version is availabe. */
@@ -231,7 +232,7 @@ fun versionCheck() {
231232
232233 fun padVersion (version : String ) = java.lang.String .format(" %03d%03d%03d" , * version.split(" ." ).map { Integer .valueOf(it) }.toTypedArray())
233234
234- if (padVersion(latestVersion).compareTo( padVersion(KSCRIPT_VERSION )) > 0 ) {
235+ if (padVersion(latestVersion) > padVersion(KSCRIPT_VERSION )) {
235236 info(""" \nA new version (v${latestVersion} ) of kscript is available. Use 'kscript --self-update' to update your local kscript installation""" )
236237 }
237238}
@@ -245,7 +246,7 @@ private fun guessKotlinHome(): String? {
245246}
246247
247248fun prepareScript (scriptResource : String ): File {
248- var scriptFile: File ? = null
249+ var scriptFile: File ?
249250
250251 // map script argument to script file
251252 scriptFile = with (File (scriptResource)) {
@@ -333,7 +334,7 @@ fun fetchFromURL(scriptURL: String): File? {
333334fun md5 (byteProvider : () -> ByteArray ): String {
334335 // from https://stackoverflow.com/questions/304268/getting-a-files-md5-checksum-in-java
335336 val md = MessageDigest .getInstance(" MD5" )
336- md.update(byteProvider());
337+ md.update(byteProvider())
337338
338339 val digestInHex = DatatypeConverter .printHexBinary(md.digest()).toLowerCase()
339340
0 commit comments