From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 4141 invoked from network); 16 Apr 2020 20:25:48 -0000 Received-SPF: pass (primenet.com.au: domain of zsh.org designates 203.24.36.2 as permitted sender) receiver=inbox.vuxu.org; client-ip=203.24.36.2 envelope-from= Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with UTF8ESMTPZ; 16 Apr 2020 20:25:48 -0000 Received: (qmail 9483 invoked by alias); 16 Apr 2020 20:25:35 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24786 Received: (qmail 398 invoked by uid 1010); 16 Apr 2020 20:25:35 -0000 X-Qmail-Scanner-Diagnostics: from relay6-d.mail.gandi.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25779. spamassassin: 3.4.4. Clear:RC:0(217.70.183.198):SA:0(-2.6/5.0):. Processed in 3.802532 secs); 16 Apr 2020 20:25:35 -0000 X-Envelope-From: stephane@chazelas.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _nblcust.gandi.net designates 217.70.183.198 as permitted sender) X-Originating-IP: 94.3.152.49 Date: Thu, 16 Apr 2020 21:24:51 +0100 From: Stephane Chazelas To: Pier Paolo Grassi Cc: Sebastian Gniazdowski , Mikael Magnusson , Zsh-Users List Subject: read -r and bad surprises (Was: indirect assignment to array) Message-ID: <20200416202451.gb5ft5f7mrpre6bf@chazelas.org> Mail-Followup-To: Pier Paolo Grassi , Sebastian Gniazdowski , Mikael Magnusson , Zsh-Users List References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 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 $ print -r ' a\b ' | read a; printf '<%s>\n' $a See https://unix.stackexchange.com/questions/209123/understanding-ifs-read-r-line for details. -- Stephane