Unverified Commit 67cd5db5 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

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

parent 995d5eae
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -1215,7 +1215,7 @@ addFolder() {
  cp -Lr "$folder/." "$dest" || return 1

  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"

  return 0
@@ -1310,7 +1310,7 @@ prepareInstall() {
  fi

  local pid file setup
  setup=$(find "$target" -maxdepth 1 -type f -iname setupp.ini | head -n 1)
  setup=$(find "$target" -maxdepth 1 -type f -iname setupp.ini -print -quit)

  if [ -n "$setup" ]; then

@@ -1606,20 +1606,20 @@ detectLegacy() {
  local dir="$1"
  local find find2

  find=$(find "$dir" -maxdepth 1 -type d -iname win95 | head -n 1)
  find=$(find "$dir" -maxdepth 1 -type d -iname win95 -print -quit)
  [ -n "$find" ] && DETECTED="win95" && return 0

  find=$(find "$dir" -maxdepth 1 -type d -iname win98 | head -n 1)
  find=$(find "$dir" -maxdepth 1 -type d -iname win98 -print -quit)
  [ -n "$find" ] && DETECTED="win98" && return 0

  find=$(find "$dir" -maxdepth 1 -type d -iname win9x | head -n 1)
  find=$(find "$dir" -maxdepth 1 -type d -iname win9x -print -quit)
  [ -n "$find" ] && DETECTED="win9x" && return 0

  find=$(find "$dir" -maxdepth 1 -type f -iname cdrom_nt.5 | head -n 1)
  find=$(find "$dir" -maxdepth 1 -type f -iname cdrom_nt.5 -print -quit)
  [ -n "$find" ] && DETECTED="win2k" && return 0

  find=$(find "$dir" -maxdepth 1 -type d -iname win51 | head -n 1)
  find2=$(find "$dir" -maxdepth 1 -type f -iname setupxp.htm | head -n 1)
  find=$(find "$dir" -maxdepth 1 -type d -iname win51 -print -quit)
  find2=$(find "$dir" -maxdepth 1 -type f -iname setupxp.htm -print -quit)

  if [ -n "$find" ] || [ -n "$find2" ] || [ -f "$dir/WIN51AP" ] || [ -f "$dir/WIN51IC" ]; then
    [ -d "$dir/AMD64" ] && DETECTED="winxpx64" && return 0
+13 −13
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ abortInstall() {
  [[ "${iso,,}" == *".esd" ]] && 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
    [[ "${PLATFORM,,}" == "x64" ]] && BOOT_MODE="windows_legacy"
@@ -230,8 +230,8 @@ detectCustom() {

  CUSTOM=""

  dir=$(find / -maxdepth 1 -type d -iname "$fname" | head -n 1)
  [ ! -d "$dir" ] && dir=$(find "$STORAGE" -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" -print -quit)

  if [ -d "$dir" ]; then
    if ! hasDisk || [ ! -f "$boot" ]; then
@@ -239,8 +239,8 @@ detectCustom() {
    fi
  fi

  file=$(find / -maxdepth 1 -type f -iname "$fname" | head -n 1)
  [ ! -s "$file" ] && file=$(find "$STORAGE" -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" -print -quit)

  if [ ! -s "$file" ] && [[ "${VERSION,,}" != "http"* ]]; then
    base=$(basename "$VERSION")
@@ -396,7 +396,7 @@ extractImage() {

  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
      error "Failed to find any .iso file in archive!" && return 1
@@ -591,14 +591,14 @@ detectImage() {
  fi

  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
    warn "failed to locate 'sources' folder in ISO image, $FB" && return 1
  fi

  wim=$(find "$src" -maxdepth 1 -type f -iname install.wim | head -n 1)
  [ ! -f "$wim" ] && wim=$(find "$src" -maxdepth 1 -type f -iname install.esd | 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 -print -quit)

  if [ ! -f "$wim" ]; then
    warn "failed to locate 'install.wim' or 'install.esd' in ISO image, $FB" && return 1
@@ -892,14 +892,14 @@ updateImage() {
  rm -rf "$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
    error "failed to locate 'sources' folder in ISO image, $FB" && return 1
  fi

  wim=$(find "$src" -maxdepth 1 -type f -iname boot.wim | head -n 1)
  [ ! -f "$wim" ] && wim=$(find "$src" -maxdepth 1 -type f -iname boot.esd | 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 -print -quit)

  if [ ! -f "$wim" ]; then
    error "failed to locate 'boot.wim' or 'boot.esd' in ISO image, $FB" && return 1
@@ -962,7 +962,7 @@ updateImage() {

  local find="$file"
  [[ "$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 [[ "$MANUAL" != [Yy1]* ]]; then