forked from Worldie-com/pen.el
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathilambda-sh
More file actions
executable file
·144 lines (113 loc) · 2.52 KB
/
ilambda-sh
File metadata and controls
executable file
·144 lines (113 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
export TTY
# 𝑖λ·SH
# Version 1.0, bash
sn="$(basename "$0")"
inside-docker-p() {
test -f /.dockerenv
}
: "${USE_COMINT:="y"}"
: "${USE_TERM:="n"}"
while [ $# -gt 0 ]; do opt="$1"; case "$opt" in
-nd) {
export NO_DOCKER=y
shift
}
;;
-nt) {
export NO_TERM=y
shift
}
;;
-com|-comint) {
USE_COMINT=y
USE_TERM=n
shift
}
;;
-term) {
USE_COMINT=n
USE_TERM=y
shift
}
;;
-nc|-nocomint) {
USE_COMINT=n
shift
}
;;
*) break;
esac; done
while [ $# -gt 0 ]; do opt="$1"; case "$opt" in
-nv) {
# Used by cterm-docker, not comint
export USE_NVC=y
USE_COMINT=n
USE_TERM=y
shift
}
;;
*) break;
esac; done
export USE_COMINT
export USE_TERM
if { ! test "$NO_DOCKER" = y; } && { ! inside-docker-p; } && { test "$USE_COMINT" = y || test "$USE_TERM" = y; }; then
if test "$USE_TERM" = y; then
cterm-docker ilambda-sh -term "$@"
elif test "$USE_COMINT"; then
export NORL=y
pen sh ilambda-sh -nt -norl "$@"
fi
exit "$?"
fi
CMD="$(cmd-nice-posix "$@")"
while [ $# -gt 0 ]; do opt="$1"; case "$opt" in
"") { shift; }; ;;
-norl) {
NORL=y
shift
}
;;
*) break;
esac; done
if ! test "$NORL" = "y"; then
rlwrap "$sn" -norl "$@"
exit $?
fi
# ilambda-sh-logo 1>&2
echo ilambda REPL | pen-hls red 1>&2
# pf-code-snippet-from-natural-language/2
# pf-ilambda-sh/2
case "$sn" in
ilambda-sh) { prompt=pf-ilambda-sh/2; } ;;
nlsc) { prompt=pf-code-snippet-from-natural-language/2; } ;;
*)
esac
if test "$USE_COMINT" = y && ! printf -- "%s\n" "$INSIDE_EMACS" | grep -q -P 'comint$'; then
comint -p "𝑖λ: " -E "ilambda-sh $CMD"
exit $?
fi
echo "Enter <function name> <args...>"
echo "For example: '𝑖λ: colorof watermelon'"
echo " or: '𝑖λ: color-of sky'"
echo " or: '𝑖λ: \"color of\" strawberry'"
echo
export USE_CONVERSATION_MODE=y
while IFS=$'\n' read -p "𝑖λ: " -r fun_and_args; do
if test "$fun_and_args" = "!!"; then
fun_and_args="$lastcmd"
# UPDATE=y
# PEN_UPDATE=t
eval "peni -u --pool $fun_and_args"
else
# UPDATE=
# PEN_UPDATE=
eval "peni --pool $fun_and_args"
fi
# This method broke it
# export UPDATE
# export PEN_UPDATE
# peni --pool sqrt 5000
# eval "peni --pool $fun_and_args"
lastcmd="$fun_and_args"
done