sh: Use exist program

Fix sh module packages to make more extensive use of the exist program
that also ships with the sh module.
Simplifies intent of the code and makes it much easier to read.
This commit is contained in:
Marty Oehme 2022-01-30 11:37:18 +01:00
parent ea95ca7dfa
commit a27d86942b
Signed by: Marty
GPG key ID: B7538B8F50A1C800
3 changed files with 8 additions and 8 deletions

View file

@ -61,6 +61,8 @@ if exist fzf; then
fzf_pkg_tool=yay fzf_pkg_tool=yay
elif exist paru; then elif exist paru; then
fzf_pkg_tool=paru fzf_pkg_tool=paru
elif exist pacman; then
fzf_pkg_tool=pacman
fi fi
# shellcheck disable=2139 # we *want* this to be done at shell startup instead of dynamically # shellcheck disable=2139 # we *want* this to be done at shell startup instead of dynamically
if [ -n "$fzf_pkg_tool" ]; then if [ -n "$fzf_pkg_tool" ]; then
@ -89,6 +91,4 @@ fi
if exist vifm; then if exist vifm; then
alias vm=vifm alias vm=vifm
alias vmm='vifm ${PWD}' alias vmm='vifm ${PWD}'
# enable picture preview script
exist vifmrun && alias vifm=vifmrun
fi fi

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# more usage instructions at https://github.com/clvv/fasd # more usage instructions at https://github.com/clvv/fasd
# eval "$(fasd --init posix-hook posix_alias bash-hook zsh-hook zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install)" # eval "$(fasd --init posix-hook posix_alias bash-hook zsh-hook zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install)"
type fasd >/dev/null 2>&1 && eval "$(fasd --init auto)" exist fasd && eval "$(fasd --init auto)"
# any # any
alias a='fasd -a' alias a='fasd -a'

View file

@ -6,28 +6,28 @@
# Also makes yay call paru since that is the new hotness # Also makes yay call paru since that is the new hotness
# (or at least I want to try it) # (or at least I want to try it)
type paru >/dev/null 2>&1 && { exist paru && {
# recreate the normal look of yay # recreate the normal look of yay
alias yay="paru --bottomup" alias yay="paru --bottomup"
} }
syu() { syu() {
type topgrade >/dev/null 2>&1 && { exist topgrade && {
topgrade topgrade
return return
} }
type paru >/dev/null 2>&1 && { exist paru && {
paru paru
return return
} }
type yay >/dev/null 2>&1 && { exist yay && {
yay yay
return return
} }
type pacman >/dev/null 2>&1 && { exist pacman && {
echo "Did not find paru, or yay installed. Updates will not be applied to aur packages." echo "Did not find paru, or yay installed. Updates will not be applied to aur packages."
sudo pacman -Syu sudo pacman -Syu
return return