Skip to content

Instantly share code, notes, and snippets.

@harsh183
Created January 20, 2020 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harsh183/ae7eee28cdc277b4a6d25fe4ed674539 to your computer and use it in GitHub Desktop.
Save harsh183/ae7eee28cdc277b4a6d25fe4ed674539 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -ex
kotlinc $1 -d $1.jar
java -jar $1.jar
@harsh183
Copy link
Author

harsh183 commented Jan 20, 2020

The output:

> ./kotlin_run.sh hello.kt
+ kotlinc hello.kt -d hello.kt.jar
hello.kt:6:17: error: expecting an element
    for(i in 1..) {
                ^
> ./kotlin_run.sh hello.kt
+ kotlinc hello.kt -d hello.kt.jar
+ java -jar hello.kt.jar
hello world
hello world

If the printing is too verbose change the set -ex to set -e and you'll get.

> ./kotlin_run.sh hello.kt
hello world
hello world
hello world
> ./kotlin_run.sh hello.kt
hello.kt:6:17: error: expecting an element
    for(i in 1..) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment