Source: qemu
Version: 1:7.0+dfsg-7
Severity: minor

Dear Maintainer,

Debian ships a few shell programs, and they (ab)use which(1)
instead of the standard command -v.

Please consider the diff, below, which fixes this in:
  * debian/qemu-debootstrap
  * debian/qemu-ifup.linux
  * debian/qemu-make-debian-root

Additionally, it fixes a horrific under-defined (notionally
XSI-extenion, not recommended by the standard, shellcheck-warned)
conditional spelling in debian/qemu-ifup.linux

Best,
наб

-- System Information:
Debian Release: 11.4
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 
'stable-debug'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.10.0-16-amd64 (SMP w/24 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_FIRMWARE_WORKAROUND, 
TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff --git a/qemu-7.0+dfsg.orig/debian/qemu-debootstrap 
b/qemu-7.0+dfsg/debian/qemu-debootstrap
index 43875cb..399e736 100755
--- a/qemu-7.0+dfsg.orig/debian/qemu-debootstrap
+++ b/qemu-7.0+dfsg/debian/qemu-debootstrap
@@ -5,7 +5,7 @@
 # so regular debootstrap can be used just fine without --foreign, since all
 # commands inside the chroot will just run using qemu from binfmt-misc 
subsystem.
 
-if ! which debootstrap >/dev/null 2>/dev/null; then
+if ! command -v debootstrap >/dev/null; then
   echo "E: debootstrap isn't found in \$PATH, is debootstrap package 
installed?" >&2
   exit 1
 fi
diff --git a/qemu-7.0+dfsg.orig/debian/qemu-ifup.linux 
b/qemu-7.0+dfsg/debian/qemu-ifup.linux
index f2f4d5d..76b68ea 100755
--- a/qemu-7.0+dfsg.orig/debian/qemu-ifup.linux
+++ b/qemu-7.0+dfsg/debian/qemu-ifup.linux
@@ -5,13 +5,13 @@
 
 # in order to be able to find brctl
 PATH=$PATH:/sbin:/usr/sbin
-ip=$(which ip)
+ip=$(command -v ip)
 
 if [ -n "$ip" ]; then
    ip link set "$1" up
 else
-   brctl=$(which brctl)
-   if [ ! "$ip" -o ! "$brctl" ]; then
+   brctl=$(command -v brctl)
+   if [ -z "$ip$brctl" ]; then
      echo "W: $0: not doing any bridge processing: neither ip nor brctl 
utility not found" >&2
      exit 0
    fi
@@ -31,11 +31,10 @@ switch=$(ip route ls | \
 for br in $switch; do
     if [ -d /sys/class/net/$br/bridge/. ]; then
         if [ -n "$ip" ]; then
-          ip link set "$1" master "$br"
+          exec ip link set "$1" master "$br"
         else
-          brctl addif $br "$1"
+          exec brctl addif $br "$1"
         fi
-        exit   # exit with status of the previous command
     fi
 done
 
diff --git a/qemu-7.0+dfsg.orig/debian/qemu-make-debian-root 
b/qemu-7.0+dfsg/debian/qemu-make-debian-root
index d4b6c01..e8681b2 100755
--- a/qemu-7.0+dfsg.orig/debian/qemu-make-debian-root
+++ b/qemu-7.0+dfsg/debian/qemu-make-debian-root
@@ -7,15 +7,15 @@
 
 set -e
 
-which debootstrap >/dev/null || {
+command -v debootstrap >/dev/null || {
     echo "error: missing debootstrap package" >&2
     exit 1
 }
-which sfdisk >/dev/null || {
+command -v sfdisk >/dev/null || {
     echo "error: missing fdisk package" >&2
     exit 1
 }
-which mke2fs >/dev/null || {
+command -v mke2fs >/dev/null || {
     echo "error: missing e2fsprogs package" >&2
     exit 1
 }

Attachment: signature.asc
Description: PGP signature

Reply via email to