Skip to content

Commit

Permalink
misc #32
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmysun committed Aug 26, 2024
1 parent 32cb5bc commit 8a72e2e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions ell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ parse_arguments "${@}";
if [ "x${ELL_OUTPUT_FILE}" != "x-" ]; then
if [ "${ELL_RECORD}" != "xtrue" ] && [ "${ELL_INTERACTIVE}" != "xtrue" ]; then
logging_debug "Outputting to file: ${ELL_OUTPUT_FILE}";
exec 1>${ELL_OUTPUT_FILE};
exec 1>"${ELL_OUTPUT_FILE}";
fi
fi

Expand Down Expand Up @@ -97,7 +97,7 @@ if [ "x${ELL_RECORD}" = "xtrue" ] || [ "x${ELL_INTERACTIVE}" = "xtrue" ] && [ "x
if [ "x${ELL_OUTPUT_FILE}" != "x-" ]; then
export ELL_TMP_SHELL_LOG="${ELL_OUTPUT_FILE}";
else
export ELL_TMP_SHELL_LOG=$(mktemp);
export ELL_TMP_SHELL_LOG="$(mktemp)";
fi
export ELL_RECORD=true;
logging_info "Session being recorded to ${ELL_TMP_SHELL_LOG}";
Expand Down Expand Up @@ -129,7 +129,7 @@ if [ -n "${ELL_INPUT_FILE}" ]; then
exit 1;
else
logging_debug "Reading input from file: ${ELL_INPUT_FILE}, overriding USER_PROMPT";
USER_PROMPT=$(sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' ${ELL_INPUT_FILE} | awk '{printf "%s\\n", $0}');
USER_PROMPT=$(sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' "${ELL_INPUT_FILE}" | awk '{printf "%s\\n", $0}');
fi
fi

Expand Down Expand Up @@ -158,7 +158,7 @@ if [ "x${ELL_INTERACTIVE}" = "xtrue" ]; then
if [ -z "${ELL_TMP_SHELL_LOG}" ]; then
logging_debug "ELL_TMP_SHELL_LOG not set";
else
SHELL_CONTEXT="$(tail -c 3000 "${ELL_TMP_SHELL_LOG}" | ${BASE_DIR}/helpers/render_to_text.perl | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g'| awk '{printf "%s\\n", $0}')";
export SHELL_CONTEXT="$(tail -c 3000 "${ELL_TMP_SHELL_LOG}" | "${BASE_DIR}/helpers/render_to_text.perl" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g'| awk '{printf "%s\\n", $0}')";
fi
PAYLOAD="$(eval "cat <<EOF
$(<"${ELL_TEMPLATE_PATH}${ELL_TEMPLATE}.json")
Expand Down
2 changes: 1 addition & 1 deletion helpers/parse_arguments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function parse_arguments() {
key="${option_array[0]}";
value="${option_array[1]}";
logging_debug "Setting ${key} to ${value}";
eval "${key}=${value}";
eval "export ${key}=${value}";
done
shift 2;
;;
Expand Down
4 changes: 2 additions & 2 deletions helpers/piping.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# this function pipe an array of commands together
# e.g. piping "cat" "grep -v 'foo'" "sort"
# this function pipes an array of commands together
# e.g. `piping "cat" "grep -v 'foo'" "sort"`

piping() {
if [ ${#} -eq 0 ] || [ "${1}" = '' ]; then
Expand Down
16 changes: 8 additions & 8 deletions plugins/paginator/90_pre_output.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

get_current_column() {
# https://stackoverflow.com/questions/2575037/how-to-get-the-cursor-position-in-bash
exec < /dev/tty
oldstty="$(stty -g)"
stty raw -echo min 0
echo -ne "\e[6n" > /dev/tty
exec < /dev/tty;
oldstty="$(stty -g)";
stty raw -echo min 0;
echo -ne "\e[6n" > /dev/tty;
# tput u7 > /dev/tty # when TERM=xterm (and relatives)
IFS=';' read -r -d R -a pos
stty "${oldstty}"
echo "$((pos[1] - 1))"
IFS=';' read -r -d R -a pos;
stty "${oldstty}";
echo "$((pos[1] - 1))";
}

if [ "x${TO_TTY}" = "xtrue" ]; then
Expand Down Expand Up @@ -60,7 +60,7 @@ if [ "x${TO_TTY}" = "xtrue" ]; then
fi
done
else
logging_debug "Not a terminal";
# logging_debug "Not a terminal";
cat -;
fi

0 comments on commit 8a72e2e

Please sign in to comment.