fix: Avoid pipe to head on find (#313)

This commit is contained in:
Kroese 2025-04-09 08:06:19 +02:00 committed by GitHub
parent a74690db69
commit 5b1108d6f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 16 deletions

View file

@ -768,7 +768,7 @@ addFolder() {
cp -Lr "$folder/." "$dest" || return 1 cp -Lr "$folder/." "$dest" || return 1
local file local file
file=$(find "$dest" -maxdepth 1 -type f -iname install.bat | head -n 1) file=$(find "$dest" -maxdepth 1 -type f -iname install.bat -print -quit)
[ -f "$file" ] && unix2dos -q "$file" [ -f "$file" ] && unix2dos -q "$file"
return 0 return 0

View file

@ -201,7 +201,7 @@ abortInstall() {
[[ "${iso,,}" == *".esd" ]] && exit 60 [[ "${iso,,}" == *".esd" ]] && exit 60
[[ "${UNPACK:-}" == [Yy1]* ]] && exit 60 [[ "${UNPACK:-}" == [Yy1]* ]] && exit 60
efi=$(find "$dir" -maxdepth 1 -type d -iname efi | head -n 1) efi=$(find "$dir" -maxdepth 1 -type d -iname efi -print -quit)
if [ -z "$efi" ]; then if [ -z "$efi" ]; then
[[ "${PLATFORM,,}" == "x64" ]] && BOOT_MODE="windows_legacy" [[ "${PLATFORM,,}" == "x64" ]] && BOOT_MODE="windows_legacy"
@ -230,8 +230,8 @@ detectCustom() {
CUSTOM="" CUSTOM=""
dir=$(find / -maxdepth 1 -type d -iname "$fname" | head -n 1) dir=$(find / -maxdepth 1 -type d -iname "$fname" -print -quit)
[ ! -d "$dir" ] && dir=$(find "$STORAGE" -maxdepth 1 -type d -iname "$fname" | head -n 1) [ ! -d "$dir" ] && dir=$(find "$STORAGE" -maxdepth 1 -type d -iname "$fname" -print -quit)
if [ -d "$dir" ]; then if [ -d "$dir" ]; then
if ! hasDisk || [ ! -f "$boot" ]; then if ! hasDisk || [ ! -f "$boot" ]; then
@ -239,8 +239,8 @@ detectCustom() {
fi fi
fi fi
file=$(find / -maxdepth 1 -type f -iname "$fname" | head -n 1) file=$(find / -maxdepth 1 -type f -iname "$fname" -print -quit)
[ ! -s "$file" ] && file=$(find "$STORAGE" -maxdepth 1 -type f -iname "$fname" | head -n 1) [ ! -s "$file" ] && file=$(find "$STORAGE" -maxdepth 1 -type f -iname "$fname" -print -quit)
if [ ! -s "$file" ] && [[ "${VERSION,,}" != "http"* ]]; then if [ ! -s "$file" ] && [[ "${VERSION,,}" != "http"* ]]; then
base=$(basename "$VERSION") base=$(basename "$VERSION")
@ -396,7 +396,7 @@ extractImage() {
else else
file=$(find "$dir" -maxdepth 1 -type f -iname "*.iso" | head -n 1) file=$(find "$dir" -maxdepth 1 -type f -iname "*.iso" -print -quit)
if [ -z "$file" ]; then if [ -z "$file" ]; then
error "Failed to find any .iso file in archive!" && return 1 error "Failed to find any .iso file in archive!" && return 1
@ -591,14 +591,14 @@ detectImage() {
fi fi
local src wim info local src wim info
src=$(find "$dir" -maxdepth 1 -type d -iname sources | head -n 1) src=$(find "$dir" -maxdepth 1 -type d -iname sources -print -quit)
if [ ! -d "$src" ]; then if [ ! -d "$src" ]; then
warn "failed to locate 'sources' folder in ISO image, $FB" && return 1 warn "failed to locate 'sources' folder in ISO image, $FB" && return 1
fi fi
wim=$(find "$src" -maxdepth 1 -type f -iname install.wim | head -n 1) wim=$(find "$src" -maxdepth 1 -type f -iname install.wim -print -quit)
[ ! -f "$wim" ] && wim=$(find "$src" -maxdepth 1 -type f -iname install.esd | head -n 1) [ ! -f "$wim" ] && wim=$(find "$src" -maxdepth 1 -type f -iname install.esd -print -quit)
if [ ! -f "$wim" ]; then if [ ! -f "$wim" ]; then
warn "failed to locate 'install.wim' or 'install.esd' in ISO image, $FB" && return 1 warn "failed to locate 'install.wim' or 'install.esd' in ISO image, $FB" && return 1
@ -723,8 +723,7 @@ updateXML() {
sed -i "s/<Username>Docker<\/Username>/<Username>$user<\/Username>/g" "$asset" sed -i "s/<Username>Docker<\/Username>/<Username>$user<\/Username>/g" "$asset"
fi fi
[ -n "$PASSWORD" ] && pass="$PASSWORD" || pass="" [ -n "$PASSWORD" ] && pass="$PASSWORD" || pass="admin"
[ -z "$pass" ] && pass="admin"
pw=$(printf '%s' "${pass}Password" | iconv -f utf-8 -t utf-16le | base64 -w 0) pw=$(printf '%s' "${pass}Password" | iconv -f utf-8 -t utf-16le | base64 -w 0)
admin=$(printf '%s' "${pass}AdministratorPassword" | iconv -f utf-8 -t utf-16le | base64 -w 0) admin=$(printf '%s' "${pass}AdministratorPassword" | iconv -f utf-8 -t utf-16le | base64 -w 0)
@ -893,14 +892,14 @@ updateImage() {
rm -rf "$tmp" rm -rf "$tmp"
mkdir -p "$tmp" mkdir -p "$tmp"
src=$(find "$dir" -maxdepth 1 -type d -iname sources | head -n 1) src=$(find "$dir" -maxdepth 1 -type d -iname sources -print -quit)
if [ ! -d "$src" ]; then if [ ! -d "$src" ]; then
error "failed to locate 'sources' folder in ISO image, $FB" && return 1 error "failed to locate 'sources' folder in ISO image, $FB" && return 1
fi fi
wim=$(find "$src" -maxdepth 1 -type f -iname boot.wim | head -n 1) wim=$(find "$src" -maxdepth 1 -type f -iname boot.wim -print -quit)
[ ! -f "$wim" ] && wim=$(find "$src" -maxdepth 1 -type f -iname boot.esd | head -n 1) [ ! -f "$wim" ] && wim=$(find "$src" -maxdepth 1 -type f -iname boot.esd -print -quit)
if [ ! -f "$wim" ]; then if [ ! -f "$wim" ]; then
error "failed to locate 'boot.wim' or 'boot.esd' in ISO image, $FB" && return 1 error "failed to locate 'boot.wim' or 'boot.esd' in ISO image, $FB" && return 1
@ -963,7 +962,7 @@ updateImage() {
local find="$file" local find="$file"
[[ "$MANUAL" == [Yy1]* ]] && find="$org" [[ "$MANUAL" == [Yy1]* ]] && find="$org"
path=$(find "$dir" -maxdepth 1 -type f -iname "$find" | head -n 1) path=$(find "$dir" -maxdepth 1 -type f -iname "$find" -print -quit)
if [ -f "$path" ]; then if [ -f "$path" ]; then
if [[ "$MANUAL" != [Yy1]* ]]; then if [[ "$MANUAL" != [Yy1]* ]]; then