Shell脚本被source时选择跳过一些语句
2012-05-17 20:21
369 查看
If you run test1.sh, you'll see
test1.sh
test1.sh
exit
If you run test2.sh, you'll see
test2.sh
test1.sh
test1.sh
#!/bin/sh
echo $0
echo $BASH_SOURCE
if [ $0 = $BASH_SOURCE ]; then
echo "exit"
exit 0;
fi
test2.sh
#!/bin/sh
. test1.sh
test1.sh
test1.sh
exit
If you run test2.sh, you'll see
test2.sh
test1.sh
test1.sh
#!/bin/sh
echo $0
echo $BASH_SOURCE
if [ $0 = $BASH_SOURCE ]; then
echo "exit"
exit 0;
fi
test2.sh
#!/bin/sh
. test1.sh
相关文章推荐
- shell的一些常用的语句(if语句,变量,for、while、until语句、函数调用、脚本调用)
- shell 脚本 语法 之选择语句 (二)
- shell脚本编写 之 条件选择,条件判断,循环语句
- shell脚本一些基本语句的用法
- shell脚本不使用if语句进行选择的脚本
- shell脚本编程之选择执行之if语句
- Shell脚本中执行sql语句操作mysql的5种方法
- shell脚本循环语句
- shell脚本常用语句用法笔记
- 简单的一些shell脚本学习--Unix命令行程序
- 一些经典的 Shell 脚本面试问题
- 我的一些简单的shell脚本实例
- ubuntu12.04中shell脚本无法使用source的原因及解决方法
- shell脚本中一些特殊符号
- shell脚本中一些特殊符号
- Shell脚本循环语句——select无限循环
- shell脚本 一些基本应用题
- 〖Android〗存在多个Android设备时,使用Shell脚本选择一个Android设备
- Shell脚本的一些语法
- 在shell脚本中调用另一个脚本的三种不同方法(fork, exec, source)