News for hackers. Stuff that matters.
Re:Filenames and Pathnames in Shell: How to Do It Correctly by Calzifer on Tuesday June 20, 2023 @07:07AM (#36402324)
> One nice thing about bash is the ${var@Q} syntax that is great for printing stuff and deals with the potential for stuff that affects the terminal in a much nicer way than piping through tr.

An alternative which works in both Bash and Zsh is

  printf %q "$var"
using /usr/bin/printf %q "$var" has even a good chance to work in other shells.

And as fun fact: the Zsh equivalent for Bash's ${var@@} is ${(q)var} and it was not enough to have one quoting style but instead you can also provide qq, qqq, qqqq, q+ or q- all with a different result.

https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parame...

There are no comments on this comment yet.