@@ -40,7 +40,7 @@ zsh_yes_or_no() {
4040}
4141
4242add_linux_user_account () {
43- if id " $USER_CREATE_USERNAME " & > /dev/null ; then
43+ if id -- " $USER_CREATE_USERNAME " & > /dev/null ; then
4444 true " INFO: User '$USER_CREATE_USERNAME ' already exists, skip creation."
4545 return 0
4646 fi
@@ -70,7 +70,7 @@ add_linux_user_account() {
7070 # # --disabled-password
7171 # # Do not run passwd(1) to set a password. In most situations, logins are still possible though
7272 # # (for example using SSH keys or through PAM) for reasons that are beyond adduser's scope.
73- adduser --no-create-home --disabled-password --comment " " " $USER_CREATE_USERNAME "
73+ adduser --no-create-home --disabled-password --comment " " -- " $USER_CREATE_USERNAME "
7474 true " INFO: User created."
7575}
7676
@@ -95,7 +95,7 @@ password_empty_for_user_account() {
9595 # user:!:19932:0:99999:7:::
9696
9797 printf ' %s\n' " INFO: Set empty password for account '$USER_CREATE_USERNAME '..."
98- passwd --delete " $USER_CREATE_USERNAME "
98+ passwd --delete -- " $USER_CREATE_USERNAME "
9999 # # /etc/shadow:
100100 # user::19932:0:99999:7:::
101101}
@@ -106,10 +106,10 @@ add_groups_to_linux_user_account() {
106106 # # Use '&>/dev/null' to suppress error from 'is_group'.
107107 # log error "Group does not exist: '${group}'"
108108 if ! is_group " $group_item " & > /dev/null; then
109- addgroup --system " $group_item "
109+ addgroup --system -- " $group_item "
110110 fi
111111
112- adduser " $USER_CREATE_USERNAME " " $group_item "
112+ adduser -- " $USER_CREATE_USERNAME " " $group_item "
113113 done
114114}
115115
@@ -128,7 +128,7 @@ linux_user_account_shell_to_zsh() {
128128 fi
129129
130130 # # Use getent to retrieve the account's entry from /etc/passwd
131- user_passwd_entry=$( getent passwd " $USER_CREATE_USERNAME " )
131+ user_passwd_entry=$( getent passwd -- " $USER_CREATE_USERNAME " )
132132
133133 # # Extract the shell field (the last field) from the account's entry
134134 user_default_shell=$( printf ' %s\n' " $user_passwd_entry " | awk -F: ' {print $NF}' )
@@ -140,18 +140,18 @@ linux_user_account_shell_to_zsh() {
140140
141141 printf ' %s\n' " $0 : INFO: Setting shell for account '$USER_CREATE_USERNAME ' to 'zsh'..."
142142 # # Use 'timeout' to prevent unexplained bug password prompt caused by 'chsh'.
143- if timeout --kill-after 5 5 chsh --shell /usr/bin/zsh " $USER_CREATE_USERNAME " ; then
143+ if timeout --kill-after 5 5 chsh --shell /usr/bin/zsh -- " $USER_CREATE_USERNAME " ; then
144144 printf ' %s\n' " $0 : INFO: Shell for account '$USER_CREATE_USERNAME ' has been set to 'zsh', ok."
145145 else
146146 if [ " $derivative_maker " = " true" ]; then
147- printf ' %s\n' " $0 : ERROR: Command 'chsh --shell /usr/bin/zsh $USER_CREATE_USERNAME ' failed during the build process. (return 1 because derivative_maker=true)"
147+ printf ' %s\n' " $0 : ERROR: Command 'chsh --shell /usr/bin/zsh -- $USER_CREATE_USERNAME ' failed during the build process. (return 1 because derivative_maker=true)"
148148 return 1
149149 fi
150150 if [ -f ' /var/lib/dist-base-files/live_build' ]; then
151- printf ' %s\n' " $0 : ERROR: Command 'chsh --shell /usr/bin/zsh $USER_CREATE_USERNAME ' failed during the build process. (return 1 because /var/lib/dist-base-files/live_build exists)"
151+ printf ' %s\n' " $0 : ERROR: Command 'chsh --shell /usr/bin/zsh -- $USER_CREATE_USERNAME ' failed during the build process. (return 1 because /var/lib/dist-base-files/live_build exists)"
152152 return 1
153153 fi
154- printf ' %s\n' " $0 : ERROR: Command 'chsh --shell /usr/bin/zsh $USER_CREATE_USERNAME ' failed. This is only a minor issue."
154+ printf ' %s\n' " $0 : ERROR: Command 'chsh --shell /usr/bin/zsh -- $USER_CREATE_USERNAME ' failed. This is only a minor issue."
155155 return 0
156156 fi
157157}
0 commit comments