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

Re: Odd behavior with various (q) array modifiers and non-printable characters (backspace, newline)



On Thu, Oct 21, 2021 at 7:24 AM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> Zach Riggle wrote on Tue, Oct 19, 2021 at 14:17:48 -0500:
> > print-a-$-and-then-the-minally-quoted-version-of-this-array-of-scalars when
> > dealing with regex, due to "builtin echo" treating '\bfoo bar\b'
> > incorrectly.
>
> Why, does it output «\b» literally (two printable characters)?  It
> should emit backspaces (ASCII 0x08).

He's trying to use \b as a word boundary marker in a regular
expression so he wants literal \b rather than backspace.

% builtin echo '\bfoo bar\b' | od -ac
0000000  bs   f   o   o  sp   b   a   r  bs  nl
         \b   f   o   o       b   a   r  \b  \n
0000012
% command echo '\bfoo bar\b' | od -ac
0000000   \   b   f   o   o  sp   b   a   r   \   b  nl
          \   b   f   o   o       b   a   r   \   b  \n
0000014

(apologies if you're looking at this in a proportional font)




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