diff mbox series

[3/5] support/scripts/mkusers: accept user tables without terminating \n

Message ID e792b64d76fdc94756698d5c757a545acf418b53.1710027863.git.yann.morin.1998@free.fr
State New
Headers show
Series support: accept text files with missing terminating \n (branch yem/newlines) | expand

Commit Message

Yann E. MORIN March 9, 2024, 11:44 p.m. UTC
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
 support/scripts/mkusers | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/support/scripts/mkusers b/support/scripts/mkusers
index ee09bbd1f2..08f3344518 100755
--- a/support/scripts/mkusers
+++ b/support/scripts/mkusers
@@ -409,9 +409,8 @@  main() {
     fi
 
     # Read in all the file in memory, exclude empty lines and comments
-    while read -r line; do
-        ENTRIES+=( "${line}" )
-    done < <( sed -r -e 's/#.*//; /^[[:space:]]*$/d;' "${USERS_TABLE}" )
+    # mapfile reads all lines, even the last one if it is missing a \n
+    mapfile -t ENTRIES < <( sed -r -e 's/#.*//; /^[[:space:]]*$/d;' "${USERS_TABLE}" )
 
     # We first create groups whose gid is positive, and then we create groups
     # whose gid is automatic, so that, if a group is defined both with