diff --git a/Makefile b/Makefile index ff1cd7a643..6eda0955a2 100644 --- a/Makefile +++ b/Makefile @@ -168,7 +168,7 @@ get_run_prefix = $(strip $(foreach mode,$(call actual_impl,$(1))_MODE, \ # Takes impl and step # Returns the runtest command prefix (with runtest options) for testing the given step -get_runtest_cmd = $(call get_run_prefix,$(1),$(2),$(if $(filter cs fsharp mal tcl vb,$(1)),RAW=1,)) \ +get_runtest_cmd = $(call get_run_prefix,$(1),$(2),$(if $(filter cs fsharp mal perl tcl vb,$(1)),RAW=1)) \ ../../runtest.py $(opt_HARD) $(opt_DEFERRABLE) $(opt_OPTIONAL) $(call $(1)_TEST_OPTS) $(TEST_OPTS) # Takes impl and step diff --git a/examples/clojurewest2014.mal b/examples/clojurewest2014.mal old mode 100755 new mode 100644 diff --git a/examples/presentation.mal b/examples/presentation.mal old mode 100755 new mode 100644 diff --git a/impls/ada.2/run b/impls/ada.2/run index 6efdc3de32..5ffd062744 100755 --- a/impls/ada.2/run +++ b/impls/ada.2/run @@ -1,2 +1,3 @@ #!/bin/sh -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/ada/Dockerfile b/impls/ada/Dockerfile old mode 100755 new mode 100644 diff --git a/impls/ada/run b/impls/ada/run index c66c2b81dc..5ffd062744 100755 --- a/impls/ada/run +++ b/impls/ada/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/awk/run b/impls/awk/run index 9c3061869f..f0a9f48c35 100755 --- a/impls/awk/run +++ b/impls/awk/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec awk -O -f $(dirname $0)/${STEP:-stepA_mal}.awk "${@}" +#!/bin/sh +set -Cefu +exec awk -f ${STEP:-stepA_mal}.awk "$@" diff --git a/impls/bash/run b/impls/bash/run index 05081b9ce6..5ada142c2f 100755 --- a/impls/bash/run +++ b/impls/bash/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec bash $(dirname $0)/${STEP:-stepA_mal}.sh "${@}" +#!/bin/sh +set -Cefu +exec bash ${STEP:-stepA_mal}.sh "$@" diff --git a/impls/bash/step0_repl.sh b/impls/bash/step0_repl.sh old mode 100755 new mode 100644 index 97bce61d17..2d779dd6c8 --- a/impls/bash/step0_repl.sh +++ b/impls/bash/step0_repl.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - READ () { read -u 0 -e -p "user> " r } diff --git a/impls/bash/step1_read_print.sh b/impls/bash/step1_read_print.sh old mode 100755 new mode 100644 index 8011fa6b86..b0eba83196 --- a/impls/bash/step1_read_print.sh +++ b/impls/bash/step1_read_print.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - source $(dirname $0)/reader.sh source $(dirname $0)/printer.sh diff --git a/impls/bash/step2_eval.sh b/impls/bash/step2_eval.sh old mode 100755 new mode 100644 index 54d75885c3..ad0c15a255 --- a/impls/bash/step2_eval.sh +++ b/impls/bash/step2_eval.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - source $(dirname $0)/reader.sh source $(dirname $0)/printer.sh diff --git a/impls/bash/step3_env.sh b/impls/bash/step3_env.sh old mode 100755 new mode 100644 index ba46e54306..f4433c48cb --- a/impls/bash/step3_env.sh +++ b/impls/bash/step3_env.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - source $(dirname $0)/reader.sh source $(dirname $0)/printer.sh source $(dirname $0)/env.sh diff --git a/impls/bash/step4_if_fn_do.sh b/impls/bash/step4_if_fn_do.sh old mode 100755 new mode 100644 index 24b45965fd..129e8959d4 --- a/impls/bash/step4_if_fn_do.sh +++ b/impls/bash/step4_if_fn_do.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - source $(dirname $0)/reader.sh source $(dirname $0)/printer.sh source $(dirname $0)/env.sh diff --git a/impls/bash/step5_tco.sh b/impls/bash/step5_tco.sh old mode 100755 new mode 100644 index 5e30751000..c81b1ea2bf --- a/impls/bash/step5_tco.sh +++ b/impls/bash/step5_tco.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - source $(dirname $0)/reader.sh source $(dirname $0)/printer.sh source $(dirname $0)/env.sh diff --git a/impls/bash/step6_file.sh b/impls/bash/step6_file.sh old mode 100755 new mode 100644 index b87cbc1986..e4d0d9c202 --- a/impls/bash/step6_file.sh +++ b/impls/bash/step6_file.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - source $(dirname $0)/reader.sh source $(dirname $0)/printer.sh source $(dirname $0)/env.sh diff --git a/impls/bash/step7_quote.sh b/impls/bash/step7_quote.sh old mode 100755 new mode 100644 index dc046f9fc2..0f0183e3b3 --- a/impls/bash/step7_quote.sh +++ b/impls/bash/step7_quote.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - source $(dirname $0)/reader.sh source $(dirname $0)/printer.sh source $(dirname $0)/env.sh diff --git a/impls/bash/step8_macros.sh b/impls/bash/step8_macros.sh old mode 100755 new mode 100644 index 64710610e2..d832170e05 --- a/impls/bash/step8_macros.sh +++ b/impls/bash/step8_macros.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - source $(dirname $0)/reader.sh source $(dirname $0)/printer.sh source $(dirname $0)/env.sh diff --git a/impls/bash/step9_try.sh b/impls/bash/step9_try.sh old mode 100755 new mode 100644 index bc6336ac34..7749c1b639 --- a/impls/bash/step9_try.sh +++ b/impls/bash/step9_try.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - source $(dirname $0)/reader.sh source $(dirname $0)/printer.sh source $(dirname $0)/env.sh diff --git a/impls/bash/stepA_mal.sh b/impls/bash/stepA_mal.sh old mode 100755 new mode 100644 index f65b4b1db2..ba81dffd3c --- a/impls/bash/stepA_mal.sh +++ b/impls/bash/stepA_mal.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - source $(dirname $0)/reader.sh source $(dirname $0)/printer.sh source $(dirname $0)/env.sh diff --git a/impls/basic/run b/impls/basic/run index 9b394f8c0b..ccca87d142 100755 --- a/impls/basic/run +++ b/impls/basic/run @@ -1,8 +1,12 @@ -#!/usr/bin/env bash -cd $(dirname $0) -(echo "(def! -*ARGS*- (list $(for a in "${@}"; do echo -n " \"${a}\""; done)))") > .args.mal +#!/bin/sh +set -efu +{ + printf '(def! -*ARGS*- (list' + [ $# = 0 ] || printf ' "%s"' "$@" + echo '))' +} > .args.mal case ${basic_MODE:-cbm} in - cbm) exec cbmbasic ${STEP:-stepA_mal}.bas "${@}" ;; - qbasic) exec ./${STEP:-stepA_mal} "${@}" ;; - *) echo "Invalid basic_MODE: ${basic_MODE}"; exit 2 ;; + cbm) exec cbmbasic ${STEP:-stepA_mal}.bas "$@" ;; + qbasic) exec ./${STEP:-stepA_mal} "$@" ;; + *) echo "Invalid basic_MODE: $basic_MODE"; exit 2 ;; esac diff --git a/impls/basic/step0_repl.in.bas b/impls/basic/step0_repl.in.bas old mode 100755 new mode 100644 diff --git a/impls/basic/step1_read_print.in.bas b/impls/basic/step1_read_print.in.bas old mode 100755 new mode 100644 diff --git a/impls/basic/step2_eval.in.bas b/impls/basic/step2_eval.in.bas old mode 100755 new mode 100644 diff --git a/impls/basic/step3_env.in.bas b/impls/basic/step3_env.in.bas old mode 100755 new mode 100644 diff --git a/impls/basic/step4_if_fn_do.in.bas b/impls/basic/step4_if_fn_do.in.bas old mode 100755 new mode 100644 diff --git a/impls/basic/step5_tco.in.bas b/impls/basic/step5_tco.in.bas old mode 100755 new mode 100644 diff --git a/impls/basic/step6_file.in.bas b/impls/basic/step6_file.in.bas old mode 100755 new mode 100644 diff --git a/impls/basic/step7_quote.in.bas b/impls/basic/step7_quote.in.bas old mode 100755 new mode 100644 diff --git a/impls/basic/step8_macros.in.bas b/impls/basic/step8_macros.in.bas old mode 100755 new mode 100644 diff --git a/impls/basic/step9_try.in.bas b/impls/basic/step9_try.in.bas old mode 100755 new mode 100644 diff --git a/impls/basic/stepA_mal.in.bas b/impls/basic/stepA_mal.in.bas old mode 100755 new mode 100644 diff --git a/impls/bbc-basic/run b/impls/bbc-basic/run index b3e2049a09..8701b18cf7 100755 --- a/impls/bbc-basic/run +++ b/impls/bbc-basic/run @@ -1,3 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh +set -Cefu exec "${BRANDY:-sbrandy}" -size 1024k \ - -path ../bbc-basic -quit $(dirname $0)/${STEP:-stepA_mal}.bas "${@}" + -quit ${STEP:-stepA_mal}.bas "$@" diff --git a/impls/c.2/run b/impls/c.2/run index 6efdc3de32..5ffd062744 100755 --- a/impls/c.2/run +++ b/impls/c.2/run @@ -1,2 +1,3 @@ #!/bin/sh -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/c/run b/impls/c/run index c66c2b81dc..5ffd062744 100755 --- a/impls/c/run +++ b/impls/c/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/chuck/run b/impls/chuck/run index 99137daea7..9375e4d69b 100755 --- a/impls/chuck/run +++ b/impls/chuck/run @@ -1,11 +1,21 @@ -#!/usr/bin/env bash +#!/bin/sh +set -Ceu +step=${STEP:-stepA_mal}.ck + regex_chugin=${REGEX_CHUGIN:-/usr/local/lib/chuck/1.5.2.5/RegEx.chug} -if [[ ! -f "$regex_chugin" ]]; then - echo "Set \$REGEX_CHUGIN to the absolute path of RegEx.chug"; exit 1 +if [ ! -f "$regex_chugin" ]; then + echo 'Set $REGEX_CHUGIN to the absolute path of RegEx.chug' + exit 1 fi -imports=$(grep "^ *// *@import" "$(dirname $0)/${STEP:-stepA_mal}.ck" | awk '{print $3}') -imports=$(for i in ${imports}; do ls $(dirname $0)/${i}; done) -old_IFS="${IFS}"; IFS=$'\a'; export CHUCK_ARGS="${*}"; IFS="${old_IFS}" +# The globs will be expanded in the exec line. +imports=$(sed -n "s|^ *// *@import *||p" $step) + +separator=$(printf '\a') +for x; do + CHUCK_ARGS="${CHUCK_ARGS:+$CHUCK_ARGS$separator}$x" +done +export CHUCK_ARGS -exec chuck --caution-to-the-wind --silent --chugin:"$regex_chugin" ${imports} $(dirname $-1)/${STEP:-stepA_mal}.ck +exec chuck --caution-to-the-wind --silent --chugin:"$regex_chugin" \ + $imports $step diff --git a/impls/clojure/run b/impls/clojure/run index 5fe4d92804..0c188c559a 100755 --- a/impls/clojure/run +++ b/impls/clojure/run @@ -1,8 +1,10 @@ -#!/usr/bin/env bash -export PATH=$PATH:$(dirname $0)/node_modules/.bin +#!/bin/sh +set -Cefu +export PATH="$PATH:node_modules/.bin" STEP=${STEP:-stepA_mal} -if [ "${clojure_MODE}" = "cljs" ]; then - exec lumo -c $(dirname $0)/src -m mal.${STEP//_/-} "${@}" -else - exec java -jar $(dirname $0)/target/${STEP}.jar "${@}" -fi +case ${clojure_MODE:-clj} in + cljs) exec lumo -c src -m mal.$(echo $STEP | tr _ -) "$@" ;; + clj) exec java -jar target/$STEP.jar "$@" ;; +esac +echo "Invalid clojure_MODE: $clojure_MODE" +exit 1 diff --git a/impls/coffee/run b/impls/coffee/run index 84deffb471..58f481b9ec 100755 --- a/impls/coffee/run +++ b/impls/coffee/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec coffee $(dirname $0)/${STEP:-stepA_mal}.coffee "${@}" +#!/bin/sh +set -Cefu +exec coffee ${STEP:-stepA_mal}.coffee "$@" diff --git a/impls/common-lisp/run b/impls/common-lisp/run index c66c2b81dc..5ffd062744 100755 --- a/impls/common-lisp/run +++ b/impls/common-lisp/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/cpp/run b/impls/cpp/run index c66c2b81dc..5ffd062744 100755 --- a/impls/cpp/run +++ b/impls/cpp/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/crystal/run b/impls/crystal/run index a42a7e149d..bf24a176db 100755 --- a/impls/crystal/run +++ b/impls/crystal/run @@ -1,2 +1,3 @@ #!/bin/sh -exec $(dirname $0)/bin/${STEP:-stepA_mal} "${@}" +set -Cefu +exec bin/${STEP:-stepA_mal} "$@" diff --git a/impls/crystal/step0_repl.cr b/impls/crystal/step0_repl.cr old mode 100755 new mode 100644 index a9c67d68f2..b6a1bfba32 --- a/impls/crystal/step0_repl.cr +++ b/impls/crystal/step0_repl.cr @@ -1,5 +1,3 @@ -#! /usr/bin/env crystal run - require "readline" # Note: diff --git a/impls/crystal/step1_read_print.cr b/impls/crystal/step1_read_print.cr old mode 100755 new mode 100644 index 4d7195895e..8c5ddffb9e --- a/impls/crystal/step1_read_print.cr +++ b/impls/crystal/step1_read_print.cr @@ -1,5 +1,3 @@ -#! /usr/bin/env crystal run - require "readline" require "./reader" require "./printer" diff --git a/impls/crystal/step2_eval.cr b/impls/crystal/step2_eval.cr old mode 100755 new mode 100644 index f8713571cd..dd8f2533d1 --- a/impls/crystal/step2_eval.cr +++ b/impls/crystal/step2_eval.cr @@ -1,5 +1,3 @@ -#! /usr/bin/env crystal run - require "readline" require "./reader" require "./printer" diff --git a/impls/crystal/step3_env.cr b/impls/crystal/step3_env.cr old mode 100755 new mode 100644 index a17d79779f..fd77be8e46 --- a/impls/crystal/step3_env.cr +++ b/impls/crystal/step3_env.cr @@ -1,5 +1,3 @@ -#! /usr/bin/env crystal run - require "readline" require "./reader" require "./printer" diff --git a/impls/crystal/step4_if_fn_do.cr b/impls/crystal/step4_if_fn_do.cr old mode 100755 new mode 100644 index fb33c8911d..251629332d --- a/impls/crystal/step4_if_fn_do.cr +++ b/impls/crystal/step4_if_fn_do.cr @@ -1,5 +1,3 @@ -#! /usr/bin/env crystal run - require "readline" require "./reader" require "./printer" diff --git a/impls/crystal/step5_tco.cr b/impls/crystal/step5_tco.cr old mode 100755 new mode 100644 index 508ed0b176..72a9489606 --- a/impls/crystal/step5_tco.cr +++ b/impls/crystal/step5_tco.cr @@ -1,5 +1,3 @@ -#! /usr/bin/env crystal run - require "readline" require "./reader" require "./printer" diff --git a/impls/crystal/step6_file.cr b/impls/crystal/step6_file.cr old mode 100755 new mode 100644 index a7a95e170c..2eff3ba8d0 --- a/impls/crystal/step6_file.cr +++ b/impls/crystal/step6_file.cr @@ -1,5 +1,3 @@ -#! /usr/bin/env crystal run - require "readline" require "./reader" require "./printer" diff --git a/impls/crystal/step7_quote.cr b/impls/crystal/step7_quote.cr old mode 100755 new mode 100644 index b935061fa2..0455d143db --- a/impls/crystal/step7_quote.cr +++ b/impls/crystal/step7_quote.cr @@ -1,5 +1,3 @@ -#! /usr/bin/env crystal run - require "readline" require "./reader" require "./printer" diff --git a/impls/crystal/step8_macros.cr b/impls/crystal/step8_macros.cr old mode 100755 new mode 100644 index 2c7ac4e755..57b6063d82 --- a/impls/crystal/step8_macros.cr +++ b/impls/crystal/step8_macros.cr @@ -1,5 +1,3 @@ -#! /usr/bin/env crystal run - require "readline" require "./reader" require "./printer" diff --git a/impls/crystal/step9_try.cr b/impls/crystal/step9_try.cr old mode 100755 new mode 100644 index 984158b28f..bfc8a70572 --- a/impls/crystal/step9_try.cr +++ b/impls/crystal/step9_try.cr @@ -1,5 +1,3 @@ -#! /usr/bin/env crystal run - require "readline" require "./reader" require "./printer" diff --git a/impls/crystal/stepA_mal.cr b/impls/crystal/stepA_mal.cr old mode 100755 new mode 100644 index 2857c89d13..65fb8e9f8b --- a/impls/crystal/stepA_mal.cr +++ b/impls/crystal/stepA_mal.cr @@ -1,5 +1,3 @@ -#! /usr/bin/env crystal run - require "colorize" require "readline" diff --git a/impls/cs/Makefile b/impls/cs/Makefile index 52529a915b..7c6165b5e0 100644 --- a/impls/cs/Makefile +++ b/impls/cs/Makefile @@ -24,13 +24,13 @@ all: $(patsubst %.cs,%.exe,$(SRCS)) dist: mal.exe mal -mal.exe: $(patsubst %.cs,%.exe,$(word $(words $(SOURCES)),$(SOURCES))) +mal.exe: $(patsubst %.cs,%.exe,$(lastword $(SOURCES))) cp $< $@ # NOTE/WARNING: static linking triggers mono libraries LGPL # distribution requirements. # http://www.mono-project.com/archived/guiderunning_mono_applications/ -mal: $(patsubst %.cs,%.exe,$(word $(words $(SOURCES)),$(SOURCES))) mal.dll +mal: $(patsubst %.cs,%.exe,$(lastword $(SOURCES))) mal.dll mkbundle --static -o $@ $+ --deps mal.dll: $(LIB_SRCS) diff --git a/impls/cs/run b/impls/cs/run index 5c5642646f..8ea6fdbea1 100755 --- a/impls/cs/run +++ b/impls/cs/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec mono $(dirname $0)/${STEP:-stepA_mal}.exe ${RAW:+--raw} "${@}" +#!/bin/sh +set -Cefu +exec mono ${STEP:-stepA_mal}.exe ${RAW:+--raw} "$@" diff --git a/impls/d/run b/impls/d/run index c66c2b81dc..5ffd062744 100755 --- a/impls/d/run +++ b/impls/d/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/dart/run b/impls/dart/run index 6f3ab8bca3..d8320472de 100755 --- a/impls/dart/run +++ b/impls/dart/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec dart --checked $(dirname $0)/${STEP:-stepA_mal}.dart "${@}" +#!/bin/sh +set -Cefu +exec dart --checked ${STEP:-stepA_mal}.dart "$@" diff --git a/impls/elisp/run b/impls/elisp/run index cb0387403c..16aaeb34c5 100755 --- a/impls/elisp/run +++ b/impls/elisp/run @@ -1,3 +1,5 @@ #!/bin/sh -dir=$(dirname $0) -exec emacs -Q --batch -L $dir --eval "(setq text-quoting-style 'straight)" --load $dir/${STEP:-stepA_mal}.elc "${@}" +set -Cefu +exec emacs -Q --batch -L . \ + --eval "(setq text-quoting-style 'straight)" \ + --load ${STEP:-stepA_mal}.elc "$@" diff --git a/impls/elixir/run b/impls/elixir/run index bfd505014b..8c4f3f8eeb 100755 --- a/impls/elixir/run +++ b/impls/elixir/run @@ -1,3 +1,3 @@ -#!/usr/bin/env bash -cd $(dirname $0) -exec mix ${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec mix ${STEP:-stepA_mal} "$@" diff --git a/impls/elm/run b/impls/elm/run index d22e4fbeac..7235b16b18 100755 --- a/impls/elm/run +++ b/impls/elm/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec node $(dirname $0)/bootstrap.js ${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec node bootstrap.js ${STEP:-stepA_mal} "$@" diff --git a/impls/erlang/run b/impls/erlang/run index c66c2b81dc..5ffd062744 100755 --- a/impls/erlang/run +++ b/impls/erlang/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/es6/run b/impls/es6/run index 54e8932d5c..1c8b71b919 100755 --- a/impls/es6/run +++ b/impls/es6/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec node $(dirname $0)/${STEP:-stepA_mal}.mjs "${@}" +#!/bin/sh +set -Cefu +exec node ${STEP:-stepA_mal}.mjs "$@" diff --git a/impls/factor/run b/impls/factor/run index bb6d41f1da..b2e0210719 100755 --- a/impls/factor/run +++ b/impls/factor/run @@ -1,2 +1,4 @@ -#!/usr/bin/env bash -exec factor $(dirname $0)/${STEP:-stepA_mal}/${STEP:-stepA_mal}.factor "${@}" +#!/bin/sh +set -Cefu +step=${STEP:-stepA_mal} +exec factor $step/$step.factor "$@" diff --git a/impls/factor/step0_repl/step0_repl.factor b/impls/factor/step0_repl/step0_repl.factor old mode 100755 new mode 100644 diff --git a/impls/factor/step1_read_print/step1_read_print.factor b/impls/factor/step1_read_print/step1_read_print.factor old mode 100755 new mode 100644 diff --git a/impls/factor/step2_eval/step2_eval.factor b/impls/factor/step2_eval/step2_eval.factor old mode 100755 new mode 100644 diff --git a/impls/factor/step3_env/step3_env.factor b/impls/factor/step3_env/step3_env.factor old mode 100755 new mode 100644 diff --git a/impls/factor/step4_if_fn_do/step4_if_fn_do.factor b/impls/factor/step4_if_fn_do/step4_if_fn_do.factor old mode 100755 new mode 100644 diff --git a/impls/factor/step5_tco/step5_tco.factor b/impls/factor/step5_tco/step5_tco.factor old mode 100755 new mode 100644 diff --git a/impls/factor/step6_file/step6_file.factor b/impls/factor/step6_file/step6_file.factor old mode 100755 new mode 100644 diff --git a/impls/factor/step7_quote/step7_quote.factor b/impls/factor/step7_quote/step7_quote.factor old mode 100755 new mode 100644 diff --git a/impls/factor/step8_macros/step8_macros.factor b/impls/factor/step8_macros/step8_macros.factor old mode 100755 new mode 100644 diff --git a/impls/factor/step9_try/step9_try.factor b/impls/factor/step9_try/step9_try.factor old mode 100755 new mode 100644 diff --git a/impls/factor/stepA_mal/stepA_mal.factor b/impls/factor/stepA_mal/stepA_mal.factor old mode 100755 new mode 100644 diff --git a/impls/fantom/run b/impls/fantom/run index b0b70cf57b..72c94f7416 100755 --- a/impls/fantom/run +++ b/impls/fantom/run @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +#!/bin/sh +set -Cefu export FAN_ENV=util::PathEnv -export FAN_ENV_PATH="$(dirname $0)" +export FAN_ENV_PATH=. exec fan ${STEP:-stepA_mal} "$@" diff --git a/impls/fennel/run b/impls/fennel/run index 5842447c37..12cbae82c3 100755 --- a/impls/fennel/run +++ b/impls/fennel/run @@ -1,3 +1,3 @@ -#!/usr/bin/env bash - -exec fennel $(dirname $0)/${STEP:-stepA_mal}.fnl "${@}" +#!/bin/sh +set -Cefu +exec fennel ${STEP:-stepA_mal}.fnl "$@" diff --git a/impls/forth/run b/impls/forth/run index 0a45c57df5..3290045678 100755 --- a/impls/forth/run +++ b/impls/forth/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec gforth $(dirname $0)/${STEP:-stepA_mal}.fs "${@}" +#!/bin/sh +set -Cefu +exec gforth ${STEP:-stepA_mal}.fs "$@" diff --git a/impls/fsharp/run b/impls/fsharp/run index 5c5642646f..8ea6fdbea1 100755 --- a/impls/fsharp/run +++ b/impls/fsharp/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec mono $(dirname $0)/${STEP:-stepA_mal}.exe ${RAW:+--raw} "${@}" +#!/bin/sh +set -Cefu +exec mono ${STEP:-stepA_mal}.exe ${RAW:+--raw} "$@" diff --git a/impls/gnu-smalltalk/run b/impls/gnu-smalltalk/run index 740459af26..746651207f 100755 --- a/impls/gnu-smalltalk/run +++ b/impls/gnu-smalltalk/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec gst -f $(dirname $0)/${STEP:-stepA_mal}.st "${@}" +#!/bin/sh +set -Cefu +exec gst -f ${STEP:-stepA_mal}.st "$@" diff --git a/impls/go/run b/impls/go/run index c66c2b81dc..5ffd062744 100755 --- a/impls/go/run +++ b/impls/go/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/groovy/run b/impls/groovy/run index b64ea39452..9733f7c8a5 100755 --- a/impls/groovy/run +++ b/impls/groovy/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec groovy $(dirname $0)/${STEP:-stepA_mal}.groovy "${@}" +#!/bin/sh +set -Cefu +exec groovy ${STEP:-stepA_mal}.groovy "$@" diff --git a/impls/guile/run b/impls/guile/run index 6d9e58d123..747d2c6932 100755 --- a/impls/guile/run +++ b/impls/guile/run @@ -1,3 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh +set -Cefu # XDG_CACHE_HOME is where guile stores the compiled files -XDG_CACHE_HOME=.cache/ exec guile -L $(dirname $0) $(dirname $0)/${STEP:-stepA_mal}.scm "${@}" +XDG_CACHE_HOME=.cache/ exec guile -L . ${STEP:-stepA_mal}.scm "$@" diff --git a/impls/hare/run b/impls/hare/run index 373d352735..5ffd062744 100755 --- a/impls/hare/run +++ b/impls/hare/run @@ -1,3 +1,3 @@ -#!/usr/bin/env bash - -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" \ No newline at end of file +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/haskell/run b/impls/haskell/run index 6efdc3de32..5ffd062744 100755 --- a/impls/haskell/run +++ b/impls/haskell/run @@ -1,2 +1,3 @@ #!/bin/sh -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/haxe/run b/impls/haxe/run index 3bb679ae65..fdd0476b6a 100755 --- a/impls/haxe/run +++ b/impls/haxe/run @@ -1,8 +1,9 @@ -#!/usr/bin/env bash +#!/bin/sh +set -Cefu case ${haxe_MODE:-neko} in - neko) exec neko $(dirname $0)/${STEP:-stepA_mal}.n "${@}" ;; - python) exec python3 $(dirname $0)/${STEP:-stepA_mal}.py "${@}" ;; - js) exec node $(dirname $0)/${STEP:-stepA_mal}.js "${@}" ;; - cpp) exec $(dirname $0)/cpp/${STEP:-stepA_mal} "${@}" ;; - *) echo "Invalid haxe_MODE: ${haxe_MODE}"; exit 2 ;; + neko) exec neko ${STEP:-stepA_mal}.n "$@" ;; + python) exec python3 ${STEP:-stepA_mal}.py "$@" ;; + js) exec node ${STEP:-stepA_mal}.js "$@" ;; + cpp) exec cpp/${STEP:-stepA_mal} "$@" ;; + *) echo "Invalid haxe_MODE: $haxe_MODE"; exit 2 ;; esac diff --git a/impls/hy/run b/impls/hy/run index e203849508..777d500345 100755 --- a/impls/hy/run +++ b/impls/hy/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal}.hy "${@}" +#!/bin/sh +set -Cefu +exec hy ${STEP:-stepA_mal}.hy "$@" diff --git a/impls/hy/step0_repl.hy b/impls/hy/step0_repl.hy old mode 100755 new mode 100644 index d651bbf0ef..5b837b721b --- a/impls/hy/step0_repl.hy +++ b/impls/hy/step0_repl.hy @@ -1,5 +1,3 @@ -#!/usr/bin/env hy - (defn READ [str] str) diff --git a/impls/hy/step1_read_print.hy b/impls/hy/step1_read_print.hy old mode 100755 new mode 100644 index ba8670e14b..61af6fda01 --- a/impls/hy/step1_read_print.hy +++ b/impls/hy/step1_read_print.hy @@ -1,5 +1,3 @@ -#!/usr/bin/env hy - (import sys traceback) (import [reader [read-str Blank]]) (import [printer [pr-str]]) diff --git a/impls/hy/step2_eval.hy b/impls/hy/step2_eval.hy old mode 100755 new mode 100644 index adfc2a16a6..1ade3ab4dd --- a/impls/hy/step2_eval.hy +++ b/impls/hy/step2_eval.hy @@ -1,5 +1,3 @@ -#!/usr/bin/env hy - (import sys traceback) (import [reader [read-str Blank]]) (import [printer [pr-str]]) diff --git a/impls/hy/step3_env.hy b/impls/hy/step3_env.hy old mode 100755 new mode 100644 index 26fca8fa7a..1a92f421f7 --- a/impls/hy/step3_env.hy +++ b/impls/hy/step3_env.hy @@ -1,5 +1,3 @@ -#!/usr/bin/env hy - (import [hy.models [HySymbol :as Sym]]) (import sys traceback) (import [reader [read-str Blank]]) diff --git a/impls/hy/step4_if_fn_do.hy b/impls/hy/step4_if_fn_do.hy old mode 100755 new mode 100644 index ae01bf32a5..c65b49c991 --- a/impls/hy/step4_if_fn_do.hy +++ b/impls/hy/step4_if_fn_do.hy @@ -1,5 +1,3 @@ -#!/usr/bin/env hy - (import [hy.models [HySymbol :as Sym]]) (import sys traceback) (import [mal_types [MalException]]) diff --git a/impls/hy/step5_tco.hy b/impls/hy/step5_tco.hy old mode 100755 new mode 100644 index 6b364657ab..6beef1a319 --- a/impls/hy/step5_tco.hy +++ b/impls/hy/step5_tco.hy @@ -1,5 +1,3 @@ -#!/usr/bin/env hy - (import [hy.models [HySymbol :as Sym]]) (import sys traceback) (import [mal_types [MalException]]) diff --git a/impls/hy/step6_file.hy b/impls/hy/step6_file.hy old mode 100755 new mode 100644 index 9cf4c7380a..45f871aff1 --- a/impls/hy/step6_file.hy +++ b/impls/hy/step6_file.hy @@ -1,5 +1,3 @@ -#!/usr/bin/env hy - (import [hy.models [HyString :as Str HySymbol :as Sym]]) (import sys traceback) (import [mal_types [MalException]]) diff --git a/impls/hy/step7_quote.hy b/impls/hy/step7_quote.hy old mode 100755 new mode 100644 index 757852db5f..de7252f2de --- a/impls/hy/step7_quote.hy +++ b/impls/hy/step7_quote.hy @@ -1,5 +1,3 @@ -#!/usr/bin/env hy - (import [hy.models [HyString :as Str HySymbol :as Sym]]) (import sys traceback) (import [mal_types [MalException]]) diff --git a/impls/hy/step8_macros.hy b/impls/hy/step8_macros.hy old mode 100755 new mode 100644 index 97ee0ee46c..806914b5a6 --- a/impls/hy/step8_macros.hy +++ b/impls/hy/step8_macros.hy @@ -1,5 +1,3 @@ -#!/usr/bin/env hy - (import [hy.models [HyString :as Str HySymbol :as Sym]]) (import sys traceback) (import [mal_types [MalException]]) diff --git a/impls/hy/step9_try.hy b/impls/hy/step9_try.hy old mode 100755 new mode 100644 index 5dc44a0cf0..f852b53fa7 --- a/impls/hy/step9_try.hy +++ b/impls/hy/step9_try.hy @@ -1,5 +1,3 @@ -#!/usr/bin/env hy - (import [hy.models [HyString :as Str HySymbol :as Sym]]) (import sys traceback) (import [mal_types [MalException]]) diff --git a/impls/hy/stepA_mal.hy b/impls/hy/stepA_mal.hy old mode 100755 new mode 100644 index 3e881fdab6..dbffa8835e --- a/impls/hy/stepA_mal.hy +++ b/impls/hy/stepA_mal.hy @@ -1,5 +1,3 @@ -#!/usr/bin/env hy - (import [hy.models [HyString :as Str HySymbol :as Sym]]) (import sys traceback) (import [mal_types [MalException]]) diff --git a/impls/io/run b/impls/io/run index d49d10a227..6d84acab3b 100755 --- a/impls/io/run +++ b/impls/io/run @@ -1,3 +1,3 @@ -#!/usr/bin/env bash - -io $(dirname $0)/${STEP:-stepA_mal}.io "$@" +#!/bin/sh +set -Cefu +exec io ${STEP:-stepA_mal}.io "$@" diff --git a/impls/janet/run b/impls/janet/run index f4782c8fae..59c0c1b628 100755 --- a/impls/janet/run +++ b/impls/janet/run @@ -1,2 +1,3 @@ #!/bin/sh -exec janet $(dirname $0)/${STEP:-stepA_mal}.janet "${@}" +set -Cefu +exec janet ${STEP:-stepA_mal}.janet "$@" diff --git a/impls/java-truffle/run b/impls/java-truffle/run index c5ca27135f..5e6271cbe4 100755 --- a/impls/java-truffle/run +++ b/impls/java-truffle/run @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +#!/bin/sh +set -Cefu CP=$(gradle -q --console plain printClasspath) diff --git a/impls/java/run b/impls/java/run index 670f45c4db..567e9f649c 100755 --- a/impls/java/run +++ b/impls/java/run @@ -1,9 +1,8 @@ -#!/usr/bin/env bash -args="" -if [ "$#" -gt 0 ]; then - args="-Dexec.args='$1'" - for a in "${@:2}"; do - args="$args '$a'" - done -fi -exec mvn -quiet -e exec:java -Dexec.mainClass="mal.${STEP:-stepA_mal}" ${args:+"$args"} +#!/bin/sh +set -Cefu +for a; do + args="${args:+$args }'$a'" +done +exec mvn -quiet -e exec:java \ + -Dexec.mainClass=mal.${STEP:-stepA_mal} \ + ${args:+"-Dexec.args=$args"} diff --git a/impls/js/run b/impls/js/run index 1148122a23..d1135e76d4 100755 --- a/impls/js/run +++ b/impls/js/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec node $(dirname $0)/${STEP:-stepA_mal}.js "${@}" +#!/bin/sh +set -Cefu +exec node ${STEP:-stepA_mal}.js "$@" diff --git a/impls/julia/run b/impls/julia/run index dd149451f1..3a08886fca 100755 --- a/impls/julia/run +++ b/impls/julia/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec julia $(dirname $0)/${STEP:-stepA_mal}.jl "${@}" +#!/bin/sh +set -Cefu +exec julia ${STEP:-stepA_mal}.jl "$@" diff --git a/impls/julia/step0_repl.jl b/impls/julia/step0_repl.jl old mode 100755 new mode 100644 index 049cde1418..e26734a05e --- a/impls/julia/step0_repl.jl +++ b/impls/julia/step0_repl.jl @@ -1,5 +1,3 @@ -#!/usr/bin/env julia - push!(LOAD_PATH, pwd(), "/usr/share/julia/base") import readline_mod diff --git a/impls/julia/step1_read_print.jl b/impls/julia/step1_read_print.jl old mode 100755 new mode 100644 index 604b1f9c3d..9991ebd308 --- a/impls/julia/step1_read_print.jl +++ b/impls/julia/step1_read_print.jl @@ -1,5 +1,3 @@ -#!/usr/bin/env julia - push!(LOAD_PATH, pwd(), "/usr/share/julia/base") import readline_mod import reader diff --git a/impls/julia/step2_eval.jl b/impls/julia/step2_eval.jl old mode 100755 new mode 100644 index b64ca9e17c..cc97dbf81e --- a/impls/julia/step2_eval.jl +++ b/impls/julia/step2_eval.jl @@ -1,5 +1,3 @@ -#!/usr/bin/env julia - push!(LOAD_PATH, pwd(), "/usr/share/julia/base") import readline_mod import reader diff --git a/impls/julia/step3_env.jl b/impls/julia/step3_env.jl old mode 100755 new mode 100644 index b1cdd6c595..e4d8a895de --- a/impls/julia/step3_env.jl +++ b/impls/julia/step3_env.jl @@ -1,5 +1,3 @@ -#!/usr/bin/env julia - push!(LOAD_PATH, pwd(), "/usr/share/julia/base") import readline_mod import reader diff --git a/impls/julia/step4_if_fn_do.jl b/impls/julia/step4_if_fn_do.jl old mode 100755 new mode 100644 index 70334f4337..ffb421eba0 --- a/impls/julia/step4_if_fn_do.jl +++ b/impls/julia/step4_if_fn_do.jl @@ -1,5 +1,3 @@ -#!/usr/bin/env julia - push!(LOAD_PATH, pwd(), "/usr/share/julia/base") import readline_mod import reader diff --git a/impls/julia/step5_tco.jl b/impls/julia/step5_tco.jl old mode 100755 new mode 100644 index 08ed0659cf..9741829cef --- a/impls/julia/step5_tco.jl +++ b/impls/julia/step5_tco.jl @@ -1,5 +1,3 @@ -#!/usr/bin/env julia - push!(LOAD_PATH, pwd(), "/usr/share/julia/base") import readline_mod import reader diff --git a/impls/julia/step6_file.jl b/impls/julia/step6_file.jl old mode 100755 new mode 100644 index 0c39d0516e..3654228609 --- a/impls/julia/step6_file.jl +++ b/impls/julia/step6_file.jl @@ -1,5 +1,3 @@ -#!/usr/bin/env julia - push!(LOAD_PATH, pwd(), "/usr/share/julia/base") import readline_mod import reader diff --git a/impls/julia/step7_quote.jl b/impls/julia/step7_quote.jl old mode 100755 new mode 100644 index 86148cfd67..66b43232d5 --- a/impls/julia/step7_quote.jl +++ b/impls/julia/step7_quote.jl @@ -1,5 +1,3 @@ -#!/usr/bin/env julia - push!(LOAD_PATH, pwd(), "/usr/share/julia/base") import readline_mod import reader diff --git a/impls/julia/step8_macros.jl b/impls/julia/step8_macros.jl old mode 100755 new mode 100644 index 5dee5a32e1..ef460889bd --- a/impls/julia/step8_macros.jl +++ b/impls/julia/step8_macros.jl @@ -1,5 +1,3 @@ -#!/usr/bin/env julia - push!(LOAD_PATH, pwd(), "/usr/share/julia/base") import readline_mod import reader diff --git a/impls/julia/step9_try.jl b/impls/julia/step9_try.jl old mode 100755 new mode 100644 index 73c18d01df..ca902b98a1 --- a/impls/julia/step9_try.jl +++ b/impls/julia/step9_try.jl @@ -1,5 +1,3 @@ -#!/usr/bin/env julia - push!(LOAD_PATH, pwd(), "/usr/share/julia/base") import readline_mod import reader diff --git a/impls/julia/stepA_mal.jl b/impls/julia/stepA_mal.jl old mode 100755 new mode 100644 index efeabef3e6..6f71851eed --- a/impls/julia/stepA_mal.jl +++ b/impls/julia/stepA_mal.jl @@ -1,5 +1,3 @@ -#!/usr/bin/env julia - push!(LOAD_PATH, pwd(), "/usr/share/julia/base") import readline_mod import reader diff --git a/impls/kotlin/run b/impls/kotlin/run index c5a1f3c10f..f77cf44639 100755 --- a/impls/kotlin/run +++ b/impls/kotlin/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec java -jar $(dirname $0)/${STEP:-stepA_mal}.jar "${@}" +#!/bin/sh +set -Cefu +exec java -jar ${STEP:-stepA_mal}.jar "$@" diff --git a/impls/latex3/run b/impls/latex3/run index 7a05291e20..c8965f8caf 100755 --- a/impls/latex3/run +++ b/impls/latex3/run @@ -2,7 +2,6 @@ set -Cefu # LaTeX creates temporary files in the current directory. -cd $(dirname $0) # There is no way to directly provide command line arguments to LaTeX, # use an intermediate file. diff --git a/impls/livescript/run b/impls/livescript/run index 1148122a23..d1135e76d4 100755 --- a/impls/livescript/run +++ b/impls/livescript/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec node $(dirname $0)/${STEP:-stepA_mal}.js "${@}" +#!/bin/sh +set -Cefu +exec node ${STEP:-stepA_mal}.js "$@" diff --git a/impls/logo/run b/impls/logo/run index f4a73d98c1..422aa8fc40 100755 --- a/impls/logo/run +++ b/impls/logo/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec ucblogo $(dirname $0)/${STEP:-stepA_mal}.lg - "${@}" +#!/bin/sh +set -Cefu +exec ucblogo ${STEP:-stepA_mal}.lg - "$@" diff --git a/impls/lua/run b/impls/lua/run index a53fbc60ba..78595ba01f 100755 --- a/impls/lua/run +++ b/impls/lua/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec lua $(dirname $0)/${STEP:-stepA_mal}.lua "${@}" +#!/bin/sh +set -Cefu +exec lua ${STEP:-stepA_mal}.lua "$@" diff --git a/impls/lua/step0_repl.lua b/impls/lua/step0_repl.lua old mode 100755 new mode 100644 index bb082a599d..94290842f8 --- a/impls/lua/step0_repl.lua +++ b/impls/lua/step0_repl.lua @@ -1,5 +1,3 @@ -#!/usr/bin/env lua - local readline = require('readline') function READ(str) diff --git a/impls/lua/step1_read_print.lua b/impls/lua/step1_read_print.lua old mode 100755 new mode 100644 index 78cde8c1fe..db7ec5d2dd --- a/impls/lua/step1_read_print.lua +++ b/impls/lua/step1_read_print.lua @@ -1,5 +1,3 @@ -#!/usr/bin/env lua - local readline = require('readline') local types = require('types') local reader = require('reader') diff --git a/impls/lua/step2_eval.lua b/impls/lua/step2_eval.lua old mode 100755 new mode 100644 index 0bb44d2a26..3259c87ca1 --- a/impls/lua/step2_eval.lua +++ b/impls/lua/step2_eval.lua @@ -1,5 +1,3 @@ -#!/usr/bin/env lua - local table = require('table') local readline = require('readline') diff --git a/impls/lua/step3_env.lua b/impls/lua/step3_env.lua old mode 100755 new mode 100644 index 297083deed..93afe5d885 --- a/impls/lua/step3_env.lua +++ b/impls/lua/step3_env.lua @@ -1,5 +1,3 @@ -#!/usr/bin/env lua - local table = require('table') local readline = require('readline') diff --git a/impls/lua/step4_if_fn_do.lua b/impls/lua/step4_if_fn_do.lua old mode 100755 new mode 100644 index f69c2379ed..d89653c391 --- a/impls/lua/step4_if_fn_do.lua +++ b/impls/lua/step4_if_fn_do.lua @@ -1,5 +1,3 @@ -#!/usr/bin/env lua - local table = require('table') local readline = require('readline') diff --git a/impls/lua/step5_tco.lua b/impls/lua/step5_tco.lua old mode 100755 new mode 100644 index 923a148357..d985db589a --- a/impls/lua/step5_tco.lua +++ b/impls/lua/step5_tco.lua @@ -1,5 +1,3 @@ -#!/usr/bin/env lua - local table = require('table') local readline = require('readline') diff --git a/impls/lua/step6_file.lua b/impls/lua/step6_file.lua old mode 100755 new mode 100644 index 2f5abf7d57..2d8a952734 --- a/impls/lua/step6_file.lua +++ b/impls/lua/step6_file.lua @@ -1,5 +1,3 @@ -#!/usr/bin/env lua - local table = require('table') local readline = require('readline') diff --git a/impls/lua/step7_quote.lua b/impls/lua/step7_quote.lua old mode 100755 new mode 100644 index 67de77665f..0a334d58d0 --- a/impls/lua/step7_quote.lua +++ b/impls/lua/step7_quote.lua @@ -1,5 +1,3 @@ -#!/usr/bin/env lua - local table = require('table') local readline = require('readline') diff --git a/impls/lua/step8_macros.lua b/impls/lua/step8_macros.lua old mode 100755 new mode 100644 index ce12dc864e..b33ffb8f88 --- a/impls/lua/step8_macros.lua +++ b/impls/lua/step8_macros.lua @@ -1,5 +1,3 @@ -#!/usr/bin/env lua - local table = require('table') local readline = require('readline') diff --git a/impls/lua/step9_try.lua b/impls/lua/step9_try.lua old mode 100755 new mode 100644 index a6fe507d5f..2634ac953a --- a/impls/lua/step9_try.lua +++ b/impls/lua/step9_try.lua @@ -1,5 +1,3 @@ -#!/usr/bin/env lua - local table = require('table') local readline = require('readline') diff --git a/impls/lua/stepA_mal.lua b/impls/lua/stepA_mal.lua old mode 100755 new mode 100644 index 242b1cdda4..76f614966e --- a/impls/lua/stepA_mal.lua +++ b/impls/lua/stepA_mal.lua @@ -1,5 +1,3 @@ -#!/usr/bin/env lua - local table = require('table') package.path = '../lua/?.lua;' .. package.path diff --git a/impls/make/reader.mk b/impls/make/reader.mk old mode 100755 new mode 100644 diff --git a/impls/make/run b/impls/make/run index 43b9344665..bfbcc4447e 100755 --- a/impls/make/run +++ b/impls/make/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec make --no-print-directory -f $(dirname $0)/${STEP:-stepA_mal}.mk "${@}" +#!/bin/sh +set -Cefu +exec make --no-print-directory -f ${STEP:-stepA_mal}.mk "$@" diff --git a/impls/mal/run b/impls/mal/run index 3bf6b5b09c..f9ac1907bc 100755 --- a/impls/mal/run +++ b/impls/mal/run @@ -1,9 +1,15 @@ -#!/usr/bin/env bash +#!/bin/sh +set -Cefu MAL_FILE=../mal/${STEP:-stepA_mal}.mal export STEP=stepA_mal # force MAL_IMPL to use stepA -case ${MAL_IMPL} in -*-mal) - MAL_IMPL=${MAL_IMPL%%-mal} - MAL_FILE="../mal/stepA_mal.mal ${MAL_FILE}" ;; +impl=${MAL_IMPL:-js} +case $impl in + *-mal) + cd ../${impl%-mal} + exec ./run ../mal/stepA_mal.mal $MAL_FILE "$@" + ;; + *) + cd ../$impl + exec ./run $MAL_FILE "$@" + ;; esac -exec ./../${MAL_IMPL:-js}/run ${MAL_FILE} "${@}" diff --git a/impls/matlab/run b/impls/matlab/run index 332c5903de..34d12fa2ba 100755 --- a/impls/matlab/run +++ b/impls/matlab/run @@ -1,21 +1,20 @@ #!/bin/sh +set -Cefu -args= for x; do - args="$args${args:+, }'$x'" + args="${args:+$args, }'$x'" done +prompt="${STEP:-stepA_mal}(${args:-});quit;" -case "$matlab_MODE" in +case ${matlab_MODE:-octave} in matlab) - options='-nodisplay -nosplash -nodesktop -nojvm -r' + exec matlab -nodisplay -nosplash -nodesktop -nojvm -r "$prompt" ;; octave) - options='-q --no-gui --no-history --eval' + exec octave -q --no-gui --no-history --eval "$prompt" ;; *) echo "Bad matlab_MODE: $matlab_MODE" exit 1 ;; esac - -exec $matlab_MODE $options "${STEP:-stepA_mal}($args);quit;" diff --git a/impls/miniMAL/run b/impls/miniMAL/run index 5fe9482d6e..824b708851 100755 --- a/impls/miniMAL/run +++ b/impls/miniMAL/run @@ -1,3 +1,3 @@ -#!/usr/bin/env bash -cd $(dirname $0) -exec miniMAL ./${STEP:-stepA_mal}.json "${@}" +#!/bin/sh +set -Cefu +exec miniMAL ${STEP:-stepA_mal}.json "$@" diff --git a/impls/nasm/run b/impls/nasm/run index 016cc72d79..5ffd062744 100755 --- a/impls/nasm/run +++ b/impls/nasm/run @@ -1,3 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" - +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/nim/run b/impls/nim/run index 6efdc3de32..5ffd062744 100755 --- a/impls/nim/run +++ b/impls/nim/run @@ -1,2 +1,3 @@ #!/bin/sh -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/objc/run b/impls/objc/run index c66c2b81dc..5ffd062744 100755 --- a/impls/objc/run +++ b/impls/objc/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/objpascal/run b/impls/objpascal/run index c66c2b81dc..5ffd062744 100755 --- a/impls/objpascal/run +++ b/impls/objpascal/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/ocaml/run b/impls/ocaml/run index 6efdc3de32..5ffd062744 100755 --- a/impls/ocaml/run +++ b/impls/ocaml/run @@ -1,2 +1,3 @@ #!/bin/sh -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/perl/run b/impls/perl/run index 4f255fe5fe..88118dc06b 100755 --- a/impls/perl/run +++ b/impls/perl/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec perl $(dirname $0)/${STEP:-stepA_mal}.pl "${@}" +#!/bin/sh +set -Cefu +exec perl ${STEP:-stepA_mal}.pl ${RAW:+--raw} "$@" diff --git a/impls/perl/step0_repl.pl b/impls/perl/step0_repl.pl index 2947178df3..a0018328a5 100644 --- a/impls/perl/step0_repl.pl +++ b/impls/perl/step0_repl.pl @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings; use File::Basename 'dirname'; @@ -34,7 +32,7 @@ sub REP { } # Command line arguments -if ( $ARGV[0] eq '--raw' ) { +if ( @ARGV and $ARGV[0] eq '--raw' ) { set_rl_mode('raw'); shift @ARGV; } diff --git a/impls/perl/step1_read_print.pl b/impls/perl/step1_read_print.pl index 43f2d82fcf..36f1bd92e9 100644 --- a/impls/perl/step1_read_print.pl +++ b/impls/perl/step1_read_print.pl @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings; use File::Basename 'dirname'; @@ -36,7 +34,7 @@ sub REP { } # Command line arguments -if ( $ARGV[0] eq '--raw' ) { +if ( @ARGV and $ARGV[0] eq '--raw' ) { set_rl_mode('raw'); shift @ARGV; } diff --git a/impls/perl/step2_eval.pl b/impls/perl/step2_eval.pl index 23bccdc69f..6ed7b5b3c7 100644 --- a/impls/perl/step2_eval.pl +++ b/impls/perl/step2_eval.pl @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings; use File::Basename 'dirname'; @@ -63,7 +61,7 @@ sub REP { } # Command line arguments -if ( $ARGV[0] eq '--raw' ) { +if ( @ARGV and $ARGV[0] eq '--raw' ) { set_rl_mode('raw'); shift @ARGV; } diff --git a/impls/perl/step3_env.pl b/impls/perl/step3_env.pl index 9b09031d8a..8add028df0 100644 --- a/impls/perl/step3_env.pl +++ b/impls/perl/step3_env.pl @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings; use File::Basename 'dirname'; @@ -93,7 +91,7 @@ sub REP { } # Command line arguments -if ( $ARGV[0] eq '--raw' ) { +if ( @ARGV and $ARGV[0] eq '--raw' ) { set_rl_mode('raw'); shift @ARGV; } diff --git a/impls/perl/step4_if_fn_do.pl b/impls/perl/step4_if_fn_do.pl index df4b825302..b4cc282aca 100644 --- a/impls/perl/step4_if_fn_do.pl +++ b/impls/perl/step4_if_fn_do.pl @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings; use File::Basename 'dirname'; @@ -124,7 +122,7 @@ sub REP { } # Command line arguments -if ( $ARGV[0] eq '--raw' ) { +if ( @ARGV and $ARGV[0] eq '--raw' ) { set_rl_mode('raw'); shift @ARGV; } diff --git a/impls/perl/step5_tco.pl b/impls/perl/step5_tco.pl index 7d2460de36..de59963b0b 100644 --- a/impls/perl/step5_tco.pl +++ b/impls/perl/step5_tco.pl @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings FATAL => 'recursion'; use File::Basename 'dirname'; @@ -134,7 +132,7 @@ sub REP { } # Command line arguments -if ( $ARGV[0] eq '--raw' ) { +if ( @ARGV and $ARGV[0] eq '--raw' ) { set_rl_mode('raw'); shift @ARGV; } diff --git a/impls/perl/step6_file.pl b/impls/perl/step6_file.pl index e0eca83ec5..ce6c496fc0 100644 --- a/impls/perl/step6_file.pl +++ b/impls/perl/step6_file.pl @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings FATAL => 'recursion'; use File::Basename 'dirname'; @@ -134,7 +132,7 @@ sub REP { } # Command line arguments -if ( $ARGV[0] eq '--raw' ) { +if ( @ARGV and $ARGV[0] eq '--raw' ) { set_rl_mode('raw'); shift @ARGV; } diff --git a/impls/perl/step7_quote.pl b/impls/perl/step7_quote.pl index ceee9c894f..6042b83535 100644 --- a/impls/perl/step7_quote.pl +++ b/impls/perl/step7_quote.pl @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings FATAL => 'recursion'; use File::Basename 'dirname'; @@ -187,7 +185,7 @@ sub REP { } # Command line arguments -if ( $ARGV[0] eq '--raw' ) { +if ( @ARGV and $ARGV[0] eq '--raw' ) { set_rl_mode('raw'); shift @ARGV; } diff --git a/impls/perl/step8_macros.pl b/impls/perl/step8_macros.pl index aee1bb8274..75c040a2f8 100644 --- a/impls/perl/step8_macros.pl +++ b/impls/perl/step8_macros.pl @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings FATAL => 'recursion'; use File::Basename 'dirname'; @@ -198,7 +196,7 @@ sub REP { } # Command line arguments -if ( $ARGV[0] eq '--raw' ) { +if ( @ARGV and $ARGV[0] eq '--raw' ) { set_rl_mode('raw'); shift @ARGV; } diff --git a/impls/perl/step9_try.pl b/impls/perl/step9_try.pl index 3612fba99d..c3311d1ed6 100644 --- a/impls/perl/step9_try.pl +++ b/impls/perl/step9_try.pl @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings FATAL => 'recursion'; use File::Basename 'dirname'; @@ -221,7 +219,7 @@ sub REP { } # Command line arguments -if ( $ARGV[0] eq '--raw' ) { +if ( @ARGV and $ARGV[0] eq '--raw' ) { set_rl_mode('raw'); shift @ARGV; } diff --git a/impls/perl/stepA_mal.pl b/impls/perl/stepA_mal.pl index e48046d504..698f9fb148 100644 --- a/impls/perl/stepA_mal.pl +++ b/impls/perl/stepA_mal.pl @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings FATAL => 'recursion'; use File::Basename 'dirname'; @@ -221,7 +219,7 @@ sub REP { } # Command line arguments -if ( $ARGV[0] eq '--raw' ) { +if ( @ARGV and $ARGV[0] eq '--raw' ) { set_rl_mode('raw'); shift @ARGV; } diff --git a/impls/perl6/run b/impls/perl6/run index 80cb92b34b..8d8e369eed 100755 --- a/impls/perl6/run +++ b/impls/perl6/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec perl6 $(dirname $0)/${STEP:-stepA_mal}.pl "${@}" +#!/bin/sh +set -Cefu +exec perl6 ${STEP:-stepA_mal}.pl "$@" diff --git a/impls/php/run b/impls/php/run index daf97f93c0..d2f262bc2b 100755 --- a/impls/php/run +++ b/impls/php/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec php $(dirname $0)/${STEP:-stepA_mal}.php "${@}" +#!/bin/sh +set -Cefu +exec php ${STEP:-stepA_mal}.php "$@" diff --git a/impls/php/tests/stepA_mal.mal b/impls/php/tests/stepA_mal.mal index de459cdbcf..3a873c0440 100644 --- a/impls/php/tests/stepA_mal.mal +++ b/impls/php/tests/stepA_mal.mal @@ -37,7 +37,7 @@ ;; testing superglobal variable access (get php/_SERVER "PHP_SELF") -;=>"../php/stepA_mal.php" +;=>"stepA_mal.php" ;; testing PHP constants access diff --git a/impls/picolisp/run b/impls/picolisp/run index a7f77da3fd..7e5ffa8b30 100755 --- a/impls/picolisp/run +++ b/impls/picolisp/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec pil $(dirname $0)/${STEP:-stepA_mal}.l - "${@}" +#!/bin/sh +set -Cefu +exec pil ${STEP:-stepA_mal}.l - "$@" diff --git a/impls/pike/run b/impls/pike/run index 1281d967de..bb8b2b35ee 100755 --- a/impls/pike/run +++ b/impls/pike/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec pike $(dirname $0)/${STEP:-stepA_mal}.pike "${@}" +#!/bin/sh +set -Cefu +exec pike ${STEP:-stepA_mal}.pike "$@" diff --git a/impls/plpgsql/init.sql b/impls/plpgsql/init.sql old mode 100755 new mode 100644 diff --git a/impls/plpgsql/run b/impls/plpgsql/run index a16184e01a..b4237611be 100755 --- a/impls/plpgsql/run +++ b/impls/plpgsql/run @@ -1,2 +1,75 @@ #!/usr/bin/env bash -exec $(dirname $0)/wrap.sh $(dirname $0)/${STEP:-stepA_mal}.sql "${@}" +step=${STEP:-stepA_mal}.sql + +RL_HISTORY_FILE=${HOME}/.mal-history +SKIP_INIT="${SKIP_INIT:-}" +PSQL_USER="${PSQL_USER:-postgres}" + +PSQL="psql -q -t -A -v ON_ERROR_STOP=1 ${PSQL_USER:+-U ${PSQL_USER}}" +[ "${DEBUG}" ] || PSQL="${PSQL} -v VERBOSITY=terse" + +# If mal DB is not there, force create of it +dbcheck=$(${PSQL} -c "select 1 from pg_database where datname='mal'") +[ -z "${dbcheck}" ] && SKIP_INIT= + +STDOUT_PID= STDIN_PID= +cleanup () { + trap - TERM QUIT INT EXIT + # Make sure input stream is closed. Input subprocess will do this + # for normal terminal input but in the runtest.py case it does not + # get a chance. + ${PSQL} -dmal -c "SELECT io.close(0);" > /dev/null + [ "${STDIN_PID}" ] && kill ${STDIN_PID} 2>/dev/null +} + +# Load the SQL code +trap "cleanup" TERM QUIT INT EXIT +${PSQL} -tc "SELECT 1 FROM pg_database WHERE datname = 'mal'" \ + | grep -q 1 || ${PSQL} -c "CREATE DATABASE mal" +#[ "${SKIP_INIT}" ] || ${PSQL} -dmal -f $step > /dev/null +[ "${SKIP_INIT}" ] || ${PSQL} -dmal -f $step + +${PSQL} -dmal -c "SELECT io.open(0); SELECT io.open(1);" > /dev/null + +# Stream from table to stdout +( +while true; do + out="$(${PSQL} -dmal -c "SELECT io.read_or_error(1)" 2>/dev/null)" || break + echo "${out}" +done +) & +STDOUT_PID=$! + +# Perform readline input into stream table when requested +( +[ -r ${RL_HISTORY_FILE} ] && history -r ${RL_HISTORY_FILE} +while true; do + prompt=$(${PSQL} -dmal \ + -c "SELECT io.wait_rl_prompt(0);" 2>/dev/null) || break + IFS= read -u 0 -r -e -p "${prompt}" line || break + if [ "${line}" ]; then + history -s -- "${line}" # add to history + history -a ${RL_HISTORY_FILE} # save history to file + fi + + ${PSQL} -dmal -v arg="${line}" \ + -f <(echo "SELECT io.writeline(:'arg', 0);") >/dev/null || break +done +${PSQL} -dmal -c "SELECT io.close(0);" > /dev/null +) <&0 >&1 & +STDIN_PID=$! + +res=0 +if [ $# -gt 0 ]; then + # If there are command line arguments then run a command and exit + args=$(for a in "$@"; do echo -n "\"$a\" "; done) + ${PSQL} -dmal -v args="(${args})" \ + -f <(echo "SELECT mal.MAIN('$(pwd)', :'args');") > /dev/null + res=$? +else + # Start main loop in the background + ${PSQL} -dmal -c "SELECT mal.MAIN('$(pwd)');" > /dev/null + res=$? +fi +wait ${STDOUT_PID} +exit ${res} diff --git a/impls/plpgsql/wrap.sh b/impls/plpgsql/wrap.sh deleted file mode 100755 index e14c072d6a..0000000000 --- a/impls/plpgsql/wrap.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env bash - -RL_HISTORY_FILE=${HOME}/.mal-history -SKIP_INIT="${SKIP_INIT:-}" -PSQL_USER="${PSQL_USER:-postgres}" - -PSQL="psql -q -t -A -v ON_ERROR_STOP=1 ${PSQL_USER:+-U ${PSQL_USER}}" -[ "${DEBUG}" ] || PSQL="${PSQL} -v VERBOSITY=terse" - -# If mal DB is not there, force create of it -dbcheck=$(${PSQL} -c "select 1 from pg_database where datname='mal'") -[ -z "${dbcheck}" ] && SKIP_INIT= - -STDOUT_PID= STDIN_PID= -cleanup () { - trap - TERM QUIT INT EXIT - # Make sure input stream is closed. Input subprocess will do this - # for normal terminal input but in the runtest.py case it does not - # get a chance. - ${PSQL} -dmal -c "SELECT io.close(0);" > /dev/null - [ "${STDIN_PID}" ] && kill ${STDIN_PID} 2>/dev/null -} - -# Load the SQL code -trap "cleanup" TERM QUIT INT EXIT -${PSQL} -tc "SELECT 1 FROM pg_database WHERE datname = 'mal'" \ - | grep -q 1 || ${PSQL} -c "CREATE DATABASE mal" -#[ "${SKIP_INIT}" ] || ${PSQL} -dmal -f $1 > /dev/null -[ "${SKIP_INIT}" ] || ${PSQL} -dmal -f $1 - -${PSQL} -dmal -c "SELECT io.open(0); SELECT io.open(1);" > /dev/null - -# Stream from table to stdout -( -while true; do - out="$(${PSQL} -dmal -c "SELECT io.read_or_error(1)" 2>/dev/null)" || break - echo "${out}" -done -) & -STDOUT_PID=$! - -# Perform readline input into stream table when requested -( -[ -r ${RL_HISTORY_FILE} ] && history -r ${RL_HISTORY_FILE} -while true; do - prompt=$(${PSQL} -dmal \ - -c "SELECT io.wait_rl_prompt(0);" 2>/dev/null) || break - IFS= read -u 0 -r -e -p "${prompt}" line || break - if [ "${line}" ]; then - history -s -- "${line}" # add to history - history -a ${RL_HISTORY_FILE} # save history to file - fi - - ${PSQL} -dmal -v arg="${line}" \ - -f <(echo "SELECT io.writeline(:'arg', 0);") >/dev/null || break -done -${PSQL} -dmal -c "SELECT io.close(0);" > /dev/null -) <&0 >&1 & -STDIN_PID=$! - -res=0 -shift -if [ $# -gt 0 ]; then - # If there are command line arguments then run a command and exit - args=$(for a in "$@"; do echo -n "\"$a\" "; done) - ${PSQL} -dmal -v args="(${args})" \ - -f <(echo "SELECT mal.MAIN('$(pwd)', :'args');") > /dev/null - res=$? -else - # Start main loop in the background - ${PSQL} -dmal -c "SELECT mal.MAIN('$(pwd)');" > /dev/null - res=$? -fi -wait ${STDOUT_PID} -exit ${res} diff --git a/impls/plsql/run b/impls/plsql/run index a16184e01a..39f9d037c1 100755 --- a/impls/plsql/run +++ b/impls/plsql/run @@ -1,2 +1,122 @@ #!/usr/bin/env bash -exec $(dirname $0)/wrap.sh $(dirname $0)/${STEP:-stepA_mal}.sql "${@}" +step=${STEP:-stepA_mal}.sql + +RL_HISTORY_FILE=${HOME}/.mal-history +SKIP_INIT="${SKIP_INIT:-}" + +ORACLE_LOGON=${ORACLE_LOGON:-system/oracle} +SQLPLUS="sqlplus -S ${ORACLE_LOGON}" + +FILE_PID= +cleanup() { + trap - TERM QUIT INT EXIT + #echo cleanup: ${FILE_PID} + [ "${FILE_PID}" ] && kill ${FILE_PID} +} +trap "cleanup" TERM QUIT INT EXIT + + +# Load the SQL code +if [ -z "${SKIP_INIT}" ]; then + out=$(echo "" | ${SQLPLUS} @$step) + if echo "${out}" | grep -vs "^No errors.$" \ + | grep -si error >/dev/null; then + #if echo "${out}" | grep -si error >/dev/null; then + echo "${out}" + exit 1 + fi +fi + +# open I/O streams +echo -e "BEGIN io.open(0); io.open(1); END;\n/" \ + | ${SQLPLUS} >/dev/null + +# Stream from table to stdout +( +while true; do + out="$(echo "SELECT io.read(1) FROM dual;" \ + | ${SQLPLUS} 2>/dev/null)" || break + #echo "out: [${out}] (${#out})" + echo "${out}" +done +) & +STDOUT_PID=$! + +# Perform readline input into stream table when requested +( +[ -r ${RL_HISTORY_FILE} ] && history -r ${RL_HISTORY_FILE} +while true; do + prompt=$(echo "SELECT io.wait_rl_prompt(0) FROM dual;" \ + | ${SQLPLUS} 2>/dev/null) || break + # Prompt is returned single-quoted because sqlplus trims trailing + # whitespace. Remove the single quotes from the beginning and end: + prompt=${prompt%\'} + prompt=${prompt#\'} + #echo "prompt: [${prompt}]" + + IFS= read -u 0 -r -e -p "${prompt}" line || break + if [ "${line}" ]; then + history -s -- "${line}" # add to history + history -a ${RL_HISTORY_FILE} # save history to file + fi + + # Escape (double) single quotes per SQL norm + line=${line//\'/\'\'} + #echo "line: [${line}]" + ( echo -n "BEGIN io.writeline('${line}', 0); END;"; + echo -en "\n/" ) \ + | ${SQLPLUS} >/dev/null || break +done +echo -e "BEGIN io.close(0); END;\n/" \ + | ${SQLPLUS} > /dev/null +) <&0 >&1 & + + +# File read if requested +( +while true; do + files="$(echo "SELECT path FROM file_io WHERE in_or_out = 'in';" \ + | ${SQLPLUS} 2>/dev/null \ + | grep -v "^no rows selected")" || break + for f in ${files}; do + if [ ! -r ${f} ]; then + echo "UPDATE file_io SET error = 'Cannot read ''${f}''' WHERE path = '${f}' AND in_or_out = 'in';" \ + | ${SQLPLUS} >/dev/null + continue; + fi + IFS= read -rd '' content < "${f}" + # sqlplus limits lines to 2499 characters so split the update + # into chunks of the file ORed together over multiple lines + query="UPDATE file_io SET data = TO_CLOB('')" + while [ -n "${content}" ]; do + chunk="${content:0:2000}" + content="${content:${#chunk}}" + chunk="${chunk//\'/\'\'}" + chunk="${chunk//$'\n'/\\n}" + query="${query}"$'\n'" || TO_CLOB('${chunk}')" + done + query="${query}"$'\n'" WHERE path = '${f}' AND in_or_out = 'in';" + echo "${query}" | ${SQLPLUS} > /dev/null + #echo "file read: ${f}: ${?}" + done + sleep 1 +done +) & +FILE_PID=$! + +res=0 +if [ $# -gt 0 ]; then + # If there are command line arguments then run a command and exit + args=$(for a in "$@"; do echo -n "\"$a\" "; done) + echo -e "SELECT mal.MAIN('(${args})') FROM dual;" \ + | ${SQLPLUS} > /dev/null + res=$? +else + # Start main loop in the background + echo "SELECT mal.MAIN() FROM dual;" \ + | ${SQLPLUS} > /dev/null + res=$? +fi +# Wait for output to flush +wait ${STDOUT_PID} +exit ${res} diff --git a/impls/plsql/wrap.sh b/impls/plsql/wrap.sh deleted file mode 100755 index c106ecb98b..0000000000 --- a/impls/plsql/wrap.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env bash - -RL_HISTORY_FILE=${HOME}/.mal-history -SKIP_INIT="${SKIP_INIT:-}" - -ORACLE_LOGON=${ORACLE_LOGON:-system/oracle} -SQLPLUS="sqlplus -S ${ORACLE_LOGON}" - -FILE_PID= -cleanup() { - trap - TERM QUIT INT EXIT - #echo cleanup: ${FILE_PID} - [ "${FILE_PID}" ] && kill ${FILE_PID} -} -trap "cleanup" TERM QUIT INT EXIT - - -# Load the SQL code -if [ -z "${SKIP_INIT}" ]; then - out=$(echo "" | ${SQLPLUS} @$1) - if echo "${out}" | grep -vs "^No errors.$" \ - | grep -si error >/dev/null; then - #if echo "${out}" | grep -si error >/dev/null; then - echo "${out}" - exit 1 - fi -fi - -# open I/O streams -echo -e "BEGIN io.open(0); io.open(1); END;\n/" \ - | ${SQLPLUS} >/dev/null - -# Stream from table to stdout -( -while true; do - out="$(echo "SELECT io.read(1) FROM dual;" \ - | ${SQLPLUS} 2>/dev/null)" || break - #echo "out: [${out}] (${#out})" - echo "${out}" -done -) & -STDOUT_PID=$! - -# Perform readline input into stream table when requested -( -[ -r ${RL_HISTORY_FILE} ] && history -r ${RL_HISTORY_FILE} -while true; do - prompt=$(echo "SELECT io.wait_rl_prompt(0) FROM dual;" \ - | ${SQLPLUS} 2>/dev/null) || break - # Prompt is returned single-quoted because sqlplus trims trailing - # whitespace. Remove the single quotes from the beginning and end: - prompt=${prompt%\'} - prompt=${prompt#\'} - #echo "prompt: [${prompt}]" - - IFS= read -u 0 -r -e -p "${prompt}" line || break - if [ "${line}" ]; then - history -s -- "${line}" # add to history - history -a ${RL_HISTORY_FILE} # save history to file - fi - - # Escape (double) single quotes per SQL norm - line=${line//\'/\'\'} - #echo "line: [${line}]" - ( echo -n "BEGIN io.writeline('${line}', 0); END;"; - echo -en "\n/" ) \ - | ${SQLPLUS} >/dev/null || break -done -echo -e "BEGIN io.close(0); END;\n/" \ - | ${SQLPLUS} > /dev/null -) <&0 >&1 & - - -# File read if requested -( -while true; do - files="$(echo "SELECT path FROM file_io WHERE in_or_out = 'in';" \ - | ${SQLPLUS} 2>/dev/null \ - | grep -v "^no rows selected")" || break - for f in ${files}; do - if [ ! -r ${f} ]; then - echo "UPDATE file_io SET error = 'Cannot read ''${f}''' WHERE path = '${f}' AND in_or_out = 'in';" \ - | ${SQLPLUS} >/dev/null - continue; - fi - IFS= read -rd '' content < "${f}" - # sqlplus limits lines to 2499 characters so split the update - # into chunks of the file ORed together over multiple lines - query="UPDATE file_io SET data = TO_CLOB('')" - while [ -n "${content}" ]; do - chunk="${content:0:2000}" - content="${content:${#chunk}}" - chunk="${chunk//\'/\'\'}" - chunk="${chunk//$'\n'/\\n}" - query="${query}"$'\n'" || TO_CLOB('${chunk}')" - done - query="${query}"$'\n'" WHERE path = '${f}' AND in_or_out = 'in';" - echo "${query}" | ${SQLPLUS} > /dev/null - #echo "file read: ${f}: ${?}" - done - sleep 1 -done -) & -FILE_PID=$! - -res=0 -shift -if [ $# -gt 0 ]; then - # If there are command line arguments then run a command and exit - args=$(for a in "$@"; do echo -n "\"$a\" "; done) - echo -e "SELECT mal.MAIN('(${args})') FROM dual;" \ - | ${SQLPLUS} > /dev/null - res=$? -else - # Start main loop in the background - echo "SELECT mal.MAIN() FROM dual;" \ - | ${SQLPLUS} > /dev/null - res=$? -fi -# Wait for output to flush -wait ${STDOUT_PID} -exit ${res} diff --git a/impls/powershell/run b/impls/powershell/run index 7adde42817..4687eac282 100755 --- a/impls/powershell/run +++ b/impls/powershell/run @@ -1,2 +1,3 @@ #!/bin/sh -exec powershell $(dirname $0)/${STEP:-stepA_mal}.ps1 "${@}" +set -Cefu +exec powershell ./${STEP:-stepA_mal}.ps1 "$@" diff --git a/impls/prolog/run b/impls/prolog/run index 6a9b5f1fe4..fa8ca18ff3 100755 --- a/impls/prolog/run +++ b/impls/prolog/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec swipl $(dirname $0)/${STEP:-stepA_mal}.pl "${@}" +#!/bin/sh +set -Cefu +exec swipl ${STEP:-stepA_mal}.pl "$@" diff --git a/impls/ps/run b/impls/ps/run index a961d13c7f..2887396e2e 100755 --- a/impls/ps/run +++ b/impls/ps/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec gs -q -I$(dirname $0) -dNOSAFER -dNODISPLAY -- $(dirname $0)/${STEP:-stepA_mal}.ps "${@}" +#!/bin/sh +set -Cefu +exec gs -q -I. -dNOSAFER -dNODISPLAY -- ${STEP:-stepA_mal}.ps "$@" diff --git a/impls/purs/Makefile b/impls/purs/Makefile index 5de690be1b..bfa9227cfa 100644 --- a/impls/purs/Makefile +++ b/impls/purs/Makefile @@ -1,35 +1,16 @@ -BINS = step0_repl.js step1_read_print.js step2_eval.js step3_env.js \ - step4_if_fn_do.js step5_tco.js step6_file.js step7_quote.js \ - step8_macros.js step9_try.js stepA_mal.js - -OTHER_SRCS = src/Readline.js src/Readline.purs src/Types.purs src/Reader.purs \ - src/Printer.purs src/Env.purs src/Core.purs - +sources := $(wildcard src/*) +BIN_SRCS := $(filter src/step%.purs,$(sources)) +OTHER_SRCS := $(filter-out src/step%.purs,$(sources)) +BINS := $(BIN_SRCS:src/step%.purs=step%.js) all: $(BINS) -$(BINS): %.js: src/%.purs $(OTHER_SRCS) node_modules/readline-sync - spago bundle-app --main $($(<:src/%=%)) --to $@ - +$(BINS): step%.js: src/step%.purs $(OTHER_SRCS) node_modules/readline-sync + spago bundle-app --main Mal.Step$(firstword $(subst _, ,$*)) --to $@ node_modules/readline-sync: npm install - -##################### - -step0_repl.purs = Mal.Step0 -step1_read_print.purs = Mal.Step1 -step2_eval.purs = Mal.Step2 -step3_env.purs = Mal.Step3 -step4_if_fn_do.purs = Mal.Step4 -step5_tco.purs = Mal.Step5 -step6_file.purs = Mal.Step6 -step7_quote.purs = Mal.Step7 -step8_macros.purs = Mal.Step8 -step9_try.purs = Mal.Step9 -stepA_mal.purs = Mal.StepA - - clean: - rm -rf step*.js output/* \ No newline at end of file + rm -f $(BINS) + rm -fr output/ diff --git a/impls/purs/run b/impls/purs/run index 510f226881..d1135e76d4 100755 --- a/impls/purs/run +++ b/impls/purs/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec node $(dirname $0)/${STEP:-stepA_mal}.js "${@}" \ No newline at end of file +#!/bin/sh +set -Cefu +exec node ${STEP:-stepA_mal}.js "$@" diff --git a/impls/python2/run b/impls/python2/run index 095e1963d0..69c9dc7644 100755 --- a/impls/python2/run +++ b/impls/python2/run @@ -1,2 +1,3 @@ #!/bin/sh -exec python2 $(dirname $0)/${STEP:-stepA_mal}.py "${@}" +set -Cefu +exec python2 ${STEP:-stepA_mal}.py "$@" diff --git a/impls/python3/run b/impls/python3/run index 1e7632cd57..e57219fcae 100755 --- a/impls/python3/run +++ b/impls/python3/run @@ -1,2 +1,3 @@ #!/bin/sh -exec python3 $(dirname $0)/${STEP:-stepA_mal}.py "${@}" +set -Cefu +exec python3 ${STEP:-stepA_mal}.py "$@" diff --git a/impls/r/run b/impls/r/run index 916876f09d..3d8166379b 100755 --- a/impls/r/run +++ b/impls/r/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec Rscript $(dirname $0)/${STEP:-stepA_mal}.r "${@}" +#!/bin/sh +set -Cefu +exec Rscript ${STEP:-stepA_mal}.r "$@" diff --git a/impls/racket/run b/impls/racket/run index fa0719bdce..72658cfba8 100755 --- a/impls/racket/run +++ b/impls/racket/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec racket $(dirname $0)/${STEP:-stepA_mal}.rkt "${@}" +#!/bin/sh +set -Cefu +exec racket ${STEP:-stepA_mal}.rkt "$@" diff --git a/impls/racket/step0_repl.rkt b/impls/racket/step0_repl.rkt old mode 100755 new mode 100644 index 643d132fa2..8cd3913fa9 --- a/impls/racket/step0_repl.rkt +++ b/impls/racket/step0_repl.rkt @@ -1,4 +1,3 @@ -#!/usr/bin/env racket #lang racket (require "readline.rkt" "types.rkt") diff --git a/impls/racket/step1_read_print.rkt b/impls/racket/step1_read_print.rkt old mode 100755 new mode 100644 index a5d8ac7761..53a64b4382 --- a/impls/racket/step1_read_print.rkt +++ b/impls/racket/step1_read_print.rkt @@ -1,4 +1,3 @@ -#!/usr/bin/env racket #lang racket (require "readline.rkt" "types.rkt" "reader.rkt" "printer.rkt") diff --git a/impls/racket/step2_eval.rkt b/impls/racket/step2_eval.rkt old mode 100755 new mode 100644 index 7ea1ce8f5d..08ac5a2ee6 --- a/impls/racket/step2_eval.rkt +++ b/impls/racket/step2_eval.rkt @@ -1,4 +1,3 @@ -#!/usr/bin/env racket #lang racket (require "types.rkt" "readline.rkt" "reader.rkt" "printer.rkt") diff --git a/impls/racket/step3_env.rkt b/impls/racket/step3_env.rkt old mode 100755 new mode 100644 index 8ecd818507..469e07fb8f --- a/impls/racket/step3_env.rkt +++ b/impls/racket/step3_env.rkt @@ -1,4 +1,3 @@ -#!/usr/bin/env racket #lang racket (require "readline.rkt" "types.rkt" "reader.rkt" "printer.rkt" diff --git a/impls/racket/step4_if_fn_do.rkt b/impls/racket/step4_if_fn_do.rkt old mode 100755 new mode 100644 index 44af35c119..28a46b18e2 --- a/impls/racket/step4_if_fn_do.rkt +++ b/impls/racket/step4_if_fn_do.rkt @@ -1,4 +1,3 @@ -#!/usr/bin/env racket #lang racket (require "readline.rkt" "types.rkt" "reader.rkt" "printer.rkt" diff --git a/impls/racket/step5_tco.rkt b/impls/racket/step5_tco.rkt old mode 100755 new mode 100644 index 880e05ae5c..2d2f3defaf --- a/impls/racket/step5_tco.rkt +++ b/impls/racket/step5_tco.rkt @@ -1,4 +1,3 @@ -#!/usr/bin/env racket #lang racket (require "readline.rkt" "types.rkt" "reader.rkt" "printer.rkt" diff --git a/impls/racket/step6_file.rkt b/impls/racket/step6_file.rkt old mode 100755 new mode 100644 index 6e1645bce9..783978ed61 --- a/impls/racket/step6_file.rkt +++ b/impls/racket/step6_file.rkt @@ -1,4 +1,3 @@ -#!/usr/bin/env racket #lang racket (require "readline.rkt" "types.rkt" "reader.rkt" "printer.rkt" diff --git a/impls/racket/step7_quote.rkt b/impls/racket/step7_quote.rkt old mode 100755 new mode 100644 index d9257f4889..f61aa7d000 --- a/impls/racket/step7_quote.rkt +++ b/impls/racket/step7_quote.rkt @@ -1,4 +1,3 @@ -#!/usr/bin/env racket #lang racket (require "readline.rkt" "types.rkt" "reader.rkt" "printer.rkt" diff --git a/impls/racket/step8_macros.rkt b/impls/racket/step8_macros.rkt old mode 100755 new mode 100644 index 864093047e..88a6d36567 --- a/impls/racket/step8_macros.rkt +++ b/impls/racket/step8_macros.rkt @@ -1,4 +1,3 @@ -#!/usr/bin/env racket #lang racket (require "readline.rkt" "types.rkt" "reader.rkt" "printer.rkt" diff --git a/impls/racket/step9_try.rkt b/impls/racket/step9_try.rkt old mode 100755 new mode 100644 index c8534d3b2b..ad42d983dc --- a/impls/racket/step9_try.rkt +++ b/impls/racket/step9_try.rkt @@ -1,4 +1,3 @@ -#!/usr/bin/env racket #lang racket (require "readline.rkt" "types.rkt" "reader.rkt" "printer.rkt" diff --git a/impls/racket/stepA_mal.rkt b/impls/racket/stepA_mal.rkt old mode 100755 new mode 100644 index c94bb80137..83cb4d13aa --- a/impls/racket/stepA_mal.rkt +++ b/impls/racket/stepA_mal.rkt @@ -1,4 +1,3 @@ -#!/usr/bin/env racket #lang racket (require "readline.rkt" "types.rkt" "reader.rkt" "printer.rkt" diff --git a/impls/rexx/run b/impls/rexx/run index b911329610..307605eaae 100755 --- a/impls/rexx/run +++ b/impls/rexx/run @@ -1,2 +1,3 @@ #!/bin/sh -exec rexx -a $(dirname $0)/${STEP:-stepA_mal}.rexxpp "${@}" +set -Cefu +exec rexx -a ${STEP:-stepA_mal}.rexxpp "$@" diff --git a/impls/rpython/run b/impls/rpython/run index c66c2b81dc..5ffd062744 100755 --- a/impls/rpython/run +++ b/impls/rpython/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/ruby.2/run b/impls/ruby.2/run index 980db0d659..af3ef3ab4e 100755 --- a/impls/ruby.2/run +++ b/impls/ruby.2/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec ruby $(dirname $0)/${STEP:-stepA_mal}.rb "${@}" +#!/bin/sh +set -Cefu +exec ruby ${STEP:-stepA_mal}.rb "$@" diff --git a/impls/ruby/run b/impls/ruby/run index 980db0d659..af3ef3ab4e 100755 --- a/impls/ruby/run +++ b/impls/ruby/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec ruby $(dirname $0)/${STEP:-stepA_mal}.rb "${@}" +#!/bin/sh +set -Cefu +exec ruby ${STEP:-stepA_mal}.rb "$@" diff --git a/impls/rust/run b/impls/rust/run index d67524c747..46e9ab2269 100755 --- a/impls/rust/run +++ b/impls/rust/run @@ -1,2 +1,3 @@ #!/bin/sh -exec $(dirname $0)/target/release/${STEP:-stepA_mal} "${@}" +set -Cefu +exec target/release/${STEP:-stepA_mal} "$@" diff --git a/impls/scala/run b/impls/scala/run index eb06292ab5..57b25b1e65 100755 --- a/impls/scala/run +++ b/impls/scala/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec java -classpath "$(dirname $0)/target/scala-2.11/mal.jar" "${STEP:-stepA_mal}" "$@" +#!/bin/sh +set -Cefu +exec java -classpath target/scala-2.11/mal.jar ${STEP:-stepA_mal} "$@" diff --git a/impls/scheme/run b/impls/scheme/run index 8cfd055ae2..ab089dc050 100755 --- a/impls/scheme/run +++ b/impls/scheme/run @@ -1,26 +1,30 @@ -#!/usr/bin/env bash -basedir=$(dirname $0) +#!/bin/sh +set -Cefu step=${STEP:-stepA_mal} -if [[ -e /usr/share/kawa/lib/kawa.jar ]]; then - kawa=/usr/share/kawa/lib/kawa.jar -elif [[ -e /usr/local/share/kawa/lib/kawa.jar ]]; then - kawa=/usr/local/share/kawa/lib/kawa.jar -fi - -if [[ $(which sash 2>/dev/null) ]]; then - sagittarius=sash -elif [[ $(which sagittarius 2>/dev/null) ]]; then - sagittarius=sagittarius -fi - case ${scheme_MODE:-chibi} in - chibi) exec chibi-scheme -I$basedir $basedir/$step.scm "${@}" ;; - kawa) exec java -cp $kawa:$basedir/out $step "${@}" ;; - gauche) exec gosh -I$basedir $basedir/$step.scm "${@}" ;; - chicken) CHICKEN_REPOSITORY=$basedir/eggs exec $basedir/$step "${@}" ;; - sagittarius) exec $sagittarius -n -L$basedir $basedir/$step.scm "${@}" ;; - cyclone) exec $basedir/$step "${@}" ;; - foment) exec foment $basedir/$step.scm "${@}" ;; - *) echo "Invalid scheme_MODE: ${scheme_MODE}"; exit 2 ;; + chibi) exec chibi-scheme $step.scm "$@" ;; + kawa) if [ -e /usr/share/kawa/lib/kawa.jar ]; then + kawa=/usr/share/kawa/lib/kawa.jar + elif [ -e /usr/local/share/kawa/lib/kawa.jar ]; then + kawa=/usr/local/share/kawa/lib/kawa.jar + else + echo >&2 'Failed to find kawa.jar.' + exit 1 + fi + exec java -cp $kawa:out $step "$@" ;; + gauche) exec gosh -I. $step.scm "$@" ;; + chicken) CHICKEN_REPOSITORY=eggs exec ./$step "$@" ;; + sagittarius) if command -v sash >/dev/null 2>&1; then + sagittarius=sash + elif command -v sagittarius >/dev/null 2>&1; then + sagittarius=sagittarius + else + echo >&2 'Failed to find sash or sagittarius.' + exit 1 + fi + exec $sagittarius -n -L. $step.scm "$@" ;; + cyclone) exec ./$step "$@" ;; + foment) exec foment $step.scm "$@" ;; + *) echo "Invalid scheme_MODE: $scheme_MODE"; exit 2 ;; esac diff --git a/impls/skew/run b/impls/skew/run index 1148122a23..d1135e76d4 100755 --- a/impls/skew/run +++ b/impls/skew/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec node $(dirname $0)/${STEP:-stepA_mal}.js "${@}" +#!/bin/sh +set -Cefu +exec node ${STEP:-stepA_mal}.js "$@" diff --git a/impls/sml/run b/impls/sml/run index c66c2b81dc..5ffd062744 100755 --- a/impls/sml/run +++ b/impls/sml/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/swift3/run b/impls/swift3/run index c66c2b81dc..5ffd062744 100755 --- a/impls/swift3/run +++ b/impls/swift3/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/swift4/run b/impls/swift4/run index c66c2b81dc..5ffd062744 100755 --- a/impls/swift4/run +++ b/impls/swift4/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/swift6/run b/impls/swift6/run index 8003dd69cb..5163410dfe 100755 --- a/impls/swift6/run +++ b/impls/swift6/run @@ -1,2 +1,3 @@ #!/bin/sh -exec $(dirname $0)/.build/${STEP:-stepA_mal} "${@}" +set -Cefu +exec .build/${STEP:-stepA_mal} "$@" diff --git a/impls/tcl/run b/impls/tcl/run index 700b5291b0..be3858ef90 100755 --- a/impls/tcl/run +++ b/impls/tcl/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec tclsh $(dirname $0)/${STEP:-stepA_mal}.tcl ${RAW:+--raw} "${@}" +#!/bin/sh +set -Cefu +exec tclsh ${STEP:-stepA_mal}.tcl ${RAW:+--raw} "$@" diff --git a/impls/tests/run_argv_test.sh b/impls/tests/run_argv_test.sh index e3682e4f9f..25859019ef 100755 --- a/impls/tests/run_argv_test.sh +++ b/impls/tests/run_argv_test.sh @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +#!/bin/sh +set -Cefu # # Usage: run_argv_test.sh @@ -21,7 +22,7 @@ if [ -z "$1" ] ; then exit 1 fi -root="$(dirname $0)" +root=../tests out="$( $@ $root/print_argv.mal aaa bbb ccc | tr -d '\r' )" assert_equal '("aaa" "bbb" "ccc")' "$out" diff --git a/impls/ts/run b/impls/ts/run index 1148122a23..d1135e76d4 100755 --- a/impls/ts/run +++ b/impls/ts/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec node $(dirname $0)/${STEP:-stepA_mal}.js "${@}" +#!/bin/sh +set -Cefu +exec node ${STEP:-stepA_mal}.js "$@" diff --git a/impls/vala/run b/impls/vala/run index c66c2b81dc..5ffd062744 100755 --- a/impls/vala/run +++ b/impls/vala/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" diff --git a/impls/vb/run b/impls/vb/run index 5c5642646f..8ea6fdbea1 100755 --- a/impls/vb/run +++ b/impls/vb/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec mono $(dirname $0)/${STEP:-stepA_mal}.exe ${RAW:+--raw} "${@}" +#!/bin/sh +set -Cefu +exec mono ${STEP:-stepA_mal}.exe ${RAW:+--raw} "$@" diff --git a/impls/vbs/run b/impls/vbs/run old mode 100644 new mode 100755 index 3c1aed2dd3..d225cb3a44 --- a/impls/vbs/run +++ b/impls/vbs/run @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +#!/bin/sh +set -Cefu MAL_VBS_IMPL_NO_STDERR=1 MAL_VBS_IMPL_ECHO_STDIN=1 \ WSLENV=MAL_VBS_IMPL_NO_STDERR/w:MAL_VBS_IMPL_ECHO_STDIN/w \ -cscript.exe -nologo "`wslpath -w "$(dirname $0)/${STEP:-stepA_mal}.vbs"`" "${@}" \ No newline at end of file +exec cscript.exe -nologo ${STEP:-stepA_mal}.vbs "$@" diff --git a/impls/vhdl/Makefile b/impls/vhdl/Makefile index e76b8e104a..5e9fe86a7d 100644 --- a/impls/vhdl/Makefile +++ b/impls/vhdl/Makefile @@ -32,4 +32,4 @@ $(BINS): %: %.o if [ "$@" = "stepA_mal" ]; then mv stepa_mal $@; fi clean: - rm -f $(OBJS) $(BINS) $(OTHER_OBJS) work-obj93.cf mal + rm -f $(OBJS) $(BINS) $(OTHER_OBJS) work-obj93.cf mal vhdl_argv.tmp diff --git a/impls/vhdl/run b/impls/vhdl/run index ca50d3f82b..5201cee735 100755 --- a/impls/vhdl/run +++ b/impls/vhdl/run @@ -1,2 +1,13 @@ -#!/usr/bin/env bash -exec $(dirname $0)/run_vhdl.sh $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -efu + +# ghdl doesn't allow passing command-line arguments to the VHDL program. To +# circumvent that, we write the command-line arguments as lines in +# vhdl_argv.tmp, and read the content of that file at the beginning of the VHDL +# program. + +for arg; do + echo "$arg" +done > vhdl_argv.tmp + +exec ./${STEP:-stepA_mal} diff --git a/impls/vhdl/run_vhdl.sh b/impls/vhdl/run_vhdl.sh deleted file mode 100755 index 1cc8e3bf9f..0000000000 --- a/impls/vhdl/run_vhdl.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -# ghdl doesn't allow passing command-line arguments to the VHDL program. To -# circumvent that, we write the command-line arguments as lines in -# vhdl_argv.tmp, and read the content of that file at the beginning of the VHDL -# program. - -cleanup() { - trap - TERM QUIT INT EXIT - rm -f vhdl_argv.tmp -} -trap "cleanup" TERM QUIT INT EXIT - -bin="$1" -shift - -for arg in "$@" ; do - echo "$arg" -done > vhdl_argv.tmp - -$bin diff --git a/impls/vimscript/run b/impls/vimscript/run index 007df20bdf..2cb7a320b4 100755 --- a/impls/vimscript/run +++ b/impls/vimscript/run @@ -1,3 +1,16 @@ -#!/usr/bin/env bash -cd $(dirname $0) -exec ./run_vimscript.sh ./${STEP:-stepA_mal}.vim "${@}" +#!/bin/sh +set -Cefu + +# Run Vim in ex mode (-e) and run the given script ($1) on startup. Our scripts +# end with 'qall!' which causes actual Vim UI to never start up. +# +# Set environment variable DEBUG=1 to allow more verbose error output from Vim. +# +# See: http://vim.wikia.com/wiki/Vim_as_a_system_interpreter_for_vimscript + +export LD_LIBRARY_PATH=. +vimscriptfile=${STEP:-stepA_mal}.vim +if [ -n "${DEBUG:-}" ] ; then + exec 2> /dev/null +fi +exec vim -i NONE -V1 -nNesS $vimscriptfile -- "$@" | cat diff --git a/impls/vimscript/run_vimscript.sh b/impls/vimscript/run_vimscript.sh deleted file mode 100755 index cf263c8f7f..0000000000 --- a/impls/vimscript/run_vimscript.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -# Run Vim in ex mode (-e) and run the given script ($1) on startup. Our scripts -# end with 'qall!' which causes actual Vim UI to never start up. -# -# Set environment variable DEBUG=1 to allow more verbose error output from Vim. -# -# See: http://vim.wikia.com/wiki/Vim_as_a_system_interpreter_for_vimscript - -rundir=`dirname $0` -export LD_LIBRARY_PATH=`readlink -f $rundir` -vimscriptfile="$1" -shift -if [ x$DEBUG = x ] ; then - exec 2> /dev/null -fi -exec vim -i NONE -V1 -nNesS $vimscriptfile -- "$@" | cat diff --git a/impls/wasm/run b/impls/wasm/run index 7d4fed5185..5958c5be40 100755 --- a/impls/wasm/run +++ b/impls/wasm/run @@ -1,18 +1,18 @@ -#!/usr/bin/env bash -STEP=${STEP:-stepA_mal} -case "${wasm_MODE}" in +#!/bin/sh +set -Cefu +case ${wasm_MODE:-js} in wasmtime) - exec wasmtime --dir=./ --dir=../ --dir=/ $(dirname $0)/${STEP:-stepA_mal}.wasm "${@}" ;; + exec wasmtime --dir=./ --dir=../ --dir=/ ${STEP:-stepA_mal}.wasm "$@" ;; wasmer) - exec wasmer run --dir=./ --dir=../ --dir=/ $(dirname $0)/${STEP:-stepA_mal}.wasm -- "${@}" ;; + exec wasmer run --dir=./ --dir=../ --dir=/ ${STEP:-stepA_mal}.wasm -- "$@" ;; warpy) - exec warpy --argv --memory-pages 256 $(dirname $0)/${STEP:-stepA_mal}.wasm "${@}" ;; + exec warpy --argv --memory-pages 256 ${STEP:-stepA_mal}.wasm "$@" ;; wax) - exec wax $(dirname $0)/${STEP:-stepA_mal}.wasm "${@}" ;; + exec wax ${STEP:-stepA_mal}.wasm "$@" ;; wace_libc) - exec wace $(dirname $0)/${STEP:-stepA_mal}.wasm "${@}" ;; + exec wace ${STEP:-stepA_mal}.wasm "$@" ;; wace_fooboot) echo >&2 "wace_fooboot mode not yet supported" ;; node|js|*) - exec ./run.js $(dirname $0)/${STEP:-stepA_mal}.wasm "${@}" ;; + exec node run.js ${STEP:-stepA_mal}.wasm "$@" ;; esac diff --git a/impls/wasm/run.js b/impls/wasm/run.js old mode 100755 new mode 100644 index 2deaa5e53c..59a705583d --- a/impls/wasm/run.js +++ b/impls/wasm/run.js @@ -1,5 +1,3 @@ -#!/usr/bin/env node - // Copyright Joel Martin // License MIT @@ -128,7 +126,7 @@ async function loadWebAssembly(filename, args) { async function main() { assert(process.argv.length >= 3, - 'Usage: ./run.js prog.wasm [ARGS...]') + 'Usage: node run.js prog.wasm [ARGS...]') const wasm = process.argv[2] const args = process.argv.slice(2) diff --git a/impls/wren/run b/impls/wren/run index 8c269bf55a..5709bd1b38 100755 --- a/impls/wren/run +++ b/impls/wren/run @@ -1,2 +1,3 @@ -#!/usr/bin/env bash -exec wren $(dirname $0)/${STEP:-stepA_mal}.wren "${@}" +#!/bin/sh +set -Cefu +exec wren ${STEP:-stepA_mal}.wren "$@" diff --git a/impls/yorick/run b/impls/yorick/run index 78b865fca2..4431fca9b8 100755 --- a/impls/yorick/run +++ b/impls/yorick/run @@ -1,3 +1,3 @@ -#!/usr/bin/env bash -export YORICK_MAL_PATH="$(dirname $0)" -exec yorick -batch "$YORICK_MAL_PATH/${STEP:-stepA_mal}.i" "${@}" +#!/bin/sh +set -Cefu +exec yorick -batch ${STEP:-stepA_mal}.i "$@" diff --git a/impls/yorick/step1_read_print.i b/impls/yorick/step1_read_print.i index 8a97cb8cf1..8d4bde5320 100644 --- a/impls/yorick/step1_read_print.i +++ b/impls/yorick/step1_read_print.i @@ -1,4 +1,3 @@ -set_path, get_env("YORICK_MAL_PATH") + ":" + get_path() require, "reader.i" require, "printer.i" diff --git a/impls/yorick/step2_eval.i b/impls/yorick/step2_eval.i index 40730a4967..984679c68b 100644 --- a/impls/yorick/step2_eval.i +++ b/impls/yorick/step2_eval.i @@ -1,4 +1,3 @@ -set_path, get_env("YORICK_MAL_PATH") + ":" + get_path() require, "reader.i" require, "printer.i" require, "core.i" diff --git a/impls/yorick/step3_env.i b/impls/yorick/step3_env.i index 604fb35a20..845ce2572d 100644 --- a/impls/yorick/step3_env.i +++ b/impls/yorick/step3_env.i @@ -1,4 +1,3 @@ -set_path, get_env("YORICK_MAL_PATH") + ":" + get_path() require, "reader.i" require, "printer.i" require, "core.i" diff --git a/impls/yorick/step4_if_fn_do.i b/impls/yorick/step4_if_fn_do.i index 6dac870716..a1bd63e183 100644 --- a/impls/yorick/step4_if_fn_do.i +++ b/impls/yorick/step4_if_fn_do.i @@ -1,4 +1,3 @@ -set_path, get_env("YORICK_MAL_PATH") + ":" + get_path() require, "reader.i" require, "printer.i" require, "core.i" diff --git a/impls/yorick/step5_tco.i b/impls/yorick/step5_tco.i index a9c8ffd96b..4f2011e7f7 100644 --- a/impls/yorick/step5_tco.i +++ b/impls/yorick/step5_tco.i @@ -1,4 +1,3 @@ -set_path, get_env("YORICK_MAL_PATH") + ":" + get_path() require, "reader.i" require, "printer.i" require, "core.i" diff --git a/impls/yorick/step6_file.i b/impls/yorick/step6_file.i index 9780f11926..843c08f024 100644 --- a/impls/yorick/step6_file.i +++ b/impls/yorick/step6_file.i @@ -1,4 +1,3 @@ -set_path, get_env("YORICK_MAL_PATH") + ":" + get_path() require, "reader.i" require, "printer.i" require, "core.i" diff --git a/impls/yorick/step7_quote.i b/impls/yorick/step7_quote.i index 4cd664ac38..c8eb843655 100644 --- a/impls/yorick/step7_quote.i +++ b/impls/yorick/step7_quote.i @@ -1,4 +1,3 @@ -set_path, get_env("YORICK_MAL_PATH") + ":" + get_path() require, "reader.i" require, "printer.i" require, "core.i" diff --git a/impls/yorick/step8_macros.i b/impls/yorick/step8_macros.i index 0060ecec7e..1ffcf9fe18 100644 --- a/impls/yorick/step8_macros.i +++ b/impls/yorick/step8_macros.i @@ -1,4 +1,3 @@ -set_path, get_env("YORICK_MAL_PATH") + ":" + get_path() require, "reader.i" require, "printer.i" require, "core.i" diff --git a/impls/yorick/step9_try.i b/impls/yorick/step9_try.i index 73df6647b9..f3e2308c9a 100644 --- a/impls/yorick/step9_try.i +++ b/impls/yorick/step9_try.i @@ -1,4 +1,3 @@ -set_path, get_env("YORICK_MAL_PATH") + ":" + get_path() require, "reader.i" require, "printer.i" require, "core.i" diff --git a/impls/yorick/stepA_mal.i b/impls/yorick/stepA_mal.i index 5251fafe8c..3205838d51 100644 --- a/impls/yorick/stepA_mal.i +++ b/impls/yorick/stepA_mal.i @@ -1,4 +1,3 @@ -set_path, get_env("YORICK_MAL_PATH") + ":" + get_path() require, "reader.i" require, "printer.i" require, "core.i" diff --git a/impls/zig/run b/impls/zig/run index 35613af46a..048ef39072 100755 --- a/impls/zig/run +++ b/impls/zig/run @@ -1,2 +1,3 @@ #!/bin/sh -exec $(dirname $0)/zig-out/bin/${STEP:-stepA_mal} "${@}" +set -Cefu +exec zig-out/bin/${STEP:-stepA_mal} "$@" diff --git a/process/guide.md b/process/guide.md index bda640206d..f8ec3f1c59 100644 --- a/process/guide.md +++ b/process/guide.md @@ -113,18 +113,31 @@ quux_STEP_TO_PROG = impls/quux/$($(1)).qx the "STEP" environment variable for the implementation step to run and defaults to "stepA_mal". Make sure the run script has the executable file permission set (or else the test runner might fail with a - permission denied error message). The following are examples of "run" + permission denied error message). + + In order to disambiguate relative paths in command line arguments, + library search paths and so on, "run" will by convention always + executed in the implementation directory. + +``` +cd impls/quux +./run ../tests/step0_repl.mal +``` + + The following are examples of "run" scripts for a compiled language and an interpreted language (where the interpreter is named "quux"): ``` -#!/usr/bin/env bash -exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +#!/bin/sh +set -Cefu +exec ./${STEP:-stepA_mal} "$@" ``` ``` -#!/usr/bin/env bash -exec quux $(dirname $0)/${STEP:-stepA_mal}.qx "${@}" +#!/bin/sh +set -Cefu +exec quux ${STEP:-stepA_mal}.qx "$@" ``` This allows you to run tests against your implementation like this: