Using zsh
, I'd like to create an alias or a shell function that operates as follows:
I want this alias or shell function to echo its command line without honoring any shell control characters such as <
or >
or &
or $
or "
or others.
In other words, consider the following example, where I'm using "xxx" as the name of this proposed alias or shell function:
xxx ls -Flastr "${something}" >/tmp/xyz &
It would simply echo the following as follows, without executing it, including the >
and &
and $
and {
and }
and "
, and without honoring any of those special characters:
ls -Flastr "${something}" >/tmp/xyz &
I know I can do this by quoting the rest of the command line after the "xxx" and possibly escaping certain characters, but I'm looking for a way to make this occur without any extra quoting or escaping.
Also, I want this to be in effect only for the one, single line which is invoked via this alias or shell function, and not for the entire script.
Is this even possible under zsh
?
Thank you in advance.
ls ...
command that I used an example above appears in a script, I'd like to prefix that command withxxx
in the script and run the script to see if that code actually is reached, without it being executed. And I want the rest of the script to indeed be executed.preexec
shell function which receives the entire command before special character substitution. However, thatpreexec
function cannot change the value of the command to be executed. What I want is something likepreexec
which will also prevent the command from actually being executedzsh 5.8
under Ubuntu. I used the exact same example that was given in that "Answer", but nothing gets printed at all via that function.