diff options
author | christos <christos@NetBSD.org> | 2003-01-22 03:24:21 +0000 |
---|---|---|
committer | christos <christos@NetBSD.org> | 2003-01-22 03:24:21 +0000 |
commit | cb73d7adb8e9cdd4e3d5fb1202400524809280fb (patch) | |
tree | 3dc7e56e09589b15797270ace12dafed86606240 | |
parent | 563f6b896df6163d10d2c85c9f5590598f47c699 (diff) | |
download | bsd-progress-cb73d7adb8e9cdd4e3d5fb1202400524809280fb.tar.gz bsd-progress-cb73d7adb8e9cdd4e3d5fb1202400524809280fb.tar.zst bsd-progress-cb73d7adb8e9cdd4e3d5fb1202400524809280fb.zip |
not all windows have 80 columns.
-rw-r--r-- | progress.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -1,4 +1,4 @@ -/* $NetBSD: progress.c,v 1.2 2003/01/22 03:13:32 enami Exp $ */ +/* $NetBSD: progress.c,v 1.3 2003/01/22 03:24:21 christos Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: progress.c,v 1.2 2003/01/22 03:13:32 enami Exp $"); +__RCSID("$NetBSD: progress.c,v 1.3 2003/01/22 03:24:21 christos Exp $"); #endif /* not lint */ #include <sys/types.h> @@ -89,6 +89,7 @@ main(int argc, char *argv[]) int lflag = 0, zflag = 0; ssize_t nr, nw, off; struct stat statb; + struct ttysize ts; setprogname(argv[0]); @@ -179,7 +180,12 @@ main(int argc, char *argv[]) bytes = 0; progress = 1; ttyout = stdout; - ttywidth = 80; + + if (ioctl(fileno(ttyout), TIOCGSIZE, &ts) == -1) { + warn("could not get tty window size"); + ttywidth = 80; + } else + ttywidth = ts.ts_cols; if (pipe(outpipe) < 0) err(1, "output pipe"); |