diff options
author | Julian Andres Klode <jak@debian.org> | 2021-11-04 03:49:04 +0000 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2021-11-04 03:49:04 +0000 |
commit | fd8affa0b98761b2140f2ec8d012b5176c615550 (patch) | |
tree | 63dcd9a5cc32141d00ca4ca5325622a3c6bb1ee5 | |
parent | f4c4f057665adf5d26b6d83be30362fcd837db22 (diff) | |
parent | 48d4b06013ae3d80b95cf72efaf9a5e7468de965 (diff) |
Merge branch 'command-v' into 'main'
Use `command -v` instead of `which`
See merge request apt-team/apt!193
-rw-r--r-- | cmdline/apt-key.in | 13 | ||||
-rw-r--r-- | debian/apt.apt-compat.cron.daily | 2 | ||||
-rwxr-xr-x | debian/apt.systemd.daily | 8 |
3 files changed, 6 insertions, 17 deletions
diff --git a/cmdline/apt-key.in b/cmdline/apt-key.in index baf3df5c3..137546de3 100644 --- a/cmdline/apt-key.in +++ b/cmdline/apt-key.in @@ -92,18 +92,7 @@ requires_root() { command_available() { if [ -x "$1" ]; then return 0; fi - # command -v "$1" >/dev/null 2>&1 # not required by policy, see #747320 - # which "$1" >/dev/null 2>&1 # is in debianutils (essential) but not on non-debian systems - local OLDIFS="$IFS" - IFS=: - for p in $PATH; do - if [ -x "${p}/${1}" ]; then - IFS="$OLDIFS" - return 0 - fi - done - IFS="$OLDIFS" - return 1 + command -v "$1" >/dev/null # required by policy, see #747320 } escape_shell() { diff --git a/debian/apt.apt-compat.cron.daily b/debian/apt.apt-compat.cron.daily index b0b553768..bde3237f6 100644 --- a/debian/apt.apt-compat.cron.daily +++ b/debian/apt.apt-compat.cron.daily @@ -18,7 +18,7 @@ check_power() # 1 (false) System is not on main power # 255 (false) Power status could not be determined # Desktop systems always return 255 it seems - if which on_ac_power >/dev/null 2>&1; then + if command -v on_ac_power >/dev/null; then if on_ac_power; then : elif [ $? -eq 1 ]; then diff --git a/debian/apt.systemd.daily b/debian/apt.systemd.daily index 25339054e..8e2168908 100755 --- a/debian/apt.systemd.daily +++ b/debian/apt.systemd.daily @@ -341,7 +341,7 @@ if test -r /var/lib/apt/extended_states; then fi # check apt-config existence -if ! which apt-config >/dev/null 2>&1; then +if ! command -v apt-config >/dev/null; then exit 0 fi @@ -375,7 +375,7 @@ if [ "$VERBOSE" -ge 3 ]; then fi # check if we can lock the cache and if the cache is clean -if which apt-get >/dev/null 2>&1 && ! eval apt-get check $XAPTOPT $XSTDERR ; then +if command -v apt-get >/dev/null && ! eval apt-get check $XAPTOPT $XSTDERR ; then debug_echo "error encountered in cron job with \"apt-get check\"." exit 0 fi @@ -470,7 +470,7 @@ if [ "$1" = "update" ] || [ -z "$1" ] ; then debug_echo "download upgradable (not run)" fi - if which unattended-upgrade >/dev/null 2>&1 && env LC_ALL=C.UTF-8 unattended-upgrade --help | grep -q download-only && check_stamp $DOWNLOAD_UPGRADEABLE_STAMP $UnattendedUpgradeInterval; then + if command -v unattended-upgrade >/dev/null && env LC_ALL=C.UTF-8 unattended-upgrade --help | grep -q download-only && check_stamp $DOWNLOAD_UPGRADEABLE_STAMP $UnattendedUpgradeInterval; then if unattended-upgrade --download-only $XUUPOPT; then update_stamp $DOWNLOAD_UPGRADEABLE_STAMP debug_echo "unattended-upgrade -d (success)" @@ -485,7 +485,7 @@ fi if [ "$1" = "install" ] || [ -z "$1" ] ; then # auto upgrade all upgradeable packages UPGRADE_STAMP=/var/lib/apt/periodic/upgrade-stamp - if which unattended-upgrade >/dev/null 2>&1 && check_stamp $UPGRADE_STAMP $UnattendedUpgradeInterval; then + if command -v unattended-upgrade >/dev/null && check_stamp $UPGRADE_STAMP $UnattendedUpgradeInterval; then if unattended-upgrade $XUUPOPT; then update_stamp $UPGRADE_STAMP debug_echo "unattended-upgrade (success)" |