Hi,

I am running bash 5.2.15(3)-release (x86_64-pc-cygwin) on
cygwin running on Windows 10.

Bash lacks a proper way of echoing commands, which is
present in other shells, even in ones which are much less
powerful, like, e.g. Windows CMD.
This is not the same as debugging, for which set -x is devoted.
"set -x" makes the ensuing commands be printed, but prefixed
with "+ ", which makes the result look ugly, not to mention that
the following "set +x" is echoed too (there are hacks to suppress
the "set +x" output, but they are just hacks).
What is needed is something equivalent to the @echo on, @echo off
of the old DOS CMD, that are not printed and that enable/disable
echoing of commands without any debugging marks added (such as
"+" of set -x).
The solution could look like:

      set -o log
      cat tmp >tmp1        # or any other command
      set -o nolog

producing the output on the console

       cat tmp >tmp1

I would stress the importance of this: the purpose of scripts is
to execute commands, informing the caller of what they execute,
purged of all the builtins and other calculations the script does
in order to come to the commands.
Many solutions are posted in the internet, all of them are hacks with
lots of edge cases that make them fail in presence of commands
containing special characters, redirections, substitutions, etc.

Thank you
-Angelo Borsotti

Reply via email to