码迷,mamicode.com
首页 > 系统相关 > 详细

Linux Set Command

时间:2017-03-25 00:57:17      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:变量   连接   com   message   set   shel   err   ansi   option   

1. set -e

"Exit immediately if a simple command exits with a non-zero status."

When this option is on, if a simple command fails for any of the reasons listed in Consequences of Shell Errors or returns an exit status value >0, and is not part of the compound list following a while, until, or if keyword, and is not a part of an AND or OR list, and is not a pipeline preceded by the ! reserved word, then the shell shall immediately exit.

2. set -o pipefail

"If set, the return value of a pipeline is the value of the last (rightmost) command to exit with a  non-zero  status,or zero if all commands in the pipeline exit successfully.  This option is disabled by default."
设置了这个选项以后,包含管道命令的语句的返回值,会变成最后一个返回非零的管道命令的返回值
3. set -x

show commands being executed

4. set -u

Treat unset variables as an error when performing parameter expansion.  If expansion is attempted  on  an  unset  variable,  the shell prints an error message, and, if not interactive, exits with a non-zero status.

5. Others

 -b:使被中止的后台程序立刻回报执行状态
 -C:转向所产生的文件无法覆盖已存在的文件
 -d:Shell预设会用杂凑表记忆使用过的指令,以加速指令的执行。使用-d参数可取消。
 -e:若指令传回值不等于0,则立即退出shell。 
 -f:取消使用通配符。
 -h:自动记录函数的所在位置。
 -H Shell:可利用"!"加<指令编号>的方式来执行history中记录的指令。
 -k:指令所给的参数都会被视为此指令的环境变量。 
 -l:记录for循环的变量名称。 
 -m:使用监视模式。 
 -n:只读取指令,而不实际执行。
 -p:启动优先顺序模式。 
 -P:启动-P参数后,执行指令时,会以实际的文件或目录来取代符号连接。 
 -t:执行完随后的指令,即退出shell。 
 -u:当执行时使用到未定义过的变量,则显示错误信息。 
 -v:显示shell所读取的输入值。 
 -x:执行指令后,会先显示该指令及所下的参数。

 

Linux Set Command

标签:变量   连接   com   message   set   shel   err   ansi   option   

原文地址:http://www.cnblogs.com/codingforum/p/6614018.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!