NetBSD-Bugs archive

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

Re: bin/38004: /bin/sh truncates a message for unobvious reasons



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

From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: bin/38004: /bin/sh truncates a message for unobvious reasons
Date: Sun, 02 Sep 2018 06:48:16 +0700

     Date:        Sat,  1 Sep 2018 23:05:00 +0000 (UTC)
     From:        David Holland <dholland-bugs%netbsd.org@localhost>
     Message-ID:  <20180901230500.E933A7A1FA%mollari.NetBSD.org@localhost>
 
   |   >  So, what I propose to do is to make that small algorithm just a
   |   >  fraction smarter 
 
   |  That seems fine.
 
 What I tentatively have (in uncommitted, mostly untested so far) sources is ...
 
 --- jobs.c      30 Dec 2017 23:24:19 -0000      1.98
 +++ jobs.c      1 Sep 2018 23:36:32 -0000
 @@ -1509,8 +1509,12 @@
         int len;
  
         cmdnextc = ps->cmd;
 -       if (iflag || mflag || sizeof ps->cmd < 100)
 +       if (iflag || mflag || sizeof ps->cmd <= 60)
                 len = sizeof(ps->cmd);
 +       else if (sizeof ps->cmd <= 400)
 +               len = 50;
 +       else if (sizeof ps->cmd <= 800)
 +               len = 80;
         else
                 len = sizeof(ps->cmd) / 10;
         cmdnleft = len;
 
 which after all the constant tests are removed, with current settings,
 turns into
 
 	if (iflag || mflag)
 		len = sizeof(ps->cmd);		/* 200 */
 	else
 		len = 50;
 
 But it will scale upwards a bit if a decision is ever made to make the command
 string buffer bigger (or if someone ever does that for private use.)
 
 50 turns out to be a nice size to make the output (when printed, along with 
 other noise that appears) fit in 80 columns, and changes ...
 
 [1] + 12256 Running           /tmp/mycmd CVS F...
 
 into
 
 [1] + 18902 Running           /tmp/mycmd CVS FIX FIX2 MSG MSG.bak Makefile T...
 
 (/tmp/mycmd is simply a script that does sleep for a few seconds, and ignores 
 its args, allows testing of long command lines without needing to find 
 something which core dumps.)
 
 If this seems reasonable to everyone (or at least those concerned) I will 
 commit this in head (I kind of doubt this is really worth pulling up to -8,
 especially after we have lived with it for all these years, but that could
 happen too if requested.)
 
 kre
 


Home | Main Index | Thread Index | Old Index