2
bash文件重定向到标准版本与Linux上的shell(`sh`)有何不同?
我编写了一个脚本,该脚本在运行时切换用户,并使用文件重定向到standard in来执行该脚本user-switch.sh。 #!/bin/bash whoami sudo su -l root whoami 并运行它bash给了我期望的行为 $ bash < user-switch.sh vagrant root 但是,如果我使用运行脚本,则会sh得到不同的输出 $ sh < user-switch.sh vagrant vagrant 为什么bash < user-switch.sh给出的输出不同于sh < user-switch.sh? 笔记: 发生在运行Debian Jessie的两个不同盒子上