Manpage set-e和set-a在bash中的作用是什么?我可以在set命令中使用哪些其他选项
我想知道下面的命令在bash中的作用Manpage set-e和set-a在bash中的作用是什么?我可以在set命令中使用哪些其他选项,manpage,Manpage,我想知道下面的命令在bash中的作用 set-e 集-a 我可以使用set的其他选项有哪些?它们的含义是什么。来自: -标记为导出到后续命令环境而修改或创建的变量和函数 -e如果管道(见管道)可能由单个简单命令(见简单命令)、列表(见列表)组成,则立即退出, 或复合命令(请参见复合命令)返回非零 地位如果失败的命令是命令的一部分,则shell不会退出 紧跟while或until关键字part之后的命令列表 在if语句中执行的任何命令的一部分&& 或| | |列表,除了最后的&&或| |后面的
- set-e
- 集-a
help set
输出为:
set: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
Set or unset values of shell options and positional parameters.
Change the value of shell attributes and positional parameters, or
display the names and values of shell variables.
Options:
-a Mark variables which are modified or created for export.
-b Notify of job termination immediately.
-e Exit immediately if a command exits with a non-zero status.
-f Disable file name generation (globbing).
-h Remember the location of commands as they are looked up.
-k All assignment arguments are placed in the environment for a
command, not just those that precede the command name.
-m Job control is enabled.
-n Read commands but do not execute them.
-o option-name
Set the variable corresponding to option-name:
allexport same as -a
braceexpand same as -B
emacs use an emacs-style line editing interface
errexit same as -e
errtrace same as -E
functrace same as -T
hashall same as -h
histexpand same as -H
history enable command history
ignoreeof the shell will not exit upon reading EOF
interactive-comments
allow comments to appear in interactive commands
keyword same as -k
monitor same as -m
noclobber same as -C
noexec same as -n
noglob same as -f
nolog currently accepted but ignored
notify same as -b
nounset same as -u
onecmd same as -t
physical same as -P
pipefail the return value of a pipeline is the status of
the last command to exit with a non-zero status,
or zero if no command exited with a non-zero status
posix change the behavior of bash where the default
operation differs from the Posix standard to
match the standard
privileged same as -p
verbose same as -v
vi use a vi-style line editing interface
xtrace same as -x
-p Turned on whenever the real and effective user ids do not match.
Disables processing of the $ENV file and importing of shell
functions. Turning this option off causes the effective uid and
gid to be set to the real uid and gid.
-t Exit after reading and executing one command.
-u Treat unset variables as an error when substituting.
-v Print shell input lines as they are read.
-x Print commands and their arguments as they are executed.
-B the shell will perform brace expansion
-C If set, disallow existing regular files to be overwritten
by redirection of output.
-E If set, the ERR trap is inherited by shell functions.
-H Enable ! style history substitution. This flag is on
by default when the shell is interactive.
-P If set, do not resolve symbolic links when executing commands
such as cd which change the current directory.
-T If set, the DEBUG trap is inherited by shell functions.
-- Assign any remaining arguments to the positional parameters.
If there are no remaining arguments, the positional parameters
are unset.
- Assign any remaining arguments to the positional parameters.
The -x and -v options are turned off.
Using + rather than - causes these flags to be turned off. The
flags can also be used upon invocation of the shell. The current
set of flags may be found in $-. The remaining n ARGs are positional
parameters and are assigned, in order, to $1, $2, .. $n. If no
ARGs are given, all shell variables are printed.
Exit Status:
Returns success unless an invalid option is given.
我发现set-e表示在非零状态下退出。现在需要知道-a选项的含义。您是否尝试过
手动设置
?它将带您进入列出bash内置项的手册页,其中有一节解释了set
的所有选项。请运行manbash
以找到答案。@Tom,我想您的意思是帮助集
?这里(Debian),没有set
手册页。man-set
在我的一台Jessie机器上工作,但在另一台机器上没有。我检查了一下,发现手册页在(可选)manpages-posix
包中<代码>帮助集当然是Bash内置的,因此始终可用。更新的文档有更好的解释:-a为创建或修改的每个变量或函数指定导出属性,并标记为导出到后续命令的环境中。”