Shellcheckify sysusers.generate-pre.sh
There should be almost no functional change, but shellcheck complains less. User/group descriptions with escaped characters are handled properly. rhel-only Resolves: #2217149
This commit is contained in:
parent
42b42fd61e
commit
eac5440e8e
@ -13,10 +13,10 @@ user() {
|
||||
shell="$6"
|
||||
|
||||
[ "$desc" = '-' ] && desc=
|
||||
[ "$home" = '-' -o "$home" = '' ] && home=/
|
||||
[ "$shell" = '-' -o "$shell" = '' ] && shell=/sbin/nologin
|
||||
{ [ "$home" = '-' ] || [ "$home" = '' ]; } && home=/
|
||||
{ [ "$shell" = '-' ] || [ "$shell" = '' ]; } && shell=/sbin/nologin
|
||||
|
||||
if [ "$uid" = '-' -o "$uid" = '' ]; then
|
||||
if [ "$uid" = '-' ] || [ "$uid" = '' ]; then
|
||||
cat <<EOF
|
||||
getent passwd '$user' >/dev/null || \\
|
||||
useradd -r -g '$group' -d '$home' -s '$shell' -c '$desc' '$user'
|
||||
@ -50,11 +50,11 @@ group() {
|
||||
}
|
||||
|
||||
parse() {
|
||||
while read line || [ "$line" ]; do
|
||||
[ "${line:0:1}" = '#' -o "${line:0:1}" = ';' ] && continue
|
||||
while read -r line || [ -n "$line" ] ; do
|
||||
{ [ "${line:0:1}" = '#' ] || [ "${line:0:1}" = ';' ]; } && continue
|
||||
line="${line## *}"
|
||||
[ -z "$line" ] && continue
|
||||
eval arr=( $line )
|
||||
eval "arr=( $line )"
|
||||
case "${arr[0]}" in
|
||||
('u')
|
||||
group "${arr[1]}" "${arr[2]}"
|
||||
@ -74,6 +74,6 @@ parse() {
|
||||
|
||||
for fn in "$@"; do
|
||||
[ -e "$fn" ] || continue
|
||||
echo "# generated from $(basename $fn)"
|
||||
echo "# generated from $(basename "$fn")"
|
||||
parse <"$fn"
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user