Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug Report: Escaped backslash incorrectly reinterpreted as control escape in double-quoted strings



Hi Oliver,

Thanks for the explanation. I had no idea the echo behaviour depended on BSD (BSD-like) vs SysV, so that explains why I was seeing different results. The tip about printf for portability is also super helpful.

Really appreciate you taking the time.
Jelius


On Thu, Nov 27 2025 at 01:35:10 AM +01:00:00, Oliver Kiddle <opk@xxxxxxx> wrote:
Jelius Basumatary wrote:
Example: “\\t…” instead of printing “\t…” it would print “ ….” even if the backslash was escaped, also bash prints it correctly as “\t…” .
Actually, bash behaves differently depending on whether it is running on a BSD or SysV derived Unix. So on Solaris, you get a tab character while on FreeBSD, it prints \t ksh (at least the real AT&T one) does likewise. Linux is of course not derived from either BSD or System V. It does new file group ownership the SysV way, ps is a hybrid (but I think it was BSD style early on) and Linux echo is BSD-like. Note also that the zsh option to change this behaviour is named BSDECHO. If you want reliable and portable printing in a shell script, use printf. Oliver


Messages sorted by: Reverse Date, Date, Thread, Author