Zsh Mailing List Archive
Messages sorted by:
Re: Little problem while converting from bash (quoting/splitting?)
- X-seq: zsh-users 8831
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Little problem while converting from bash (quoting/splitting?)
- Date: Sun, 15 May 2005 18:48:25 +0000
- In-reply-to: <20050515134623.M88380@xxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20050512060921.M13778@xxxxxx> <1050512162911.ZM17235@xxxxxxxxxxxxxxxxxxxxxxx> <20050515134623.M88380@xxxxxx>
On May 15, 4:48pm, krasnal wrote:
} Subject: Re: Little problem while converting from bash (quoting/splitting?
} On Thu, 12 May 2005 16:29:11 +0000, Bart Schaefer wrote
} > Bash apparently reads stdin/stdout pipes in text mode, whereas zsh
} > does so in binary mode.
} I understand the difference but I'm not sure I follow your arguments
} here :)). Why reading in text mode would be problematic?
Suppose you have 7663 bytes of data containing 97 \r\n sequences. You
don't know whether it's text or binary data.
Read it in text mode, where \r\n is automatically converted to \n, and
stuff the entire contents into a variable. That variable will contain
only 7566 bytes. Information has been lost.
Zsh is capable of dealing sensibly with non-text values stored in
variables, so it was deemed more appropriate to treat text as binary
(no information loss) than the other way around. The exception for
reading files is made because the Cygwin platform supports filesystems
that force all reads and writes to be in text mode. Zsh doesn't know
what kind of filesystem it's reading/writing for any given file, so the
only way to assure that all file reads and writes behave the same is
to treat them all as text, regardless of the filesystem type.
Once the data is in a pipe, though, all filesystem-enforced conversions
can be assumed already to have occured, so it's safer to treat the data
as binary, and not convert it any further.
Messages sorted by: