automotiveMastermind / numonic

The second generation prompt for macOS, Linux, and WSL
MIT License
9 stars 5 forks source link

fix(shell): install-gcloud fails on macOS 12.2.1 #17

Open patrickserrano opened 2 years ago

patrickserrano commented 2 years ago

Commands to Reproduce

install-gcloud

Expected Results

Google Cloud SDK to be installed

Actual Results

rm returns an illegal option error.

rm on macOS doesn't support `--recursive` and `--force` instead opting for `-r` and `-f` respectively. I'm guessing it has something to do with this from the man page:

NOTE
     The rm command uses getopt(3) to parse its arguments, which allows it to accept the ‘--’ option which
     will cause it to stop processing flag options at that point.  This will allow the removal of file names
     that begin with a dash (‘-’).  For example:
           rm -- -filename
     The same behavior can be obtained by using an absolute or relative path reference.  For example:
           rm /home/user/-filename
           rm ./-filename

Any additional logs that will help us?

install-gcloud: installing gcloud-sdk...
download-safe: attempting to download: https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.tar.gz
rm: illegal option -- -
usage: rm [-f | -i] [-dPRrvW] file ...
       unlink file

Operating System(s)

macOS

Operating System (Other)

No response

Architecture

arm64 / aarch64

Shell

zsh

Terminal Program(s)

other

Terminal Program(s) (Other)

iTerm2

What is the output from uname -srv on the system(s) where the bug is occurring?

Darwin 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000

Code of Conduct

patrickserrano commented 2 years ago

@dmccaffery this issue also impacts install-dotnet (and probably install-aws) when run with -f or --force since it uses the long form rm --recursive --force instead of rm -rf.

-> install-dotnet -f
rm: illegal option -- -
usage: rm [-f | -i] [-dPRrvW] file ...
       unlink file

Also, I noticed that install-gcloud when run with -f or --force uses rm -rf instead of rm --recursive --force. I can open a PR with a fix for all three scripts so we're using rm -rf everywhere if that's how you want to proceed.

sjk07 commented 1 year ago

@patrickserrano I would like to follow the below statement on our readme...

NOTE: We believe in transparency and clarity of commands, hence the expanded form for the options above. The -s flag for the shell command means "read commands from standard input". For more information, see the POSIX Specification.

I understand that it seems macOS cannot support the fully qualified flags. in such a case it may be necessary to create a wrapper around the rm command or a separate script for macOS. This in the long term will require more maintenance.