执行时:
#!/bin/bash
function01() {
echo "Func01"
}
function02() {
echo "Func02"
}
function03() {
echo "Func03"
}
clear
function01
function02
#sudo su
function03
并调用如下:
curl http://192.168.1.1:80/myScript.sh | sudo bash
或者
curl http://192.168.1.1:80/myScript.sh | bash
它运行正常但如果取消注释该行:
#sudo su
然后它会引发错误:
bash: line 1: function03: command not found