fix: Simplify conditional checks

This commit is contained in:
Kroese 2025-09-21 15:13:59 +02:00 committed by GitHub
parent 9e9e7b5c48
commit df61797b9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -162,7 +162,7 @@ startInstall() {
ISO=$(basename "$BOOT") ISO=$(basename "$BOOT")
ISO="$TMP/$ISO" ISO="$TMP/$ISO"
if [ -f "$BOOT" ] && [ -s "$BOOT" ]; then if [ -f "$BOOT" && -s "$BOOT" ]; then
mv -f "$BOOT" "$ISO" mv -f "$BOOT" "$ISO"
fi fi
@ -183,7 +183,7 @@ finishInstall() {
local aborted="$2" local aborted="$2"
local base byte local base byte
if [ ! -s "$iso" ] || [ ! -f "$iso" ]; then if [ ! -s "$iso" || ! -f "$iso" ]; then
error "Failed to find ISO file: $iso" && return 1 error "Failed to find ISO file: $iso" && return 1
fi fi
@ -304,7 +304,7 @@ findFile() {
file="$STORAGE/$base" file="$STORAGE/$base"
fi fi
if [ ! -f "$file" ] || [ ! -s "$file" ]; then if [ ! -f "$file" || ! -s "$file" ]; then
return 0 return 0
fi fi
@ -621,11 +621,11 @@ setXML() {
error "The bind $file maps to a file that does not exist!" && exit 67 error "The bind $file maps to a file that does not exist!" && exit 67
fi fi
[ ! -f "$file" ] || [ ! -s "$file" ] && file="$STORAGE/custom.xml" [ ! -f "$file" || ! -s "$file" ] && file="$STORAGE/custom.xml"
[ ! -f "$file" ] || [ ! -s "$file" ] && file="/run/assets/custom.xml" [ ! -f "$file" || ! -s "$file" ] && file="/run/assets/custom.xml"
[ ! -f "$file" ] || [ ! -s "$file" ] && file="$1" [ ! -f "$file" || ! -s "$file" ] && file="$1"
[ ! -f "$file" ] || [ ! -s "$file" ] && file="/run/assets/$DETECTED.xml" [ ! -f "$file" || ! -s "$file" ] && file="/run/assets/$DETECTED.xml"
[ ! -f "$file" ] || [ ! -s "$file" ] && return 1 [ ! -f "$file" || ! -s "$file" ] && return 1
XML="$file" XML="$file"
return 0 return 0
@ -639,7 +639,7 @@ detectImage() {
XML="" XML=""
if [ -z "$DETECTED" ] && [ -z "$CUSTOM" ]; then if [ -z "$DETECTED" && -z "$CUSTOM" ]; then
[[ "${version,,}" != "http"* ]] && DETECTED="$version" [[ "${version,,}" != "http"* ]] && DETECTED="$version"
fi fi
@ -734,7 +734,7 @@ prepareImage() {
if [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then if [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then
[ -f "$dir/$ETFS" ] && [ -f "$dir/$EFISYS" ] && return 0 [ -f "$dir/$ETFS" && -f "$dir/$EFISYS" ] && return 0
missing=$(basename "$dir/$EFISYS") missing=$(basename "$dir/$EFISYS")
[ ! -f "$dir/$ETFS" ] && missing=$(basename "$dir/$ETFS") [ ! -f "$dir/$ETFS" ] && missing=$(basename "$dir/$ETFS")
@ -955,7 +955,7 @@ updateImage() {
skipVersion "${DETECTED,,}" && return 0 skipVersion "${DETECTED,,}" && return 0
if [ ! -s "$asset" ] || [ ! -f "$asset" ]; then if [ ! -s "$asset" || ! -f "$asset" ]; then
asset="" asset=""
if [[ "$MANUAL" != [Yy1]* ]]; then if [[ "$MANUAL" != [Yy1]* ]]; then
MANUAL="Y" MANUAL="Y"
@ -1140,40 +1140,40 @@ bootWindows() {
ARGUMENTS="$ARGS ${ARGUMENTS:-}" ARGUMENTS="$ARGS ${ARGUMENTS:-}"
fi fi
if [ -s "$STORAGE/windows.vga" ] && [ -f "$STORAGE/windows.vga" ]; then if [ -s "$STORAGE/windows.vga" && -f "$STORAGE/windows.vga" ]; then
if [ -z "${VGA:-}" ]; then if [ -z "${VGA:-}" ]; then
VGA=$(<"$STORAGE/windows.vga") VGA=$(<"$STORAGE/windows.vga")
VGA="${VGA//[![:print:]]/}" VGA="${VGA//[![:print:]]/}"
fi fi
fi fi
if [ -s "$STORAGE/windows.usb" ] && [ -f "$STORAGE/windows.usb" ]; then if [ -s "$STORAGE/windows.usb" && -f "$STORAGE/windows.usb" ]; then
if [ -z "${USB:-}" ]; then if [ -z "${USB:-}" ]; then
USB=$(<"$STORAGE/windows.usb") USB=$(<"$STORAGE/windows.usb")
USB="${USB//[![:print:]]/}" USB="${USB//[![:print:]]/}"
fi fi
fi fi
if [ -s "$STORAGE/windows.net" ] && [ -f "$STORAGE/windows.net" ]; then if [ -s "$STORAGE/windows.net" && -f "$STORAGE/windows.net" ]; then
if [ -z "${ADAPTER:-}" ]; then if [ -z "${ADAPTER:-}" ]; then
ADAPTER=$(<"$STORAGE/windows.net") ADAPTER=$(<"$STORAGE/windows.net")
ADAPTER="${ADAPTER//[![:print:]]/}" ADAPTER="${ADAPTER//[![:print:]]/}"
fi fi
fi fi
if [ -s "$STORAGE/windows.type" ] && [ -f "$STORAGE/windows.type" ]; then if [ -s "$STORAGE/windows.type" && -f "$STORAGE/windows.type" ]; then
if [ -z "${DISK_TYPE:-}" ]; then if [ -z "${DISK_TYPE:-}" ]; then
DISK_TYPE=$(<"$STORAGE/windows.type") DISK_TYPE=$(<"$STORAGE/windows.type")
DISK_TYPE="${DISK_TYPE//[![:print:]]/}" DISK_TYPE="${DISK_TYPE//[![:print:]]/}"
fi fi
fi fi
if [ -s "$STORAGE/windows.mode" ] && [ -f "$STORAGE/windows.mode" ]; then if [ -s "$STORAGE/windows.mode" && -f "$STORAGE/windows.mode" ]; then
BOOT_MODE=$(<"$STORAGE/windows.mode") BOOT_MODE=$(<"$STORAGE/windows.mode")
BOOT_MODE="${BOOT_MODE//[![:print:]]/}" BOOT_MODE="${BOOT_MODE//[![:print:]]/}"
fi fi
if [ -s "$STORAGE/windows.old" ] && [ -f "$STORAGE/windows.old" ]; then if [ -s "$STORAGE/windows.old" && -f "$STORAGE/windows.old" ]; then
if [[ "${PLATFORM,,}" == "x64" ]]; then if [[ "${PLATFORM,,}" == "x64" ]]; then
MACHINE=$(<"$STORAGE/windows.old") MACHINE=$(<"$STORAGE/windows.old")
MACHINE="${MACHINE//[![:print:]]/}" MACHINE="${MACHINE//[![:print:]]/}"
@ -1194,7 +1194,7 @@ if ! startInstall; then
exit 68 exit 68
fi fi
if [ ! -s "$ISO" ] || [ ! -f "$ISO" ]; then if [ ! -s "$ISO" || ! -f "$ISO" ]; then
if ! downloadImage "$ISO" "$VERSION" "$LANGUAGE"; then if ! downloadImage "$ISO" "$VERSION" "$LANGUAGE"; then
rm -f "$ISO" 2> /dev/null || true rm -f "$ISO" 2> /dev/null || true
exit 61 exit 61