-
Notifications
You must be signed in to change notification settings - Fork 4
/
termset
executable file
·3 lines (3 loc) · 2.51 KB
/
termset
1
2
3
#!/usr/bin/env sh
# shellcheck disable=SC2211,SC2046,SC2059,SC2086,SC2015,SC2154
set -e 2> /dev/null || true :; OEXT="${1}" && export OEXT; EXSCR=$(mktemp) || { printf '%s\n' "Error: mktemp failed."; exit 1; }; PROWS=$(printf "%s" "${ROWS:-24}" | sed 's/./& /g') || { printf '%s\n' "Error: Failed to set ROWS."; exit 1; }; PCOLS=$(printf "%s" "${COLS:-80}" | sed 's/./& /g') || { printf '%s\n' "Error: Failed to set COLS."; exit 1; }; printf '#!/'"${PENV:-/usr/bin/env}"' expect\nset timeout 5\ncd ./mince80\nspawn ../ccom'"${OEXT:-}"' config.com\nexpect "Would you like to exit and change disks? "\nsleep 0.1;\nsend -- "N"\nexpect " --> "\nsleep 0.1;\nsend -- "2\\r\\n"\nexpect " --> "\nsleep 0.1;\nsend -- "9\\r\\n"\nexpect " --> "\nsleep 0.1;\nsend -- "5\\r\\n"\nexpect " Any changes? "\nsleep 0.1;\nsend -- "Y"\nexpect " Which item? "\nsleep 0.1;\nsend -- "1\\r\\n"\n' > "${EXSCR:?}" && printf '%s\n' 'expect "Number of rows on your terminal? (default = 24) "' >> "${EXSCR:?}" && printf 'sleep 0.1;\nsend -- "%s"\n' ${PROWS} >> "${EXSCR:?}" && printf '%s\n' "sleep 0.1;" 'send -- "\r\n"' >> "${EXSCR:?}" && printf '%s\n' 'expect "Number of columns on your terminal? (default = 80) "' >> "${EXSCR:?}" && printf 'sleep 0.1;\nsend -- "%s"\n' ${PCOLS} >> "${EXSCR:?}" && printf '%s\n' "sleep 0.1;" 'send -- "\r\n"' >> "${EXSCR:?}" && printf 'expect "Any changes?"\nsleep 0.1;\nsend -- "N"\nexpect "Any changes?"\nsleep 0.1;\nsend -- "N"\nexpect "Any changes?"\nsleep 0.1;\nsend -- "N"\nexpect " --> "\nsleep 0.1;\nsend -- "4"\nsend -- "\\r\\n"\nexpect "default = "\nsleep 0.1;\nsend -- "2"\nsleep 0.1;\nsend -- "4"\nsleep 0.1;\nsend -- "8"\nsleep 0.1;\nsend -- "\\r\\n"\nexpect "default = "\nsleep 0.1;\nsend -- "\\r\\n"\nexpect "default = "\nsleep 0.1;\nsend -- "\\r\\n"\nexpect "default = "\nsleep 0.1;\nsend -- "\\r\\n"\nexpect "default = "\nsleep 0.1;\nsend -- "\\r\\n"\nexpect "default = "\nsleep 0.1;\nsend -- "\\r\\n"\nexpect "default = "\nsleep 0.1;\nsend -- "\\r\\n"\n expect " --> "\nsleep 0.1;\nsend -- "7\\r\\n"\nexpect "?"\nsleep 0.1\nsend -- "\\r\\n"\nexpect "swp"\nsleep 0.1;\nsend -- "Y"\nexpect " --> "\nsleep 0.1;\nsend -- "8\\r\\n"\nsleep 0.1;\nexpect eof;\n' >> "${EXSCR:?}"; chmod +x "${EXSCR:?}" || true :; ${TEST:-test} -f "${EXSCR:?}" && "${PENV:-/usr/bin/env}" expect "${EXSCR:?}" || { printf '%s\n' " *** NOTICE: Expect session failed; using fallback configuration."; printf '%s\n' "fallback" > fallback.L || true :; ${RM:-rm} "${EXSCR:?}"; ${CP:-cp} mince80/fallback/mince.swp mince80/mince.swp && exit 0 || { exit 1; }; }; ${RM:-rm} "${EXSCR:?}"