找出导出管道里的 bug

来自 管道与重定向
GNU Bash 5.2.21 进阶 7分钟 找出 2处问题

找出这段生成的导出管道在数据完整性和状态处理上的错误。

Shell
set -o pipefail
export_rows() {
  printf '%s\n' '{"id":104}'
  printf '%s\n' 'warning: stale replica' >&2
  return 6
}
export_rows 2>&1 | tee export.log | jq -s '.' > export.json
printf 'saved %s\n' "$?"
stages=("${PIPESTATUS[@]}")
在试验场中打开
报告错误