Skip to content

Commit fc544e6

Browse files
committed
better bash style
1 parent 2578555 commit fc544e6

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Note: It might feel more intuitive to provide dependencies as an argument to `k
6363
References
6464
============
6565

66-
The initial version of `kscript` was kindly contributed by Oscar Gonzales.
66+
The initial version of `kscript` was kindly contributed by Oscar Gonzalez.
6767

6868
`kscript` is inspired by [kotlin-script](https://github.com/andrewoma/kotlin-script) which is another great way to do scripting in Kotlin. `kotlin-script` has more options compared to `kscript`, but the latter is conceptually cleaner (no code wrapping) and more simplistic.
6969

kscript

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/bin/bash
22

33
### auto-install expandcp.kts into same dir as kscript for automatic dependency resolution if not yet in PATH
4-
if [ -z "$(which expandcp.kts 2> /dev/null)" ]; then
4+
if ! which expandcp.kts &> /dev/null; then
55
installDir=$(dirname $(which kscript))
66
curl -s https://raw.githubusercontent.com/holgerbrandl/kscript/master/expandcp.kts > ${installDir}/expandcp.kts
77
chmod u+x ${installDir}/expandcp.kts
88
fi
99

10-
dependencies=$(grep -F "//DEPS" $1 | head -n1 | cut -f2- -d' ' | tr ',' ' ' | tr ';' ' ' )
10+
dependencies=$(grep -F "//DEPS" $1 | head -n1 | cut -f2- -d' ' | tr ',;')
1111
#dependencies=" org.docopt:docopt:0.6.0-SNAPSHOT log4j:log4j:1.2.14 "
1212

1313
if [ -n "$dependencies" ]; then
@@ -26,8 +26,7 @@ shift
2626
## work around missing md5sum on mac
2727
if [ "${OSTYPE//[0-9.]/}" == "darwin" ]; then md5sum(){ md5 -r $1; }; fi
2828

29-
scriptCheckSum=$(md5sum ${scriptFile} | awk '{ print $1 }')
30-
scriptCheckSum=${scriptCheckSum:0:6}
29+
scriptCheckSum=$(md5sum $scriptFile | cut -c1-6)
3130

3231
jarDir=$(dirname ${scriptFile}) # see https://github.com/holgerbrandl/kscript/issues/5
3332
jarFile=${jarDir}/.$(basename ${scriptFile} .kts).${scriptCheckSum}.jar

0 commit comments

Comments
 (0)