You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just came across gh-install on HN. While reading through the script I saw a few opportunities to improve it. Hope this helps :)
Using a subshell to execute commands in a different directory avoids the need forpopd.
(
cd$tmp
extract $filename
PS3="Select binary: "
select bin in $(find * -type f -not -path "*$filename"); do break; done
)
Using alternatives in case-matches avoids duplicated commands
Instead of failing with "command not found" gh-install could check for non-standard dependencies using command
gh-install users probably care less about its internal in error messages than gh-install developers, hence a more generic error message could be more appropriate
case $arg in
*.tar.bz2|*.tbz2) tar xjf $arg ;;
*.tar.gz|*tar.xz|*.tgz) tar xzf $arg ;;
*.bz2) bunzip2 $arg ;;
*.gz) gunzip $arg ;;
*.tar) tar xf $arg ;;
*.zip) unzip $arg ;;
*.Z) uncompress $arg ;;
*.rar)
rar=$(command -v rar)
if [ -z "$rar" ]; then echo "Please install the rar utility"; exit 1; fi
$rar x $arg
;;
*.jar)
jar=$(command -v jar)
if [ -z "$jar" ]; then echo "Please install the jar utility"; exit 1; fi
jar -xvf $arg
;;
*) echo "Don't know how to unpack '$arg'" ;;
The text was updated successfully, but these errors were encountered:
I don't usually copy-paste scripts literally from the internet, but this extract() method was taken literally from https://unix.stackexchange.com/a/168/245465. I think I'll credit it, and apply your tips.
I used to do 7z x which handles many formats, but wasn't sure if it would be installed on most operating systems.
While 7z might be a convenient utility it is an external dependency that usually isn't installed on most systems so use of tar(1), bunzip2(1), gunzip(1) is preferrable.
Giving credit where credit is due will be greatly appreciated :)
Just came across
gh-install
on HN. While reading through the script I saw a few opportunities to improve it. Hope this helps :)popd
.gh-install
could check for non-standard dependencies usingcommand
gh-install
users probably care less about its internal in error messages thangh-install
developers, hence a more generic error message could be more appropriateThe text was updated successfully, but these errors were encountered: