use `command -v` instead of `which` to determine tool availability.

It's POSIX and also considers builtins.
gf-arm64
FriendlyNeighborhoodShane 3 years ago
parent 3afe9f0ddd
commit 2efc1d10b9

@ -25,7 +25,7 @@ echo "-- The Essentials only MicroG pack --";
modname="MinMicroG";
for bin in cp grep ls mv rm sed zip; do
[ "$(which $bin)" ] || abort "No $bin found";
command -v "$bin" >/dev/null || abort "No $bin found";
done;
echo " ";

@ -23,7 +23,7 @@ echo "-- Minimal MicroG Test Script --";
echo "-- The Essentials only MicroG pack --";
for bin in printf sed; do
[ "$(which $bin)" ] || abort "No $bin found";
command -v "$bin" >/dev/null || abort "No $bin found";
done;
[ "$#" = "3" ] || abort "Not enough arguments";

@ -80,7 +80,7 @@ microg_cleanup() {
fi;
done;
fi;
if [ "$(which sqlite3)" ]; then
if command -v "sqlite3" >/dev/null; then
find /data/system* -type f -name "accounts*db" 2>/dev/null | while read -r database; do
log "PREPPER: deleting Google Accounts from $database";
sqlite3 "$database" "DELETE FROM accounts WHERE type='com.google';";

@ -54,7 +54,7 @@ verifycerts() {
[ "$stuff_repo" ] || echo "$stuff_download" | grep -qE "^[ ]*[^ ]+.apk[ ]+" || return 0;
[ "$(which jarsigner)" ] && [ "$(which openssl)" ] || {
command -v "jarsigner" >/dev/null && command -v "openssl" >/dev/null || {
echo " ";
echo " !! Not checking certificates (missing jarsigner or openssl)";
return 0;
@ -115,7 +115,7 @@ checkwhitelist() {
echo "$stuff_download" | grep -qE "^[ ]*/system/priv-app/[^ ]+.apk[ ]+" || return 0;
[ "$(which aapt)" ] || {
command -v "aapt" >/dev/null || {
echo " ";
echo " !! Not checking privperms (missing aapt)";
return 0;

@ -102,7 +102,7 @@ $bootmode || {
}
for bin in chcon chmod chown cp cut df du echo find grep head mkdir mount ps rm sed tail touch umount unzip; do
[ "$(which "$bin")" ] || abort "No $bin available";
command -v "$bin" >/dev/null || abort "No $bin available";
done;
$bootmode && filedir="/dev/tmp/$modname" || filedir="/tmp/$modname";

@ -19,7 +19,7 @@ echo "-- Minimal MicroG Test Script --";
echo "-- The Essentials only MicroG pack --";
for bin in shellcheck; do
[ "$(which $bin)" ] || abort "No $bin found";
command -v "$bin" >/dev/null || abort "No $bin found";
done;
# These tests are only excluded in the command because they're pointless

@ -40,7 +40,7 @@ echo "-- The Essentials Only MicroG Pack --";
# Bin check
for bin in chmod cp curl grep head jq mv rm sort tr unzip; do
[ "$(which $bin)" ] || abort "No $bin found";
command -v "$bin" >/dev/null || abort "No $bin found";
done;
echo " ";

Loading…
Cancel
Save