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 26924
- From: Lawrence Velázquez <larryv@xxxxxxx>
- To: "Zach Riggle" <zachriggle@xxxxxxxxx>
- Cc: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>, zsh-users@xxxxxxx
- Subject: Re: Odd behavior with various (q) array modifiers and non-printable characters (backspace, newline)
- Date: Wed, 11 Aug 2021 20:34:05 -0400
- Archived-at: <https://zsh.org/users/26924>
- In-reply-to: <CAH+w=7YKt1HZDPWKn_c4QgV0hpiOqJmWo9DSoYSJnQvk2S9Q0w@mail.gmail.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> <CAMP9c5krwMUZpe+PiUPsMSUQVMbu50-eb9ShDY3bPtouobsCiw@mail.gmail.com> <CAH+w=7YKt1HZDPWKn_c4QgV0hpiOqJmWo9DSoYSJnQvk2S9Q0w@mail.gmail.com>
On Wed, Aug 11, 2021, at 8:22 PM, Bart Schaefer wrote:
> On Wed, Aug 11, 2021 at 4:25 PM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
> >
> > TLDR 2: I also learned that (q+) is my new favorite, and my code
> > should use "command echo" to avoid the above behavior.
>
> You more likely want "setopt BSD_ECHO".
>
> You can also use
> disable echo
> but that might have unexpected side-effects on scripts written by others.
A third option is to stick to
print -r -- $foo
or
printf '%s\n' $foo
which behave predictably and are zsh builtins. (The latter is also
POSIX-compliant.)
--
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author