use command -v instead of which

This commit is contained in:
Jakobus Schürz 2023-02-14 04:38:42 +01:00
parent f2841408f8
commit 988d59bf2c

View file

@ -53,8 +53,8 @@ function sudo() {
local C
# SUDO=$( if [ -e /bin/sudo ]; then echo /bin/sudo; else echo /usr/bin/sudo; fi )
SUDO=$(which sudo)
SUDO=$( if [ -e /bin/sudo ]; then echo /bin/sudo; else echo /usr/bin/sudo; fi )
# [ -z "${SUDO} ] && "SUDO=$(command -v sudo)
@ -103,7 +103,6 @@ function sudo() {
SSH_TTY="$SSH_TTY" \
SSH_AUTH_SOCK="$SSH_AUTH_SOCK" \
http_proxy="$http_proxy" \
$BASH \
$@
}
@ -214,8 +213,8 @@ mencfs () {
local PKEY
local ENCDIR
local DESTDIR
local PASS=$(which pass 2>/dev/null || exit 127 )
local ENCFS=$(which encfs 2>/dev/null || exit 127 )
local PASS=$(command -v pass || exit 127 )
local ENCFS=$(command -v encfs || exit 127 )
local CONFIG
if [ -z ${ENCFS_CONFIG_DIRS+x} ] ; then
logwarning "are you sure, ENCFS_CONFIG_DIRS is defined?"
@ -265,7 +264,7 @@ $ENCFS_PASSWORD
uencfs () {
ENTRY
local FUSERMOUNT=$(which fusermount 2>/dev/null || exit 127 )
local FUSERMOUNT=$(command -v fusermount || exit 127 )
local i
[ -z ${FUSERMOUNT+x} ] && return 127
if [ $# -eq 1 ]; then
@ -296,8 +295,8 @@ kinit-custom () {
ENTRY
local PKEY
local REALM
local PASS=$(which pass 2>/dev/null || exit 127 )
local KINIT=$(which kinit 2>/dev/null || exit 127 )
local PASS=$(command -v pass || exit 127 )
local KINIT=$(command -v kinit || exit 127 )
local CONFIG
if [ -z ${KERBEROS_CONFIG_DIRS+x} ] ; then
logwarning "are you sure, KERBEROS_CONFIG_DIRS is defined?"
@ -758,7 +757,7 @@ function checkbkp-full() {
$CMD /bin/bash << EOF
sudo find /srv/nfs/backup -mindepth 1 -maxdepth 1|grep -v -e "git$\|git-backup-repos"|while read i;do printf "%-30s%s\\n" "\$i" \$(ls \$i|tail -n1);done|sort -k 2.1 -r
EOF
which pdsh 1>/dev/null 2>&1 && pdsh -g vpn sudo systemctl status backup.service
command -v pdsh && pdsh -g vpn sudo systemctl status backup.service
else
logwarning "backup.vpn is not reachable -> exit"
@ -891,14 +890,16 @@ reachable-default () {
local SERVER=$1
local PORT=${2:-22}
local res=3
if which nc >/dev/null; then
nc=$(command -v nc || resturn 2)
# if which nc >/dev/null; then
if nc -w 2 -z $SERVER $PORT 2>/dev/null; then
res=0
# res=0
return 0
fi
else
res=2
fi
return $res
# else
# res=2
# fi
# return $res
}
reachable () {