LukeSmithxyz / LARBS

Luke's Auto-Rice Bootstrapping Scripts: Installation Scripts for My Arch Linux Meta-Distribution
GNU General Public License v3.0
2.03k stars 797 forks source link

When providing a custom dotfiles repo via "-r" `git ls-remote` is run without making sure it's installed #450

Closed FelixBrendel closed 2 years ago

FelixBrendel commented 2 years ago

When trying to supply a custom dotfile repository on a fresh arch install, the script failes trying to run a git command without git being installed yet. After manually installing git before starting larbs.sh, it runs without problems. I am not the best shell script programmer but I would attribute this to the git command in the prelude of the script which is run before any packages are installed.

while getopts ":a:r:b:p:h" o; do case "${o}" in
    h) printf "Optional arguments for custom use:\\n  -r: Dotfiles repository (local file or url)\\n  -p: Dependencies and programs csv (local file or url)\\n  -a: AUR helper (must have pacman-like syntax)\\n  -h: Show this message\\n" && exit 1 ;;
    r) dotfilesrepo=${OPTARG} && git ls-remote "$dotfilesrepo" || exit 1 ;;
    b) repobranch=${OPTARG} ;;
    p) progsfile=${OPTARG} ;;
    a) aurhelper=${OPTARG} ;;
    *) printf "Invalid option: -%s\\n" "$OPTARG" && exit 1 ;;
esac done
anntnzrb commented 2 years ago

The script could be refactored so the functions now go on top, by doing this, it's possible to take advantage of the installpkg function and auto install git; or perhaps just loop through a list of dependencies and exit 1 if at least one is not installed. However I think the issue is already handled well by the || exit at the end which indicates the command is not installed.

I usually install base-devel + git on every install before any user customization anyways (I'm pretty sure most people do as well), so this shouldn't be considered a critical issue imho.