on master help sign in
Add OpenBSD support to shebang script

* use sha1 instead of sha1sum on OpenBSD * enable using runidris regardless of the script's extension * mark runidris scripts executable

commitf9194a644d39ff0e350aa4748beaabec550220cc authorScott Bonds <scott@ggr.com> dateThu 3 Aug 2017, 08:08 (9 years ago) parentb9b32e5
2 files changed+20−6
scripts/runidris+9−2 scripts/runidris-node+11−4
scripts/runidrismode 100644 → 100755+9−2
@@ -9,10 +9,17 @@ if [ ! -d $RUNIDRIS_DIR ]; then
99 mkdir $RUNIDRIS_DIR
1010 chmod 700 $RUNIDRIS_DIR
1111fi
12−TEMP_NAME="runidris-`sha1sum $1 | cut -c1-40`"
12+
13+OS=`uname -s`
14+case $OS in
15+ OpenBSD ) TEMP_NAME="runidris-`sha1 -q $1`" ;;
16+ * ) TEMP_NAME="runidris-`sha1sum $1 | cut -c1-40`" ;;
17+esac
18+
1319FP="$RUNIDRIS_DIR/$TEMP_NAME"
20+cp "$1" "$FP.idr" # idris won't compile the script unless it ends in .idr
1421if [ ! -e $FP ]; then
15− "${IDRIS:-idris}" $1 --ibcsubdir "$RUNIDRIS_DIR" -i "." -o $FP
22+ "${IDRIS:-idris}" "$FP.idr" --ibcsubdir "$RUNIDRIS_DIR" -i "." -o $FP
1623fi
1724shift
1825"$FP" "$@"
scripts/runidris-nodemode 100644 → 100755+11−4
@@ -9,10 +9,17 @@ if [ ! -d $RUNIDRIS_DIR ]; then
99 mkdir $RUNIDRIS_DIR
1010 chmod 700 $RUNIDRIS_DIR
1111fi
12−TEMP_NAME="runidris-`sha1sum $1 | cut -c1-40`.js"
12+
13+OS=`uname -s`
14+case $OS in
15+ OpenBSD ) TEMP_NAME="runidris-`sha1 -q $1`" ;;
16+ * ) TEMP_NAME="runidris-`sha1sum $1 | cut -c1-40`" ;;
17+esac
18+
1319FP="$RUNIDRIS_DIR/$TEMP_NAME"
14−if [ ! -e $FP ]; then
15− "${IDRIS:-idris}" --codegen node --ibcsubdir "$RUNIDRIS_DIR" -i "." $1 -o $FP
20+cp "$1" "$FP.idr" # idris won't compile the script unless it ends in .idr
21+if [ ! -e "$FP.js" ]; then
22+ "${IDRIS:-idris}" --codegen node --ibcsubdir "$RUNIDRIS_DIR" -i "." "$FP.idr" -o "$FP.js"
1623fi
1724shift
18−node "$FP" "$@"
25+node "$FP.js" "$@"