From: Stephane Chazelas <stephane@chazelas.org>
To: Pier Paolo Grassi <pierpaolog@gmail.com>
Cc: Sebastian Gniazdowski <sgniazdowski@gmail.com>,
Mikael Magnusson <mikachu@gmail.com>,
Zsh-Users List <zsh-users@zsh.org>
Subject: read -r and bad surprises (Was: indirect assignment to array)
Date: Thu, 16 Apr 2020 21:24:51 +0100 [thread overview]
Message-ID: <20200416202451.gb5ft5f7mrpre6bf@chazelas.org> (raw)
In-Reply-To: <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
next prev parent reply other threads:[~2020-04-16 20:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-15 23:01 indirect assignment to array Pier Paolo Grassi
2020-04-15 23:13 ` Mikael Magnusson
2020-04-15 23:42 ` Pier Paolo Grassi
2020-04-15 23:54 ` Bart Schaefer
2020-04-16 0:05 ` Pier Paolo Grassi
2020-04-16 0:12 ` Bart Schaefer
2020-04-16 16:02 ` Pier Paolo Grassi
2020-04-16 16:28 ` Sebastian Gniazdowski
2020-04-16 18:04 ` Pier Paolo Grassi
[not found] ` <CAP+y1xDa=fUvaP=gwbawRmcfwjq0ZH1KEnt=wTX4zOKaT4mzyQ__13411.9792653777$1587060411$gmane$org@mail.gmail.com>
2020-04-16 20:24 ` Stephane Chazelas [this message]
2020-04-16 21:06 ` read -r and bad surprises (Was: indirect assignment to array) Pier Paolo Grassi
[not found] ` <CAP+y1xAG3ayQNE3JqeF_YOT5FZ9pLiUAF5TmPVoOv+nPyjK30A__22203.4378488146$1586994256$gmane$org@mail.gmail.com>
2020-04-16 16:30 ` indirect assignment to array Stephane Chazelas
2020-04-16 16:37 ` Pier Paolo Grassi
2020-04-16 17:37 ` Bart Schaefer
2020-04-16 17:43 ` Pier Paolo Grassi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200416202451.gb5ft5f7mrpre6bf@chazelas.org \
--to=stephane@chazelas.org \
--cc=mikachu@gmail.com \
--cc=pierpaolog@gmail.com \
--cc=sgniazdowski@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).