一部の機能のデバッグを支援するために、bash スクリプト内で「set -x」を使用してきましたが、非常にうまく機能しています。
-x After expanding each simple command, for command, case command,
select command, or arithmetic for command, display the expanded
value of PS4, followed by the command and its expanded arguments or
associated word list.
ただし、機能を終了する前にクリアできるようにしたい
例えば:
#/bin bash
function somefunction()
{
set -x
# some code I'm debugging
# clear the set -x
set ????
}
somefunction