DISABLE FDs (REMOVE ME).
[jackhill/mal.git] / make / readline.mk
CommitLineData
31690700
JM
1#
2# mal (Make Lisp) shell readline wrapper
3#
4
5ifndef __mal_readline_included
6__mal_readline_included := true
7
8# Call bash read/readline. Since each call is in a separate shell
9# instance we need to restore and save after each call in order to
10# have readline history.
11READLINE_EOF :=
12READLINE_HISTORY_FILE := $${HOME}/.mal-history
23100ede
NB
13READLINE = $(eval __readline_temp := $(shell \
14 history -r $(READLINE_HISTORY_FILE); \
15 read -u 0 -r -e -p $(if $(1),$(1),"user> ") line && \
16 history -s -- "$${line}" && \
17 echo "$${line}" || \
18 echo "__||EOF||__"; \
19 history -a $(READLINE_HISTORY_FILE) 2>/dev/null || \
20 true \
21))$(if $(filter __||EOF||__,$(__readline_temp)),$(eval READLINE_EOF := yes),$(__readline_temp))
31690700
JM
22
23endif