我是否正确地执行了这些 if 语句?

我是否正确地执行了这些 if 语句?

下面是我脚本的一部分,我不确定我是否正确地执行了 if 语句。特别是 elfif 之后的 if - 我可以这样做吗?

read -p 'Enter username: ' user 
if [ -z "$1" ]; then
    echo "You must supply a user name argument"
    exit 1
elif grep "${user}" /etc/passwd >/dev/null 2>&1 then 
    read -p 'Are you sure you want to delete user orange? [y/n] ' response
if [[ ! $response =~ ^([yY][eE][sS]|[yY])$ ]] then
    del-user
else
    echo "User orange has not been deleted."
fi
else
    add-user
fi

编辑:我想弄清楚我的语法是否正确。

相关内容