在curl
用于获取脚本然后执行它的 shell 脚本中,这两种方法是否有实质性不同?
curl http://address-to-some-script/dosomething.sh | sudo tee /usr/bin/dosomething.sh
Run Code Online (Sandbox Code Playgroud)
……对……
sudo curl http://address-to-some-script/dosomething.sh >> /usr/bin/dosomething.sh
Run Code Online (Sandbox Code Playgroud)
在第二个命令sudo
之前curl
,有一些事情让我停下来,但我无法阐明它是否或如何与第一个不同(风险更大?)。
存在许多实质性差异。
curl http://address-to-some-script/dosomething.sh | sudo tee /usr/bin/dosomething.sh
Run Code Online (Sandbox Code Playgroud)
curl
以当前用户和tee
root 身份运行;它还/usr/bin/dosomething.sh
在写入之前清除内容。
sudo curl http://address-to-some-script/dosomething.sh >> /usr/bin/dosomething.sh
Run Code Online (Sandbox Code Playgroud)
curl
以 root 身份运行,并尝试/usr/bin/dosomething.sh
使用当前用户的权限进行追加(当前 shell 设置了重定向)。