Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: read -r and bad surprises (Was: indirect assignment to array)
thanks, fortunately I already crossed that bridge, as my read alias can
testify:
alias \read
read='IFS='''' read -r'
Pier Paolo Grassi
linkedin: https://www.linkedin.com/in/pier-paolo-grassi-19300217
founder: https://www.meetup.com/it-IT/Machine-Learning-TO
Il giorno gio 16 apr 2020 alle ore 22:24 Stephane Chazelas <
stephane@xxxxxxxxxxxx> ha scritto:
> 2020-04-16 20:04:57 +0200, Pier Paolo Grassi:
> [...]
> > thanks but I really hate when I find out bugs that i never have thought
> of
> > (a big one has been discovering the -r flag to read)
> [...]
>
> While you're there, note that the syntax to read a line of input
> verbatim is:
>
> IFS= read -r line
>
> not just read -r line.
>
> Compare:
>
> $ print -r ' a\b ' | IFS= read -r a; printf '<%s>\n' $a
> < a\b >
> $ print -r ' a\b ' | read -r a; printf '<%s>\n' $a
> <a\b>
> $ print -r ' a\b ' | read a; printf '<%s>\n' $a
> <ab>
>
> See
> https://unix.stackexchange.com/questions/209123/understanding-ifs-read-r-line
> for details.
>
> --
> Stephane
>
--
Pier Paolo Grassi
Messages sorted by:
Reverse Date,
Date,
Thread,
Author