Switch out which for command -v in install.sh

This commit is contained in:
David Tomaschik
2021-11-07 15:49:09 -08:00
parent 1f59627da9
commit f8ddb56b02

View File

@@ -26,7 +26,7 @@ is_comment() {
} }
prerequisites() { prerequisites() {
if which zsh > /dev/null 2>&1 ; then if command -v zsh > /dev/null 2>&1 ; then
case $- in case $- in
*i*) *i*)
case $(getent passwd $USER | cut -d: -f7) in case $(getent passwd $USER | cut -d: -f7) in
@@ -36,7 +36,7 @@ prerequisites() {
if [ $(id) -ne 0 ] ; then if [ $(id) -ne 0 ] ; then
echo 'Enter password to change shell.' >&2 echo 'Enter password to change shell.' >&2
fi fi
chsh -s $(which zsh) chsh -s $(command -v zsh)
;; ;;
esac esac
;; ;;
@@ -98,7 +98,7 @@ install_basic_dir() {
install_git() { install_git() {
# Install or update a git repository # Install or update a git repository
if ! which git > /dev/null ; then if ! command -v git > /dev/null 2>&1 ; then
return 1 return 1
fi fi
local REPO="${*: -2:1}" local REPO="${*: -2:1}"
@@ -177,7 +177,7 @@ install_ssh_keys() {
} }
install_gpg_keys() { install_gpg_keys() {
which gpg >/dev/null 2>&1 || \ command -v gpg >/dev/null 2>&1 || \
return 0 return 0
local key local key
for key in ${BASEDIR}/keys/gpg/* ; do for key in ${BASEDIR}/keys/gpg/* ; do
@@ -215,7 +215,7 @@ run_as_root() {
if [ ${USER} = "root" ] ; then if [ ${USER} = "root" ] ; then
"$@" "$@"
return $? return $?
elif test -x $(which sudo 2>/dev/null) ; then elif test -x $(command -v sudo 2>/dev/null) ; then
verbose "Using sudo to run ${1}..." verbose "Using sudo to run ${1}..."
sudo "$@" sudo "$@"
return $? return $?
@@ -371,7 +371,7 @@ install_main() {
} }
install_dconf() { install_dconf() {
which dconf >/dev/null 2>&1 || return 1 command -v dconf >/dev/null 2>&1 || return 1
find "${BASEDIR}/dconf" -type f -printf '/%P\n' | while read dcpath ; do find "${BASEDIR}/dconf" -type f -printf '/%P\n' | while read dcpath ; do
dconf load ${dcpath}/ < "${BASEDIR}/dconf/${dcpath}" dconf load ${dcpath}/ < "${BASEDIR}/dconf/${dcpath}"
done done
@@ -396,7 +396,7 @@ if [ ! -d $BASEDIR ] ; then
exit 1 exit 1
fi fi
if which dpkg-query > /dev/null 2>&1 ; then if command -v dpkg-query > /dev/null 2>&1 ; then
HAVE_X=$(dpkg-query -s xserver-xorg 2>/dev/null | \ HAVE_X=$(dpkg-query -s xserver-xorg 2>/dev/null | \
grep -c 'Status.*installed' \ grep -c 'Status.*installed' \
|| true) || true)