support/scripts/mkusers: fix double comma in group member list
PATCH 1/1 support/scripts/mkusers: fix double comma in group member list
When add_user_to_group() updates an existing user, it removes the current entry from the list and appends the user to the end. If the user was in the middle of a list (e.g. "user1,user2,user3,user4"), remove "user3" leaves a double command (e.g. "user1,user2,,user4,user3").
The cleanup regex s/,+/, matches on the first comma but fails to collapse subsequent ones since it lacks the global flag.
This commit adds the g flag so consectutive commas are collapsed.
Signed-off-by William Sherrer <[email protected]>
--- support/scripts/mkusers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
support/scripts/mkusers +1 -1
@@ -300,7 +300,7 @@ add_user_to_group() { sed -r -i --follow-symlinks \ -e 's/^('"${group}"':.*:)(([^:]+,)?)'"${username}"'(,[^:]+*)?$/\1\2\4/;' \ -e 's/^('"${group}"':.*)$/\1,'"${username}"'/;' \ - -e 's/,+/,/' \ + -e 's/,+/,/g' \ -e 's/:,/:/' \ "${_f}" done
Signature · 6 lines
2.43.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot