Browse Source

support/scripts/mkusers: accept user tables without terminating \n

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
(cherry picked from commit 5d8445138bd466f80dd45dab1b9fb7279f1536eb)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Yann E. MORIN 1 year ago
parent
commit
06706fa80d
1 changed files with 2 additions and 3 deletions
  1. 2 3
      support/scripts/mkusers

+ 2 - 3
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