aboutsummaryrefslogtreecommitdiff
path: root/bash/step1_read_print.sh
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-19 13:04:09 -0500
committerJoel Martin <github@martintribe.org>2014-04-19 13:04:09 -0500
commit86b689f3d7111a9fa13da389a30f3dfdf877d1a4 (patch)
treed72b065f9f987e291f892ceee5a8640363bfd9df /bash/step1_read_print.sh
parent718887c3019c49fc807bc18fbd5feb975ec03c85 (diff)
downloadmal-86b689f3d7111a9fa13da389a30f3dfdf877d1a4.tar.gz
mal-86b689f3d7111a9fa13da389a30f3dfdf877d1a4.zip
All: *ARGV* and *host-language*. Misc syncing/fixes.
Diffstat (limited to 'bash/step1_read_print.sh')
-rwxr-xr-xbash/step1_read_print.sh21
1 files changed, 9 insertions, 12 deletions
diff --git a/bash/step1_read_print.sh b/bash/step1_read_print.sh
index ca852ed..e7ca283 100755
--- a/bash/step1_read_print.sh
+++ b/bash/step1_read_print.sh
@@ -1,17 +1,15 @@
#!/bin/bash
-INTERACTIVE=${INTERACTIVE-yes}
-
source $(dirname $0)/reader.sh
source $(dirname $0)/printer.sh
-# READ: read and parse input
+# read
READ () {
[ "${1}" ] && r="${1}" || READLINE
READ_STR "${r}"
}
-# EVAL: just return the input
+# eval
EVAL () {
local ast="${1}"
local env="${2}"
@@ -20,7 +18,7 @@ EVAL () {
r="${ast}"
}
-# PRINT:
+# print
PRINT () {
if [[ "${__ERROR}" ]]; then
_pr_str "${__ERROR}" yes
@@ -31,16 +29,15 @@ PRINT () {
fi
}
-# REPL: read, eval, print, loop
+# repl
REP () {
READ "${1}" || return 1
EVAL "${r}"
PRINT "${r}"
}
-if [[ -n "${INTERACTIVE}" ]]; then
- while true; do
- READLINE "user> " || exit "$?"
- [[ "${r}" ]] && REP "${r}" && echo "${r}"
- done
-fi
+# repl loop
+while true; do
+ READLINE "user> " || exit "$?"
+ [[ "${r}" ]] && REP "${r}" && echo "${r}"
+done