File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -215,16 +215,17 @@ if [ ! -f ~/.chatgpt_history ]; then
215
215
fi
216
216
217
217
running=true
218
- # check input source
219
- # if prompt already entered, run on pipe mode (run once, no chat)
220
- # prompt from pipe
221
- if [ -p /dev/stdin ]; then
222
- pipe_mode_prompt+=$( cat -)
223
- # prompt from argument
224
- elif [ -n " $prompt " ]; then
218
+ # check input source and determine run mode
219
+
220
+ # prompt from argument, run on pipe mode (run once, no chat)
221
+ if [ -n " $prompt " ]; then
225
222
pipe_mode_prompt=${prompt}
226
- else
223
+ # if input file_descriptor is a terminal, run on chat mode
224
+ elif [ -t 0 ]; then
227
225
echo -e " Welcome to chatgpt. You can quit with '\033[36mexit\033[0m'."
226
+ # prompt from pipe or redirected stdin, run on pipe mode
227
+ else
228
+ pipe_mode_prompt+=$( cat -)
228
229
fi
229
230
230
231
while $running ; do
You can’t perform that action at this time.
0 commit comments