From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21425 invoked from network); 27 Jan 2002 21:32:31 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 27 Jan 2002 21:32:31 -0000 Received: (qmail 20181 invoked by alias); 27 Jan 2002 21:32:16 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16501 Received: (qmail 20154 invoked from network); 27 Jan 2002 21:32:15 -0000 From: "Bart Schaefer" Message-Id: <1020127213209.ZM9378@candle.brasslantern.com> Date: Sun, 27 Jan 2002 21:32:09 +0000 In-Reply-To: <20020127202405.GB32151@dman.com> Comments: In reply to Clint Adams "[goswin.brederlow@student.uni-tuebingen.de: Bug#131063: zsh: read -r removes \ in \\]" (Jan 27, 3:24pm) References: <20020127202405.GB32151@dman.com> X-Mailer: Z-Mail (5.0.0 30July97) To: Clint Adams , zsh-workers@sunsite.dk Subject: Re: [goswin.brederlow@student.uni-tuebingen.de: Bug#131063: zsh: read -r removes \ in \\] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jan 27, 3:24pm, Clint Adams wrote: } Subject: [goswin.brederlow@student.uni-tuebingen.de: Bug#131063: zsh: read } } ----- Forwarded message from Goswin Brederlow ----- } } ~% echo "\\" } \ } ~% echo "\\" | read -r i; echo "$i" } \ } ~% echo "\\\\\\\\" } \\ } ~% echo "\\\\\\\\" | read -r i; echo "$i" } \ } } The manpage says read -r does not remove \. `read -r' didn't remove the backslash. `echo "$i"' removed it, as was pointed out a moment later: } Also echo removes \: } } ~% echo "\\\\" } \ } } bash will print \\ as intendet. Any reason? (ksh/pdksh print \ I was } told). zsh/ksh use the SysV definition of `echo' by default; bash uses the BSD definition, it would appear. If one had RTM, one would have found that `echo -E' does what you meant -- or else you can set the BSD_ECHO option to get that behavior all the time. So let's try the first example again with BSD_ECHO set: schaefer[508] setopt BSD_ECHO schaefer[509] echo "\\" \ In this case it was double-quoted expansion that removed the backslash. Using single quotes shows that it was not echo that removed it: schaefer[513] echo '\\' \\ Now back to the example: schaefer[510] echo "\\" | read -r i; echo "$i" \ schaefer[511] echo "\\\\\\\\" \\\\ schaefer[512] echo "\\\\\\\\" | read -r i; echo "$i" \\\\ Neither read nor echo has removed any backslashes. Only double-quoting did so. Again trying the same thing with single quotes: schaefer[514] echo '\\\\\\\\' | read -r i; echo "$i" \\\\\\\\ This is all working exactly as documented. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net