我正在尝试以另一个用户身份运行命令并以该用户身份读取输入。由于某种原因,脚本不会在read
命令上暂停,我不确定为什么。这是脚本的一个示例:
#!/bin/bash
username='anthony'
sudo -H -u "$username" bash << 'END_COMMAND'
# Commands to be run as new user
# -------------------------------
echo "#! Running as new user $USER..."
echo "#! Gathering setup information for $USER..."
echo -n "Enter your name and press [ENTER]: "
read name
echo -n "Enter your email and press [ENTER]: "
read email
END_COMMAND
echo "Done"
关于为什么这不会停止的任何想法read name
或read email
?