From 6d0346fd2af53096b65560cf7a9be3bfe4a56912 Mon Sep 17 00:00:00 2001 From: garbled Date: Thu, 12 Jan 2006 20:33:20 +0000 Subject: 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" --- progress.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'progress.c') 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 #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 @@ -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; -- cgit v1.2.3