1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
Author: Michael B. Trausch <mike@trausch.us>
Author: Francois Marier <francois@debian.org>
Subject: Consider environment when determining default output columns
Origin: http://launchpadlibrarian.net/13009086/columns_for_tty.ubuntu.debdiff
Forwarded: yes
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/diffstat/+bug/209537
Last-Update: 2010-07-17
--- a/diffstat.c
+++ b/diffstat.c
@@ -2072,10 +2072,19 @@ int
main(int argc, char *argv[])
{
int j;
+ const int STDOUT = 1;
+ char *env_columns;
char version[80];
max_width = 80;
+ env_columns = getenv("COLUMNS");
+ if(env_columns) {
+ if(isatty(STDOUT)) {
+ max_width = atoi(env_columns);
+ }
+ }
+
while ((j = getopt_helper(argc, argv,
"bcCdD:e:f:hklmn:N:o:p:qr:sS:tuvVw:", 'h', 'V'))
!= -1) {
|