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.
This commit is contained in:
parent
1575061001
commit
975bf63eb5
@ -13,10 +13,10 @@ user() {
|
|||||||
shell="$6"
|
shell="$6"
|
||||||
|
|
||||||
[ "$desc" = '-' ] && desc=
|
[ "$desc" = '-' ] && desc=
|
||||||
[ "$home" = '-' -o "$home" = '' ] && home=/
|
{ [ "$home" = '-' ] || [ "$home" = '' ]; } && home=/
|
||||||
[ "$shell" = '-' -o "$shell" = '' ] && shell=/sbin/nologin
|
{ [ "$shell" = '-' ] || [ "$shell" = '' ]; } && shell=/sbin/nologin
|
||||||
|
|
||||||
if [ "$uid" = '-' -o "$uid" = '' ]; then
|
if [ "$uid" = '-' ] || [ "$uid" = '' ]; then
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
getent passwd '$user' >/dev/null || \\
|
getent passwd '$user' >/dev/null || \\
|
||||||
useradd -r -g '$group' -d '$home' -s '$shell' -c '$desc' '$user'
|
useradd -r -g '$group' -d '$home' -s '$shell' -c '$desc' '$user'
|
||||||
@ -50,11 +50,11 @@ group() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parse() {
|
parse() {
|
||||||
while read line || [ "$line" ]; do
|
while read -r line || [ -n "$line" ] ; do
|
||||||
[ "${line:0:1}" = '#' -o "${line:0:1}" = ';' ] && continue
|
{ [ "${line:0:1}" = '#' ] || [ "${line:0:1}" = ';' ]; } && continue
|
||||||
line="${line## *}"
|
line="${line## *}"
|
||||||
[ -z "$line" ] && continue
|
[ -z "$line" ] && continue
|
||||||
eval arr=( $line )
|
eval "arr=( $line )"
|
||||||
case "${arr[0]}" in
|
case "${arr[0]}" in
|
||||||
('u')
|
('u')
|
||||||
group "${arr[1]}" "${arr[2]}"
|
group "${arr[1]}" "${arr[2]}"
|
||||||
@ -74,6 +74,6 @@ parse() {
|
|||||||
|
|
||||||
for fn in "$@"; do
|
for fn in "$@"; do
|
||||||
[ -e "$fn" ] || continue
|
[ -e "$fn" ] || continue
|
||||||
echo "# generated from $(basename $fn)"
|
echo "# generated from $(basename "$fn")"
|
||||||
parse <"$fn"
|
parse <"$fn"
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user