Interactive通常是指读入写出数据都是从用户的terminal,也就是我们平时用命令行打开终端就是Interactive模式,而执行一个shell脚本就是Non-interactive模式。怎么检验当前shell运行的模式是不是Interactive呢?小姐姐从GNU网站拷贝了一段脚本:
case "$-" in
*i*) echo This shell is interactive ;;
*) echo This shell is not interactive ;;
esac