Add explanatory comments for run modes

allow-input-from-redirected-prompt
acx 1 year ago
parent d79cf405ad
commit 2d29a805e4
  1. 10
      chatgpt.sh

@ -215,15 +215,15 @@ if [ ! -f ~/.chatgpt_history ]; then
fi
running=true
# check input source
# prompt from argument
# check input source and determine run mode
# prompt from argument, run on pipe mode (run once, no chat)
if [ -n "$prompt" ]; then
pipe_mode_prompt=${prompt}
# if input file_descriptor is a terminal
# if input file_descriptor is a terminal, run on chat mode
elif [ -t 0 ]; then
echo -e "Welcome to chatgpt. You can quit with '\033[36mexit\033[0m'."
# if prompt already entered, run on pipe mode (run once, no chat)
# prompt from pipe
# prompt from pipe or redirected stdin, run on pipe mode
else
pipe_mode_prompt+=$(cat -)
fi

Loading…
Cancel
Save