![bash:调试(xtrace)重定向目标](https://linux22.com/image/204896/bash%EF%BC%9A%E8%B0%83%E8%AF%95%EF%BC%88xtrace%EF%BC%89%E9%87%8D%E5%AE%9A%E5%90%91%E7%9B%AE%E6%A0%87.png)
有没有办法显示重定向bash -x
?
$ bash -exc 'for word in foo bat baz; do echo $word >$word; done'
+ for word in foo bat baz
+ echo foo
+ for word in foo bat baz
+ echo bat
+ for word in foo bat baz
+ echo baz
我想要这样的输出,以便可以执行脚本#!/usr/bin/env -S bash -ex
并描述其所需的步骤:
$ bash -exc 'for word in foo bat baz; do echo $word >$word; done'
+ for word in foo bat baz
+ echo foo >foo
+ for word in foo bat baz
+ echo bat >bat
+ for word in foo bat baz
+ echo baz >baz
我尝试在互联网上搜索,但关键字 bash、debug 和redirection 导致了有关如何重定向调试日志的问题,但没有涉及如何记录/调试重定向的问题。