]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
Use `command -v` instead of `which`
authorGalaxySnail <me@glxys.nl>
Wed, 18 Jan 2023 10:38:17 +0000 (18:38 +0800)
committerAlessandro Astone <ales.astone@gmail.com>
Wed, 18 Jan 2023 13:14:58 +0000 (14:14 +0100)
See: <https://hynek.me/til/which-not-posix/>

data/scripts/waydroid-net.sh

index 1b8a924ab0e8477d3513127643215a24780cf538..3ce3910ff54b52cc7b3d3c49c97fb59d885266c8 100755 (executable)
@@ -32,20 +32,20 @@ LXC_IPV6_MASK=""
 LXC_IPV6_NETWORK=""
 LXC_IPV6_NAT="false"
 
 LXC_IPV6_NETWORK=""
 LXC_IPV6_NAT="false"
 
-IPTABLES_BIN="$(which iptables-legacy)"
+IPTABLES_BIN="$(command -v iptables-legacy)"
 if [ ! -n "$IPTABLES_BIN" ]; then
 if [ ! -n "$IPTABLES_BIN" ]; then
-    IPTABLES_BIN="$(which iptables)"
+    IPTABLES_BIN="$(command -v iptables)"
 fi
 fi
-IP6TABLES_BIN="$(which ip6tables-legacy)"
+IP6TABLES_BIN="$(command -v ip6tables-legacy)"
 if [ ! -n "$IP6TABLES_BIN" ]; then
 if [ ! -n "$IP6TABLES_BIN" ]; then
-    IP6TABLES_BIN="$(which ip6tables)"
+    IP6TABLES_BIN="$(command -v ip6tables)"
 fi
 
 use_nft() {
     [ -n "$NFT" ] && nft list ruleset > /dev/null 2>&1 && [ "$LXC_USE_NFT" = "true" ]
 }
 
 fi
 
 use_nft() {
     [ -n "$NFT" ] && nft list ruleset > /dev/null 2>&1 && [ "$LXC_USE_NFT" = "true" ]
 }
 
-NFT="$(which nft)"
+NFT="$(command -v nft)"
 if ! use_nft; then
     use_iptables_lock="-w"
     $IPTABLES_BIN -w -L -n > /dev/null 2>&1 || use_iptables_lock=""
 if ! use_nft; then
     use_iptables_lock="-w"
     $IPTABLES_BIN -w -L -n > /dev/null 2>&1 || use_iptables_lock=""
@@ -158,7 +158,7 @@ start() {
     # can't write its pid into, so we restorecon it (to var_run_t)
     if [ ! -d "${varrun}" ]; then
         mkdir -p "${varrun}"
     # can't write its pid into, so we restorecon it (to var_run_t)
     if [ ! -d "${varrun}" ]; then
         mkdir -p "${varrun}"
-        if which restorecon >/dev/null 2>&1; then
+        if command -v restorecon >/dev/null 2>&1; then
             restorecon "${varrun}"
         fi
     fi
             restorecon "${varrun}"
         fi
     fi