V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m35s

Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
2025-08-31 14:57:07 +02:00
parent 8f766cd304
commit 51df551080

View File

@@ -341,40 +341,25 @@ partitioning() {
done
### Prepare mount ordering scheme.
### Prepare the mount ordering scheme.
# shellcheck disable=SC2312
#IFS=$'\n' read -r -d '' -a ARY_PATHS_SORTED < <(
# printf "%s\n" "${ary_paths_unsorted[@]}" \
# | sort -u \
# | awk '
# BEGIN{root_seen=0}
# $0=="/"{root_seen=1; print; next}
# $0=="SWAP"{swap=1; next}
# /^\//{print; next}
# {print} # any other tokens if ever used
# END{ if (swap) print "SWAP" }
# ' \
# && printf "\0"
#)
#IFS=$'\n' read -r -d '' -a ARY_PATHS_SORTED < <(printf "%s\n" "${ary_paths_unsorted[@]}" | sort -u | awk 'BEGIN{FS="/"}{print NF, $0}' | sort -n | cut -d' ' -f2- && printf '\0')
#mapfile -d '' -t ARY_PATHS_SORTED < <(
# printf '%s\0' "${ary_paths_unsorted[@]}" |
# awk -v RS='\0' -v ORS='\0' 'BEGIN{FS="/"} {printf "%d\t%s\0", NF, $0}' |
# sort -z -n -t $'\t' -k1,1 -k2,2 |
# cut -z -f2-
#)
mapfile -d '' -t ARY_PATHS_SORTED < <(
mapfile -d '' -t ARY_PATHS_SORTED < <(\
### a) Emit unsorted items as NUL-separated records (preserve any whitespace):
printf '%s\0' "${ary_paths_unsorted[@]}" |
### b) Dedupe NUL-safely, and add a sort group:
### - grp=0 for the special token "SWAP" (non-path), so it comes first.
### - grp=1 for everything else (absolute paths).
awk -v RS='\0' -v ORS='\0' '
!seen[$0]++ {
grp = ($0=="SWAP") ? 0 : 1;
# Use TAB as field separator for the sort key
printf "%d\t%s\0", grp, $0
}
' | sort -z -t $'\t' -k1,1 -k2,2 | cut -z -f2-
' |
### c) Sort NUL-separated by the group, then lexicographically by the *full path*:
### This ensures parent before child due to prefix property:
### "/boot" < "/boot/efi", "/var/log" < "/var/log/audit" < "/var/tmp"
sort -z -t $'\t' -k1,1 -k2,2 | cut -z -f2-
)
printf "%s\n" "${ary_paths_unsorted[@]}" >| "${DIR_LOG}/mount_paths_unsorted.log"