Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

RE: Under Cygwin ZSH, "diff -" fails unless forced into text mode

Peter Stephenson wrote:
>>  zsh% cat foo | diff - foo
>>  diff: -: Illegal seek
>>  zsh%
> The short, but unsatisfactory, answer is that it's not required to
> work.  diff expects to have a seekable file, for which a pipe doesn't
> necessarily qualify: it depends partly on the OS and also partly on how
> far back you need to seek, so you sometimes get away with it.

I'd call expecting stdin to be seekable a bug in diff,
although presumably ZSH-USERS isn't the right forum for
that discussion. (I guess HELP-GNU-UTILS would be.)

>> It passes if I force it into text mode:
>>  zsh% cat foo | diff -a - foo
>>  zsh%
> There's some Cygwin-specific code in main.c to force read-only files
> into text mode.  This is a fairly murky area and I have no idea how that
> affects pipes.

I'm not sure where you're headed with that one, but it
appears that ZSH is making the pipe appear as a binary
stream in this case. Forcing it *back* to text is what
fixes the problem.

I know there are similar issues with UTF-8 encodings on
Linux, and I have at times worked around it by setting
LANG= or LANG=C or something similar (I haven't delved
into it too deeply, although it looks like some of the
workarounds aren't as successful with some of the newer
versions of Linux). But this issue is happening all of
the time on Cygwin, and so far I haven't figured a way
to suppress it. Other shells do not act this way.


Messages sorted by: Reverse Date, Date, Thread, Author