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)
- X-seq: zsh-users 26931
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Lawrence Velázquez <larryv@xxxxxxx>
- Cc: Zach Riggle <zachriggle@xxxxxxxxx>, zsh-users@xxxxxxx
- Subject: Re: Odd behavior with various (q) array modifiers and non-printable characters (backspace, newline)
- Date: Sat, 14 Aug 2021 15:52:52 +0000
- Archived-at: <https://zsh.org/users/26931>
- In-reply-to: <27bc215c-3916-4afe-b8b3-7946dd0cb4bc@www.fastmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAMP9c5k=MRwfuR_xNzJjUAMO8ds7Kr=OpM2QMD9+A9hLKHu3iw@mail.gmail.com> <CAH+w=7bkaBZYR0Ok+zwqEqNDAjRDK1GyP9k74wY4-X+6jOrTEw@mail.gmail.com> <27bc215c-3916-4afe-b8b3-7946dd0cb4bc@www.fastmail.com>
Lawrence Velázquez wrote on Wed, Aug 11, 2021 at 17:42:09 -0400:
> On Wed, Aug 11, 2021, at 5:16 PM, Bart Schaefer wrote:
> > You need to stop testing things with "echo". The "echo" builtin
> > interprets some backslash escapes itself, which will confuse you about
> > what the quoting options have done.
> >
> > Repeat all your tests instead with
> > printf "%s\n" ${(q)...}
> > and so on, and come back if you still have questions.
>
> Additionally, \b and \n are not interpreted in double quotes, so
> your initial data does not actually contain BS or NL characters.
⋮
> As per the QUOTING section of zshmisc(1):
>
> Inside double quotes (""), parameter and command substitution
> occur, and `\' quotes the characters `\', ``', `"', `$',
> and the first character of $histchars (default `!').
There are third-party plugins that implement syntax highlighting at the
prompt (I happen to co-maintain one such plugin). Those plugins are
aware of the quoted docs section, so on input such as
.
% foo "bar \n \\ \x"
.
they will correctly highlight only the «\\» as an escape sequence, and
everything else as literals.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author