Mail Archives: cygwin/1999/07/25/01:14:48
On 23-Jul-1999, Jeffry T Ross <jtr AT mitre DOT org> wrote:
> Randy
>
> I thought the suggestion to use dd was a good, although a bit excessive
> when one only wants to move bytes from a file to a pipe without any
> conversion. So I tried it:
>
> dd if=test1 > test2
> test1 was 1296 bytes and test2 became 1301 bytes.
>
> So then I tried dd directly to a file.
> dd if=test1 of=test2
> this worked fine.
>
> So now I don't suspect cat but the piping and redirection.
I think the symptom that you report above is a bug in `dd'
(i.e. `dd' has not been properly ported to Cygwin).
> The question is how does cygwin implement it's piping and redirection?
By default, stdin, stdout, and stderr are assumed to use text mode.
If a program such as `dd' wishes to use stdin/stdout/stderr in binary
mode, then it should be modified to do so.
The issue here is basically the same as passing extra flags to open()
and fopen() to say that files should be opened in binary mode.
It's a little bit more complicated, though, since stdin/stdout/stderr
are already open. However, there should be a way of changing the mode
of an already open file. I don't recall off-hand what it is, though.
(I vaguely recall some mention of a setmode() function, but I could be
way off base with that...)
> Is this problem imposed by the underlying WIN/DOS or is it a bug in BASH?
Bash doesn't know whether the underlying program (e.g. `dd') will use
the stream in text or binary mode, so there's nothing bash can do.
I suppose you could add special syntax for redirection in binary mode,
so that the user could type e.g. "dd if=test1 >@ test2", but
it makes much more sense for it to be the program's responsibility to
use its files in the right mode rather than for this to be the user's
responsibility.
--
Fergus Henderson <fjh AT cs DOT mu DOT oz DOT au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh AT 128 DOT 250 DOT 37 DOT 3 | -- the last words of T. S. Garp.
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
- Raw text -