Subject: bin/4841: cat(1) bug with interaction of -b, -e options
To: None <gnats-bugs@gnats.netbsd.org>
From: None <giles@nemeton.com.au>
List: netbsd-bugs
Date: 01/19/1998 06:56:56
>Number:         4841
>Category:       bin
>Synopsis:       cat(1) bug with interaction of -b, -e options
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 18 23:05:01 1998
>Last-Modified:
>Originator:     Giles Lean
>Organization:

Giles Lean               <giles@nemeton.com.au>             +61 3 9480 2118
Nemeton Pty. Ltd.                                       fax +61 3 9480 1771
PGP Fingerprint (DA68EE41) 9F FB 28 37 81 F2 AC F3  8A B0 37 E5 73 CF 39 E7
P5 Fingerprint char x[5]={0xf0, 0x0f, 0xc7, 0xc8}; main(){void(*f)()=x;f();}
>Release:        NetBSD-current January 18th 1998
>Environment:
	
System: NetBSD topaz.nemeton.com.au 1.3_ALPHA NetBSD 1.3_ALPHA (TOPAZ-DISKLESS) #0: Sat Nov 22 15:15:58 EST 1997 giles@topaz.nemeton.com.au:/usr/src/sys/arch/i386/compile/TOPAZ-DISKLESS i386


>Description:

Note here how the '$' are not lining up with the LHS of the file data
on blank lines:

% cat -be /etc/motd
     1	NetBSD 1.3_ALPHA (TOPAZ-DISKLESS) #0: Sat Nov 22 15:15:58 EST 1997$
$
     2	Welcome to NetBSD!$
$

I'd rather see:

% ./cat -be /etc/motd
     1	NetBSD 1.3_ALPHA (TOPAZ-DISKLESS) #0: Sat Nov 22 15:15:58 EST 1997$
      	$
     3	Welcome to NetBSD!$
      	$

For comparison, -ne gets it "right":

% cat -ne /etc/motd
     1	NetBSD 1.3_ALPHA (TOPAZ-DISKLESS) #0: Sat Nov 22 15:15:58 EST 1997$
     2	$
     3	Welcome to NetBSD!$
     4	$

>How-To-Repeat:
	$ cat -be /etc/motd
 Fix:
*** /a/NetBSD/SUP/src/bin/cat/cat.c	Tue Jan 13 23:13:40 1998
--- cat/cat.c	Mon Jan 19 17:36:39 1998
***************
*** 167,176 ****
  					gobble = 1;
  					continue;
  				}
! 				if (nflag && !bflag) {
! 					(void)fprintf(stdout, "%6d\t", ++line);
! 					if (ferror(stdout))
  						break;
  				}
  			} else if (nflag) {
  				(void)fprintf(stdout, "%6d\t", ++line);
--- 167,183 ----
  					gobble = 1;
  					continue;
  				}
! 				if (nflag) {
! 					++line;
! 					if (!bflag) {
! 					  (void)fprintf(stdout, "%6d\t", line);
! 					  if (ferror(stdout))
  						break;
+ 					} else if (eflag) {
+ 					  (void)fprintf(stdout, "%6s\t", " ");
+ 					  if (ferror(stdout))
+ 						break;
+ 					}
  				}
  			} else if (nflag) {
  				(void)fprintf(stdout, "%6d\t", ++line);
>Fix:
>Audit-Trail:
>Unformatted: