diff options
Diffstat (limited to 'bash')
| -rwxr-xr-x | bash/step6_file.sh | 11 | ||||
| -rwxr-xr-x | bash/step7_quote.sh | 11 | ||||
| -rwxr-xr-x | bash/step8_macros.sh | 11 | ||||
| -rwxr-xr-x | bash/step9_interop.sh | 11 | ||||
| -rwxr-xr-x | bash/stepA_more.sh | 11 |
5 files changed, 35 insertions, 20 deletions
diff --git a/bash/step6_file.sh b/bash/step6_file.sh index 9656125..1c8fab5 100755 --- a/bash/step6_file.sh +++ b/bash/step6_file.sh @@ -150,14 +150,17 @@ read_string () { READ_STR "${ANON["${1}"]}"; } _fref "read-string" read_string _eval () { EVAL "${1}" "${REPL_ENV}"; } _fref "eval" _eval -slurp () { string "$(cat "${ANON["${1}"]}")"; } +slurp () { + local lines + mapfile lines < "${ANON["${1}"]}" + local text="${lines[*]}"; text=${text//$'\n' /$'\n'} + string "${text}" +} _fref "slurp" slurp -slurp_do () { string "(do $(cat "${ANON["${1}"]}"))"; } -_fref "slurp-do" slurp_do # Defined using the language itself REP "(def! not (fn* (a) (if a false true)))" -REP "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))" +REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" if [[ "${1}" ]]; then echo "${@}" diff --git a/bash/step7_quote.sh b/bash/step7_quote.sh index 4bb74ba..cecc3b8 100755 --- a/bash/step7_quote.sh +++ b/bash/step7_quote.sh @@ -195,14 +195,17 @@ read_string () { READ_STR "${ANON["${1}"]}"; } _fref "read-string" read_string _eval () { EVAL "${1}" "${REPL_ENV}"; } _fref "eval" _eval -slurp () { string "$(cat "${ANON["${1}"]}")"; } +slurp () { + local lines + mapfile lines < "${ANON["${1}"]}" + local text="${lines[*]}"; text=${text//$'\n' /$'\n'} + string "${text}" +} _fref "slurp" slurp -slurp_do () { string "(do $(cat "${ANON["${1}"]}"))"; } -_fref "slurp-do" slurp_do # Defined using the language itself REP "(def! not (fn* (a) (if a false true)))" -REP "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))" +REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" if [[ "${1}" ]]; then echo "${@}" diff --git a/bash/step8_macros.sh b/bash/step8_macros.sh index e86a032..a905958 100755 --- a/bash/step8_macros.sh +++ b/bash/step8_macros.sh @@ -232,14 +232,17 @@ _eval () { EVAL "${1}" "${REPL_ENV}" } _fref "eval" _eval -slurp () { string "$(cat "${ANON["${1}"]}")"; } +slurp () { + local lines + mapfile lines < "${ANON["${1}"]}" + local text="${lines[*]}"; text=${text//$'\n' /$'\n'} + string "${text}" +} _fref "slurp" slurp -slurp_do () { string "(do $(cat "${ANON["${1}"]}"))"; } -_fref "slurp-do" slurp_do # Defined using the language itself REP "(def! not (fn* (a) (if a false true)))" -REP "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))" +REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" if [[ "${1}" ]]; then echo "${@}" diff --git a/bash/step9_interop.sh b/bash/step9_interop.sh index 930aa2e..e1d57f5 100755 --- a/bash/step9_interop.sh +++ b/bash/step9_interop.sh @@ -241,14 +241,17 @@ _eval () { EVAL "${1}" "${REPL_ENV}" } _fref "eval" _eval -slurp () { string "$(cat "${ANON["${1}"]}")"; } +slurp () { + local lines + mapfile lines < "${ANON["${1}"]}" + local text="${lines[*]}"; text=${text//$'\n' /$'\n'} + string "${text}" +} _fref "slurp" slurp -slurp_do () { string "(do $(cat "${ANON["${1}"]}"))"; } -_fref "slurp-do" slurp_do # Defined using the language itself REP "(def! not (fn* (a) (if a false true)))" -REP "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))" +REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" if [[ "${1}" ]]; then echo "${@}" diff --git a/bash/stepA_more.sh b/bash/stepA_more.sh index 8caa72d..0902b57 100755 --- a/bash/stepA_more.sh +++ b/bash/stepA_more.sh @@ -260,16 +260,19 @@ _eval () { EVAL "${1}" "${REPL_ENV}" } _fref "eval" _eval -slurp () { string "$(cat "${ANON["${1}"]}")"; } +slurp () { + local lines + mapfile lines < "${ANON["${1}"]}" + local text="${lines[*]}"; text=${text//$'\n' /$'\n'} + string "${text}" +} _fref "slurp" slurp -slurp_do () { string "(do $(cat "${ANON["${1}"]}"))"; } -_fref "slurp-do" slurp_do # Defined using the language itself REP "(def! not (fn* (a) (if a false true)))" REP "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))" REP "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) \`(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))" -REP "(def! load-file (fn* (f) (eval (read-string (slurp-do f)))))" +REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" if [[ "${1}" ]]; then echo "${@}" |
