NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/39574: /bin/echo always exits zero even when it encounters I/O errors



The following reply was made to PR bin/39574; it has been noted by GNATS.

From: Ed Ravin <eravin%panix.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: bin/39574: /bin/echo always exits zero even when it encounters
        I/O errors
Date: Wed, 17 Sep 2008 22:18:53 -0400

 On Wed, Sep 17, 2008 at 10:25:00PM +0000, gnats-admin%netbsd.org@localhost 
wrote:
 > >Category:       bin
 > >Responsible:    bin-bug-people
 > >Synopsis:       /bin/echo always exits zero even when it encounters I/O 
 > >errors
 > >Arrival-Date:   Wed Sep 17 22:25:00 +0000 2008
 
 This might be a patch to fix the problem:
 
 --- echo.c      2003-11-24 22:40:18.000000000 -0500
 +++ echoiochk.c 2008-09-17 22:17:06.000000000 -0400
 @@ -65,12 +65,13 @@
                 nflag = 0;
 
         while (*argv) {
 -               (void)printf("%s", *argv);
 +               if (printf("%s", *argv) < 0) exit(1);
                 if (*++argv)
 -                       (void)putchar(' ');
 +                       if (putchar(' ') == EOF) exit(1);
 +
         }
         if (nflag == 0)
 -               (void)putchar('\n');
 +               if (putchar('\n') == EOF) exit(1);
         exit(0);
         /* NOTREACHED */
  }
 


Home | Main Index | Thread Index | Old Index