1

How to merge set -x and set -v in ash? (or set -v with a prefix)

In other words, echo back command upon running.

The DEBUG signal does not exist in ash: DEBUG: invalid signal specification.

set -x

$ echo > foo.txt # Normal
$ set -x
$ echo > foo.txt # Example
+ echo
$ # Missing "> foo.txt # Example"

set -v

$ echo > foo.txt # Normal
$ set -v
$ echo > foo.txt # Example
echo > foo.txt # Example
$ # Missing prefix "> "

set -xv

$ echo > foo.txt # Normal
$ set -vx
$ echo > foo.txt # Example
echo > foo.txt # Example
+ echo
$ # Now there are two problems... (missing "> foo.txt  # Example" and missing prefix "> ")

Desired

$ echo > foo.txt # Normal
$ magic_command "> "
$ echo > foo.txt # Example
> echo > foo.txt # Example
$ ls
> ls
foo.txt
wjwrpoyob
  • 366
  • 1
  • 12
  • @muru, I've reopened as the dup ([Formatting display of of \`set -v\` output](https://unix.stackexchange.com/q/430480)) is about bash where the answer uses the DEBUG trap, and the OP is clearly aware that the DEBUG trap can't be used here – Stéphane Chazelas Apr 13 '23 at 05:27
  • @StéphaneChazelas sure, the original post didn't mention ash at all and was tagged bash. I guess OP wasn't aware which shell they were using at the time. – muru Apr 13 '23 at 06:08

0 Answers0