diff options
| author | Joel Martin <github@martintribe.org> | 2014-04-01 23:12:33 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-04-01 23:12:33 -0500 |
| commit | 1617910ad342a55762f3ddabb975849d843cff85 (patch) | |
| tree | 7d5ec5c3865370fa3cf477b772a79a7b9c6dc109 /bash | |
| parent | 7e872ecfc0b00c3675d64b748a5f1e8754c85b7e (diff) | |
| download | mal-1617910ad342a55762f3ddabb975849d843cff85.tar.gz mal-1617910ad342a55762f3ddabb975849d843cff85.zip | |
All: remove slurp-do, use str around slurp instead.
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 "${@}" |
