feat: Refactor negated command conditions (#1346)

This commit is contained in:
Kroese
2026-07-30 21:22:21 +02:00
committed by GitHub
parent 18d6be8210
commit de8468161f
5 changed files with 16 additions and 16 deletions
+4 -4
View File
@@ -254,7 +254,7 @@ if ! touch "$SYSTEM"; then
error "Could not create file $SYSTEM for the system disk." && exit 98
fi
! setOwner "$SYSTEM" && warn "failed to set the owner for \"$SYSTEM\" !"
setOwner "$SYSTEM" || warn "failed to set the owner for \"$SYSTEM\" !"
if [[ "${FS,,}" == "btrfs" ]]; then
{ chattr +C "$SYSTEM"; } || :
@@ -329,7 +329,7 @@ fakeroot -- bash -c "set -Eeu;\
rm -rf "$MOUNT"
echo "$BASE" > "$STORAGE/dsm.ver"
! setOwner "$STORAGE/dsm.ver" && warn "failed to set the owner for \"$STORAGE/dsm.ver\" !"
setOwner "$STORAGE/dsm.ver" || warn "failed to set the owner for \"$STORAGE/dsm.ver\" !"
if [[ "$URL" == "file://$STORAGE/$BASE.pat" ]]; then
rm -f "$PAT"
@@ -338,11 +338,11 @@ else
fi
if [ -f "$STORAGE/$BASE.pat" ]; then
! setOwner "$STORAGE/$BASE.pat" && warn "failed to set the owner for \"$STORAGE/$BASE.pat\" !"
setOwner "$STORAGE/$BASE.pat" || warn "failed to set the owner for \"$STORAGE/$BASE.pat\" !"
fi
mv -f "$BOOT" "$STORAGE/$BASE.boot.img"
! setOwner "$STORAGE/$BASE.boot.img" && warn "failed to set the owner for \"$STORAGE/$BASE.boot.img\" !"
setOwner "$STORAGE/$BASE.boot.img" || warn "failed to set the owner for \"$STORAGE/$BASE.boot.img\" !"
rm -rf "$TMP"
+4 -4
View File
@@ -108,8 +108,8 @@ forceKillQemu() {
local reason="$1"
local pid display
! readQemuPid pid && return 0
! isAlive "$pid" && return 0
readQemuPid pid || return 0
isAlive "$pid" || return 0
display=$(displayReason "$reason")
error "Forcefully terminating $(app), reason: $display..."
@@ -305,7 +305,7 @@ waitForShutdown() {
local slp=$!
# Stop waiting if the process has exited
! isAlive "$pid" && break
isAlive "$pid" || break
# Workaround for stale/zombie QEMU pid file
[ ! -s "$QEMU_START_PID" ] && [ ! -s "$QEMU_PID" ] && break
@@ -372,7 +372,7 @@ graceful_shutdown() {
finish "$code"
}
! enabled "$SHUTDOWN" && return 0
enabled "$SHUTDOWN" || return 0
[ -n "${QEMU_TIMEOUT:-}" ] && TIMEOUT="$QEMU_TIMEOUT"
if interactive; then
+1 -1
View File
@@ -47,7 +47,7 @@ checkSse42() {
if ! hasFlag "sse4_2"; then
error "Your CPU does not have the SSE4 instruction set that Virtual DSM requires!"
! enabled "$DEBUG" && exit 88
enabled "$DEBUG" || exit 88
fi
return 0
+3 -3
View File
@@ -209,7 +209,7 @@ normalizeRamSize() {
fi
RAM_SIZE=$(echo "${RAM_SIZE^^}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
! numfmt --from=iec "$RAM_SIZE" &>/dev/null && error "Invalid RAM_SIZE: $RAM_SIZE" && exit 16
numfmt --from=iec "$RAM_SIZE" &>/dev/null || { error "Invalid RAM_SIZE: $RAM_SIZE" && exit 16; }
wanted=$(numfmt --from=iec "$RAM_SIZE")
[ "$wanted" -lt "$RAM_MINIMUM" ] && error "RAM_SIZE is too low: $RAM_SIZE" && exit 16
@@ -254,7 +254,7 @@ checkKvm() {
fi
if ! grep -qw "sse4_2" <<< "$flags"; then
error "Your CPU does not have the SSE4 instruction set that Virtual DSM requires!"
! enabled "$DEBUG" && exit 88
enabled "$DEBUG" || exit 88
fi
fi
fi
@@ -275,7 +275,7 @@ checkKvm() {
error "KVM acceleration is not available $KVM_ERR, this will cause the machine to run about 10 times slower."
error "See the FAQ for possible causes, or disable acceleration by adding the \"KVM=N\" variable (not recommended)." ;;
esac
! enabled "$DEBUG" && exit 88
enabled "$DEBUG" || exit 88
fi
fi
+4 -4
View File
@@ -155,7 +155,7 @@ waitPidFile() {
local timeout="${2:-10}"
local deadline=$((SECONDS + timeout))
! readPidFile pid "$file" && return 0
readPidFile pid "$file" || return 0
while [ -s "$file" ] && isAlive "$pid"; do
(( SECONDS >= deadline )) && return 1
@@ -218,7 +218,7 @@ sKill() {
local pid
local file="$1"
! readPidFile pid "$file" && return 0
readPidFile pid "$file" || return 0
if isAlive "$pid"; then
{ kill -15 -- "$pid" || :; } 2>/dev/null
@@ -256,7 +256,7 @@ setOwner() {
uid=$(stat -c '%u' "$dir") || return 1
gid=$(stat -c '%g' "$dir") || return 1
! chown "$uid:$gid" "$file" && return 1
chown "$uid:$gid" "$file" || return 1
return 0
}
@@ -267,7 +267,7 @@ makeDir() {
local dir uid gid
[ -d "$path" ] && return 0
! mkdir -p "$path" && return 1
mkdir -p "$path" || return 1
dir=$(dirname -- "$path")