bash 脚本常用的四个选项(set builtins): set -xueo pipefail 分别为: Print a trace of simple commands, for commands, case commands, select commands, and arithmetic for commands and their arguments or associated word lists after they a ...
在bash脚本中习惯了在脚本头部加上set -e内置命令,使得脚本里任何一行命令的退出状态码为非零时,shell立即退出。然而最近发现一个bug,排查了很久才找到原因,记录一下。 需求是在for循环中进行一系列由管道连接的操作,大致如下: #!/bin/bash set -e ... for id in `something`;do cmd1 | cm ...