The format of the trap command is.
trap命令的格式为。
To catch a signal that is sent to your process, use the built-in trap command.
要捕捉发送到您的进程的信号,请使用内置的trap命令。
The first is the return status from a command, and the second is the trap command within your shell.
第一个是命令的返回状态,第二个是外壳中的trap命令。
When a signal is caught, the current command being executed attempts to complete before the trap command takes over.
在捕捉到信号后,正在执行的当前命令会尝试在trap接管之前结束执行。
The first trap command causes the stopsleep function to be run whenever a SIGCHLD, SIGINT, or SIGTERM signal is received.
第一个trap命令将使stopsleep函数在接受到SIGCHLD、SIGINT或SIGTERM信号时运行。
The ERR goes with the signal list within the trap command. In the following example, a non-existent file is copied, which invokes an error
ERR在trap命令中提供了一个信号列表。
The trap command prevents the script from being interrupted by the user (by pressing control-C during boot, for example) while the script executes.
trap命令防止用户在脚本执行时中断(例如,在引导时键入control - c)脚本。
A message displays containing the line number and command when the trap was caught; the script then exits (from the exit command on the trap command list).
在捕捉到trap后,会显示一条包含行号和命令的消息;脚本随后将退出执行(使用trap命令列表中的exit命令)。
To use trap, you specify the command or function to be executed when the signal is trapped, and the signal number or Numbers that you want to trap, as shown here in Listing 13.
要使用跟踪,可以指定跟踪到信号时执行的命令或函数、要跟踪的信号编号,如此处的清单13中所示。
Errexit: if a command has an exit status of anything but 0 (zero), execute the err trap (if it is set and exists).
errexit:如果某个命令产生非0(零)的退出状态并且设置了err陷阱,则执行err陷阱并退出。
Errexit: if a command has an exit status of anything but 0 (zero), execute the err trap (if it is set and exists).
errexit:如果某个命令产生非0(零)的退出状态并且设置了err陷阱,则执行err陷阱并退出。
应用推荐