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 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