zsh-workers
 help / color / mirror / code / Atom feed
* [goswin.brederlow@student.uni-tuebingen.de: Bug#131063: zsh: read -r removes \ in \\]
@ 2002-01-27 20:24 Clint Adams
  2002-01-27 21:32 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Clint Adams @ 2002-01-27 20:24 UTC (permalink / raw)
  To: zsh-workers

----- Forwarded message from Goswin Brederlow <goswin.brederlow@student.uni-tuebingen.de> -----

~% echo "\\"                       
\
~% echo "\\" | read -r i; echo "$i"
\
~% echo "\\\\\\\\"                       
\\
~% echo "\\\\\\\\" | read -r i; echo "$i"
\

The manpage says read -r does not remove \.


Also echo removes \:

~% echo "\\\\"                     
\

bash will print \\ as intendet. Any reason? (ksh/pdksh print \ I was
told).

MfG
	Goswin

-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux dual 2.4.16 #9 SMP Sat Jan 26 16:39:53 CET 2002 i686
Locale: LANG=C, LC_CTYPE=de_DE

Versions of packages zsh depends on:
ii  libc6                    2.2.5-1         GNU C Library: Shared libraries an
ii  libcap1                  1:1.10-12       support for getting/setting POSIX.
ii  libncurses5              5.2.20020112a-3 Shared libraries for terminal hand


----- End forwarded message -----


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [goswin.brederlow@student.uni-tuebingen.de: Bug#131063: zsh: read -r removes \ in \\]
  2002-01-27 20:24 [goswin.brederlow@student.uni-tuebingen.de: Bug#131063: zsh: read -r removes \ in \\] Clint Adams
@ 2002-01-27 21:32 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2002-01-27 21:32 UTC (permalink / raw)
  To: Clint Adams, zsh-workers

On Jan 27,  3:24pm, Clint Adams wrote:
} Subject: [goswin.brederlow@student.uni-tuebingen.de: Bug#131063: zsh: read
}
} ----- Forwarded message from Goswin Brederlow <goswin.brederlow@student.uni-tuebingen.de> -----
} 
} ~% 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   


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-01-27 21:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-27 20:24 [goswin.brederlow@student.uni-tuebingen.de: Bug#131063: zsh: read -r removes \ in \\] Clint Adams
2002-01-27 21:32 ` Bart Schaefer

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).