在shell脚本中要用到read-s输入密码,但有博客说read-s会将输入内容当作命令保存在历史文件记录中
说法不详细。自己查看了history文件中并没有记录,求知道的帮忙给个详细解释。
另外使用stty-echo不回显,为啥再使用输入重定向时会有stty:standard错误
你还可以试试passwd,这个应该不会保存到历史记录中。
adduser "$1"
echo "$2" | passwd "$1" --stdin
man 1 passwd
--stdin
This option is used to indicate that passwd should read the new
password from standard input, which can be a pipe.