fix(bootstrap): strip empty lines from every LDIF fragment

The first file of each prefix group was not stripped, so a trailing
empty line there split the entry completed by the following files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bertrand Gouny
2026-10-13 22:06:15 +02:00
co-authored by Claude Opus 5.5
parent a65faa1611
commit 97af2dbd7c
+15 -15
View File
@@ -65,23 +65,23 @@ bootstrap_ldif() {
# add a blank line between each group (e.g., between 49 and 50).
if [ -n "${prev_group}" ] && [ "${group}" != "${prev_group}" ]; then
echo >> "${tmp_file}" # add empty line
else
# remove trailing empty lines
tmp=$(mktemp -p "${BOOTSTRAP_TMP_DIR}")
awk '
{ lines[NR] = $0 }
$0 ~ /[^[:space:]]/ {
if (!first) first = NR
last = NR
}
END {
if (first) for (i = first; i <= last; i++) print lines[i]
}
' "${file}" > "${tmp}"
mv -v "${tmp}" "${file}" 2>&1 | container log debug
fi
# remove leading and trailing empty lines
tmp=$(mktemp -p "${BOOTSTRAP_TMP_DIR}")
awk '
{ lines[NR] = $0 }
$0 ~ /[^[:space:]]/ {
if (!first) first = NR
last = NR
}
END {
if (first) for (i = first; i <= last; i++) print lines[i]
}
' "${file}" > "${tmp}"
mv -v "${tmp}" "${file}" 2>&1 | container log debug
cat "${file}" >> "${tmp_file}"
prev_group="${group}"