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.05k stars 150 forks source link

Install error on PopOS!/Ubuntu for sed option #36

Closed direster closed 1 year ago

direster commented 1 year ago

First off this is a Great tool! Thank you for developing and sharing this! I've seen an error for sed option during install on pop-os/ubuntu, so raising this issue. Could be an easy fix(?)

direster@pop-os:~$ curl -sS https://raw.githubusercontent.com/0xacx/chatGPT-shell-cli/main/install.sh | sudo -E bash
sed: invalid option -- 'h'
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

  -n, --quiet, --silent
                 suppress automatic printing of pattern space
      --debug
                 annotate program execution
  -e script, --expression=script
                 add the script to the commands to be executed
  -f script-file, --file=script-file
                 add the contents of script-file to the commands to be executed
  --follow-symlinks
                 follow symlinks when processing in place
  -i[SUFFIX], --in-place[=SUFFIX]
                 edit files in place (makes backup if SUFFIX supplied)
  -l N, --line-length=N
                 specify the desired line-wrap length for the `l' command
  --posix
                 disable all GNU extensions.
  -E, -r, --regexp-extended
                 use extended regular expressions in the script
                 (for portability use POSIX -E).
  -s, --separate
                 consider files as separate rather than as a single,
                 continuous long stream.
      --sandbox
                 operate in sandbox mode (disable e/r/w commands).
  -u, --unbuffered
                 load minimal amounts of data from the input files and flush
                 the output buffers more often
  -z, --null-data
                 separate lines by NUL characters
      --help     display this help and exit
      --version  output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret.  All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

GNU sed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
Installed chatgpt script to /usr/local/bin/chatgpt
OpenAI key and chatgpt path added to ~/.profile
Installation complete
direster commented 1 year ago

I'm not sure what the intention was for using -h option, but did you mean to use -n for quiet mode (suppress automatic printing of pattern space)?

If that is so, I can fix this or any other minor issues I come across as I use the tool. Please let me know if you would like me to contribute with the change.

Issue at line 35 of install.sh. https://github.com/0xacx/chatGPT-shell-cli/pull/33/commits Offending block of code:

# Replace open image command with xdg-open for linux systems
if [[ "$OSTYPE" == "linux-gnu"* ]] || [[ "$OSTYPE" == "freebsd"* ]]; then
  sed -i -h 's/open "\${image_url}"/xdg-open "\${image_url}"/g' '/usr/local/bin/chatgpt'
fi
direster commented 1 year ago

I've downloaded the install.sh and removed the -h option in the sed command mentioned in above comment, and it works fine now. Note: replacing -h with -n did not work for some reason, so I've completely removed -h option. It looks like this now:

# Replace open image command with xdg-open for linux systems
if [[ "$OSTYPE" == "linux-gnu"* ]] || [[ "$OSTYPE" == "freebsd"* ]]; then
  sed -i 's/open "\${image_url}"/xdg-open "\${image_url}"/g' '/usr/local/bin/chatgpt'
fi
0xacx commented 1 year ago

Thank you so much for finding this! 🙏

Weirdly, without the -h flag it doesn't work on mac and I don't understand completely why, but that's fine since this line only needs to work on Linux systems. So just removing it should be good. 👍

if we needed to make that command portable between Mac and Linux then we would need to do it like that

Thanks again for catching this bug! If you find any other, don't hesitate to submit a PR! 🙏

direster commented 1 year ago

Awesome! Thanks for fixing this so quickly!