aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgarbled <garbled@NetBSD.org>2006-01-12 20:33:20 +0000
committergarbled <garbled@NetBSD.org>2006-01-12 20:33:20 +0000
commit6d0346fd2af53096b65560cf7a9be3bfe4a56912 (patch)
tree6c8b63894085939994e4c7720aa754c2bef80235
parent253dee6111409401649db8673ca7b5a08b0bd289 (diff)
downloadbsd-progress-6d0346fd2af53096b65560cf7a9be3bfe4a56912.tar.gz
bsd-progress-6d0346fd2af53096b65560cf7a9be3bfe4a56912.tar.zst
bsd-progress-6d0346fd2af53096b65560cf7a9be3bfe4a56912.zip
Apply patch from PR bin/28717
This adds a -e option to progress which causes the progress bar to be sent to stderr. This allows using progress mid-pipe, such as: tar -cf . | progress -e bzip -1c | ssh host "cat > file"
-rw-r--r--progress.16
-rw-r--r--progress.c15
2 files changed, 13 insertions, 8 deletions
diff --git a/progress.1 b/progress.1
index 6ed316f..b015e3e 100644
--- a/progress.1
+++ b/progress.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: progress.1,v 1.9 2004/04/03 06:19:22 lukem Exp $
+.\" $NetBSD: progress.1,v 1.10 2006/01/12 20:33:20 garbled Exp $
.\"
.\" Copyright (c) 2003,2004 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -38,7 +38,7 @@
.Nd feed input to a command, displaying a progress bar
.Sh SYNOPSIS
.Nm
-.Op Fl z
+.Op Fl ez
.Op Fl f Ar file
.Op Fl l Ar length
.Op Fl p Ar prefix
@@ -65,6 +65,8 @@ simply displays a count of the data and the data rate.
.Pp
The options are as follows:
.Bl -tag -width XlXlengthXX
+.It Fl e
+Display progress to standard error instead of standard output.
.It Fl f Ar file
Read from the specified
.Ar file
diff --git a/progress.c b/progress.c
index 6e9d898..3272ba2 100644
--- a/progress.c
+++ b/progress.c
@@ -1,4 +1,4 @@
-/* $NetBSD: progress.c,v 1.10 2005/02/23 22:32:31 dsl Exp $ */
+/* $NetBSD: progress.c,v 1.11 2006/01/12 20:33:20 garbled Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: progress.c,v 1.10 2005/02/23 22:32:31 dsl Exp $");
+__RCSID("$NetBSD: progress.c,v 1.11 2006/01/12 20:33:20 garbled Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -73,7 +73,7 @@ static void
usage(void)
{
fprintf(stderr,
- "usage: %s [-z] [-f file] [-l length] [-p prefix] cmd [args...]\n",
+ "usage: %s [-ez] [-f file] [-l length] [-p prefix] cmd [args...]\n",
getprogname());
exit(1);
}
@@ -87,7 +87,7 @@ main(int argc, char *argv[])
pid_t pid = 0, gzippid = 0, deadpid;
int ch, fd, outpipe[2];
int ws, gzipstat, cmdstat;
- int lflag = 0, zflag = 0;
+ int eflag = 0, lflag = 0, zflag = 0;
ssize_t nr, nw, off;
struct stat statb;
struct ttysize ts;
@@ -99,8 +99,11 @@ main(int argc, char *argv[])
filesize = 0;
prefix=NULL;
- while ((ch = getopt(argc, argv, "f:l:p:z")) != -1)
+ while ((ch = getopt(argc, argv, "ef:l:p:z")) != -1)
switch (ch) {
+ case 'e':
+ eflag++;
+ break;
case 'f':
infile = optarg;
break;
@@ -183,7 +186,7 @@ main(int argc, char *argv[])
/* Initialize progressbar.c's global state */
bytes = 0;
progress = 1;
- ttyout = stdout;
+ ttyout = eflag ? stderr : stdout;
if (ioctl(fileno(ttyout), TIOCGSIZE, &ts) == -1) {
ttywidth = 80;