0xacx / chatGPT-shell-cli

Simple shell script to use OpenAI's ChatGPT and DALL-E from the terminal. No Python or JS required.
https://gptshell.cc
MIT License
1.11k stars 157 forks source link

Bug - fold: illegal width value when using pipe mode #107

Closed 0xacx closed 1 year ago

0xacx commented 1 year ago

Reported on discord:

Running chatgpt in pipe mode: cat /test_playbook.yml | ./chatgpt.sh --init-prompt-from-file ../prompts/documentation_instructions_and_format.txt results in fold: illegal width value

Assumption: The $COLUMNS variable probably is not initialized or updated properly when using pipe mode.

0xacx commented 1 year ago

Closing this as I cannot reproduce the error.

mountaineerbr commented 1 year ago

If this error is ever encountered again, a mitigation may be setting shopt -s checkwinsize.

Or a workaround echo text | { fold -s -w $COLUMNS 2>/dev/null || cat ;}

0xacx commented 1 year ago

@mountaineerbr thank you very much for the tips! 🙏 I was not able to reproduce the error but the user had it again today, so I will give it another try.

marzbana commented 1 year ago

Did any of the fixes work? Im facing the same issue, thanks!

camyujistark commented 1 year ago

I was having a similar issue. Turns out when running with zsh shopt command is unknown. In my case, running chatgpt command with bash in front fixed the issue. bash chatgpt <command>

marzbana commented 1 year ago

Thanks so much! Also I figured out removing the column variables and that stuff fixed it for me as well