1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-05 08:09:03 -08:00

turn have, has, and maybesudo into one-liners

This commit is contained in:
Connor Olding 2024-02-24 08:34:23 -08:00
parent eb31cf5450
commit 2b0c642512

View file

@ -8,18 +8,10 @@ fi
# {{{1 utilities
have() {
if [ -z "$ZSH_VERSION" ]; then which -- "$1"; else whence -p -- "$1"; fi
} 2>/dev/null
has() {
have "$@"
} >/dev/null
have() { if [ -z "$ZSH_VERSION" ]; then which -- "$1"; else whence -p -- "$1"; fi; } 2>/dev/null
has() { have "$@"; } >/dev/null
if has sudo; then
maybesudo() { sudo "$@"; }
else
maybesudo() { maybesudo_ "$@"; }
fi
has sudo && maybesudo() { sudo "$@"; } || maybesudo() { maybesudo_ "$@"; }
ADDPATH() { ### @- append a directory to `$PATH` if it isn't already present.
[ $# = 1 ] || { printf >&2 'ADDPATH: expected exactly 1 argument, got %s\n' $#; return 64; }