아래 명령이 bash에서 무엇을하는지 알고 싶습니다.set -e 및 set -a는 bash에서 무엇을합니까? set 명령과 함께 사용할 수있는 다른 옵션은 무엇입니까
- 세트
- 세트 -a -e
내가 세트로 사용하고 그 의미 할 수있는 다른 옵션은 무엇입니까. 가입일
아래 명령이 bash에서 무엇을하는지 알고 싶습니다.set -e 및 set -a는 bash에서 무엇을합니까? set 명령과 함께 사용할 수있는 다른 옵션은 무엇입니까
내가 세트로 사용하고 그 의미 할 수있는 다른 옵션은 무엇입니까. 가입일
man page : 후속 명령
의 환경 수출 수정되거나 생성 된 마크 변수와 함수 -a
-e 출구 바로 만약 파이프 (파이프 라인을 참조), 이는 단일 명령 (단순 명령 참조), 목록 (목록 참조), 또는 복합 명령 (복합 명령 참조)으로 구성되어상태가 아닌 값을 반환합니다. 실패 명령이 명령 목록을 즉시 동안 또는 키워드 때까지 다음 의 일부가 & & 또는 실행 모든 명령의 문 경우, 부분적으로, 시험의 일부 경우, 쉘은 종료되지 않습니다 || 최종 & & 또는 ||의 파이프 라인에있는 모든 명령 다음의 명령을 제외하고, 또는 명령의 반송 상태 이! 서브 쉘 이외의 복합 명령이 -e가 무시 된 동안 명령이 실패했기 때문에 0이 아닌 상태를 리턴하면 쉘은 종료하지 않습니다. ERR이 설정된 경우, 쉘이 종료되기 전에 이 실행됩니다.
이 옵션은 쉘 환경에 적용되며 각 (명령 실행 환경 참조) 별도 환경을 서브 쉘 및 원인 서브 쉘이 서브 쉘에서 모든 명령을 실행하기 전에 종료 할 수 있습니다.
화합물 명령 또는 쉘 함수 -e 은, 화합물 명령 또는 함수 본문 내에서 실행되는 명령의 어떤 것도 -e 설정이 적용되지 않으며 무시되는 상황에서 실행하면
,하더라도 -e 이 설정되고 명령이 실패 상태를 리턴합니다. 복합 명령 또는 셸 함수가 -e가 무시되는 컨텍스트에서 실행 중 -e를 설정하면 복합 명령이나 함수 호출 이 포함 된 명령이 완료 될 때까지 해당 설정이 적용되지 않습니다.
시도 실행 :
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.
내가 -e 비 제로 상태에서 종료를 의미 설정 발견. 이제 -a 옵션의 의미를 알아야합니다. – thinkingmonster
'man set'을 사용해 보셨습니까? 그것은'set'에 대한 모든 옵션을 설명하는 섹션이있는 bash 내장 명령을 나열하는 맨 페이지로 연결됩니다. –
대답을 찾으려면'man bash'를 실행하십시오. – gzh