Subject: bin/32343: etcupdate uses the wrong field of `stty -a` for terminal width
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <rjgrace@fastmail.fm>
List: netbsd-bugs
Date: 12/20/2005 02:25:00
>Number: 32343
>Category: bin
>Synopsis: etcupdate uses the wrong field of `stty -a` for terminal width
>Confidential: no
>Severity: non-critical
>Priority: high
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Dec 20 02:25:00 +0000 2005
>Originator: Richard Grace
>Release: 3.0
>Organization:
>Environment:
NetBSD Cubit 3.0 NetBSD 3.0 (GENERIC) #1: Mon Dec 19 10:05:44 EST 2005 root@Cubit:/usr/obj/sys/arch/i386/compile/GENERIC i386
>Description:
Line 58 of /usr/sbin/etcupdate uses stty to determine the terminal width:
SWIDTH=`stty -a | awk '/columns/{w=$6}END{if(w==0){w=80}print w}'`
This is incorrect, as the column with is in field 9 of the stty output,
not field 6.
This prevents etcupdate being able to show the differences when merging
two files which differ after a new installation.
>How-To-Repeat:
The output from this is:
$ stty -a | awk '/columns/{w=$6}END{if(w==0){w=80}print w}'
baud;
While it should be:
$ stty -a | awk '/columns/{w=$9}END{if(w==0){w=80}print w}'
90
The stty that is being used is:
$ which stty
/bin/stty
>Fix:
Here is a unified diff for /usr/sbin/etcupdate:
--- etcupdate.orig 2005-12-20 13:13:32.000000000 +1100
+++ etcupdate 2005-12-20 13:13:49.000000000 +1100
@@ -55,7 +55,7 @@
TEMPROOT="${TEMPROOT:=/tmp/temproot}"
SRCDIR="${SRCDIR:=/usr/src/etc}"
PAGER="${PAGER:=/usr/bin/more}"
-SWIDTH=`stty -a | awk '/columns/{w=$6}END{if(w==0){w=80}print w}'`
+SWIDTH=`stty -a | awk '/columns/{w=$9}END{if(w==0){w=80}print w}'`
WIDTH="${WIDTH:=${SWIDTH}}"
VERBOSE=
CONTINUE=