cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/14/22:20:45

Date: Tue, 14 Oct 1997 19:20:02 -0700 (PDT)
Message-Id: <199710150220.TAA04074@adit.ap.net>
Mime-Version: 1.0
To: djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: DOS ugliness affects grep

The Problem:
When you write to DOS's CON driver, it stops writing when it encounters an
EOF character (ASCII 0x1A, ^Z).

The Effect:
If you use `grep' on a binary file (or on `*' when there are binary files in
the directory), and it finds a matching "line" which contains a ^Z, it will
give a misleading error message about ENOSPC because the count was short. It
will also only print the first part of the "line", before the ^Z. This will
not occur if you redirect stdout, for obvious reasons.

More Details:
Actually what happens is that when _write() detects a short count being
written, it sets errno to ENOSPC. fwrite(), which `grep' uses, notices this
and sets the `error' flag on the stream. When `grep' calls ferror(), it
finds out about this and prints the error message.

I realize this is DOS's fault and not DJGPP's, and no workarounds come
immediately to mind. I'm also not too concerned about getting it fixed,
since it's only cosmetic, and `grep'ing binary files to the console isn't
very meaningful anyway. But I thought I'd throw it out there.

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019