Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
read -r and bad surprises (Was: indirect assignment to array)
- X-seq: zsh-users 24786
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Pier Paolo Grassi <pierpaolog@xxxxxxxxx>
- Subject: read -r and bad surprises (Was: indirect assignment to array)
- Date: Thu, 16 Apr 2020 21:24:51 +0100
- Cc: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>, Mikael Magnusson <mikachu@xxxxxxxxx>, Zsh-Users List <zsh-users@xxxxxxx>
- In-reply-to: <CAP+y1xDa=fUvaP=gwbawRmcfwjq0ZH1KEnt=wTX4zOKaT4mzyQ__13411.9792653777$1587060411$gmane$org@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mail-followup-to: Pier Paolo Grassi <pierpaolog@xxxxxxxxx>, Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>, Mikael Magnusson <mikachu@xxxxxxxxx>, Zsh-Users List <zsh-users@xxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAP+y1xCb3NJn8BRsuwpO6XVgzAtGsBvP870M5na3mAH+CwJ_OA@mail.gmail.com> <CAHYJk3TmiNicTrwem6iRxKMxdNT5-ZB8W8vT5Gc=t7DrbPfBdQ@mail.gmail.com> <CAKc7PVBPMdox3+VE-unFVgmD+WT+u8H86+MwDmXKTKHQsKduOw@mail.gmail.com> <CAP+y1xDa=fUvaP=gwbawRmcfwjq0ZH1KEnt=wTX4zOKaT4mzyQ__13411.9792653777$1587060411$gmane$org@mail.gmail.com>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author