shell——函数
1. 函数返回值
#!/bin/bash
function func1()
{
echo "I will return 0"
}
function func2()
{
echo "I will return 1"
# 默认返回最近命令的 返回值
find ./ -name &>/dev/null
}
func1
echo "Last function return $?"
func2
echo "Last function return $?"
2. 函数库
# 避免库被直接调用
#!/bin/echo "I'am lib, can't be exec"
test()
{
echo "Lib function : test"
}
# 调用库
source ./lib.sh
test