标题:[实践OK]shell type使用及查找定义的shell函数 出处:向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除 时间:Tue, 22 Oct 2019 15:58:31 +0000 作者:jackxiang 地址:http://jackxiang.com/post/10338/ 内容: type用法,查找对应命令的返回值: type cwww cwww is an alias for cd /data/www/ k8s里的shell代码运行: function h::fn_exists() { echo ${1} $(type "${1}" 2>/dev/null | grep -q 'function') return $? } run: + echo init::all init::all ++ type init::all ++ grep -q function + return 1 函数检测: g() { return; } type g g 是函数 g () { return } type g > /dev/null; echo $? 0 Generated by Jackxiang's Bo-blog 2.1.1 Release