1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-11 21:57:38 +03:00
mal/impls/bash
Andy Chu 02028e90a4 impls/bash: Minor changes to make it run under OSH
OSH is a bash-compatible shell: https://www.oilshell.org/

reader.sh:

- Put the constant regex pattern in a string literal.  This simplifies
  it by removing mixed regex vs. shell quoting, and implicit
  concatenation with $'\n'.

  This is suggested by the bash manual:
  https://www.gnu.org/software/bash/manual/bash.html#Conditional-Constructs

  "Storing the regular expression in a shell variable is often a useful
  way to avoid problems with quoting characters that are special to the
  shell."

- Initialize __reader_tokens as an array, not a string.

  https://www.oilshell.org/release/0.8.pre6/doc/known-differences.html#values-are-tagged-with-types-not-cells

env.sh:

Simplify quoting in 'eval' expressions.  This quotes associative array keys,
which is required by OSH to avoid dynamic parsing.

  https://www.oilshell.org/release/0.8.pre6/doc/known-differences.html#strings-vs-bare-words-in-array-indices
  http://www.oilshell.org/blog/2016/10/20.html

core.sh:

Quote associative array keys.  '<' and '>' are shell operators and OSH doesn't
have a special case when inside [].

----

With this change, OSH can run tests just like bash, e.g.:

$ osh impls/bash/stepA_mal.sh tests/step4_if_fn_do.mal

----

Test results are the same before and after this change:

$ NO_DOCKER=1 ./.travis_test.sh test bash

FAILURES:
SOFT FAILED TEST (line 295): (f (+ 1 1)) -> ['',true]:
    Expected : '.*\ntrue'
    Got      : '(f (+ 1 1))\nfalse'

TEST RESULTS (for ../tests/stepA_mal.mal):
    1: soft failing tests
    0: failing tests
  106: passing tests
  107: total tests
2020-06-13 10:57:13 -07:00
..
tests Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
core.sh impls/bash: Minor changes to make it run under OSH 2020-06-13 10:57:13 -07:00
Dockerfile Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
env.sh impls/bash: Minor changes to make it run under OSH 2020-06-13 10:57:13 -07:00
Makefile Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
printer.sh Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
reader.sh impls/bash: Minor changes to make it run under OSH 2020-06-13 10:57:13 -07:00
run Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step0_repl.sh Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step1_read_print.sh Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step2_eval.sh Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step3_env.sh Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step4_if_fn_do.sh Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step5_tco.sh Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step6_file.sh Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step7_quote.sh Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step8_macros.sh Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step9_try.sh Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
stepA_mal.sh Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
types.sh Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00