Commit | Line | Data |
---|---|---|
31690700 JM |
1 | # |
2 | # mal (Make Lisp) shell readline wrapper | |
3 | # | |
4 | ||
5 | ifndef __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. | |
11 | READLINE_EOF := | |
12 | READLINE_HISTORY_FILE := $${HOME}/.mal-history | |
23100ede NB |
13 | READLINE = $(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 | |
23 | endif |