- 论坛徽章:
- 0
|
- #!/bin/bash
- set -o pipefail
- set -E
- trap 'echo "ERR CATCHED in LINE: ${LINENO}"' ERR
- ls FILE_NOT_EXIST_00
- [b]ls FILE_NOT_EXIST_01 | while read LINE ; do
- echo "in while: $LINE"
- done[/b]
- ls FILE_NOT_EXIST_02 | head
- exit 0
复制代码 执行的输出结果是:- ls: cannot access FILE_NOT_EXIST_00: No such file or directory
- ERR CATCHED in LINE: 8
- ls: cannot access FILE_NOT_EXIST_01: No such file or directory
- ls: cannot access FILE_NOT_EXIST_02: No such file or directory
- ERR CATCHED in LINE: 15
复制代码 ls FILE_NOT_EXIST_01 | while read LINE ; 这个错误没有被捕捉到... 有点奇怪!
我的bash版本是“GNU bash, version 3.2.33(1)-release (i386-redhat-linux-gnu)” |
|