On Jun 11, 2018, at 4:50 PM, Gordon Messmer
<gordon.messmer(a)gmail.com> wrote:
On 06/11/2018 02:31 PM, Bev in TX wrote:
>
> It’s an option of the builtin set command.
>
> set …
> … When options are specified, they set or unset shell attributes. ….
> -v Print shell input lines as they are read.
Yeah, that also *kinda* works. That'll print lines as they're read, not as
they're executed, so you *do* get the lines before expansion, but you won't get
quiet what is expected (I think) if those lines appear in a loop or a function.
_______________________________________________
It may not be perfect, but it helps in many situations.
I set a debug flag in my main script (often passed as a script argument, e.g., myscript
-d). That flag can be checked in loops and/or passed to functions. If the flag is set I
then execute set -x or whichever form is desired. This way I have a form of debugging
built into the script at all times, but it has little impact production usage.
Bev in TX