From bcb33ce2aa589ecf26d400f0ccf2b6570b92e659 Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Sun, 16 Jul 2023 21:58:08 +0100 Subject: [PATCH] Honour the --force setting when writing the progress display --- doc/ACKNOWLEDGEMENTS.md | 2 ++ doc/NEWS.md | 3 ++- doc/TODO.md | 2 -- doc/quickref.1.in | 13 +++++++++++++ src/pv/display.c | 4 ++-- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/doc/ACKNOWLEDGEMENTS.md b/doc/ACKNOWLEDGEMENTS.md index 2433982..592d5a9 100644 --- a/doc/ACKNOWLEDGEMENTS.md +++ b/doc/ACKNOWLEDGEMENTS.md @@ -72,6 +72,8 @@ is acknowledged and greatly appreciated: * Johannes Gerer - suggested that "`-B`" should enable "`-C`" * Sam James - provided fix for number.c build issue caused by missing stddef.h * Jakub Wilk - corrected README encoding + * Frederik Eaton - reported issue with `<()` shell constructs + * [gray](https://github.com/gray) - reported issue with "`--force`" and terminal process groups, and proposed a patch * [Luc Gommans](https://github.com/lgommans) / https://lgms.nl/ - provided a "momentary ETA" patch * [ikasty](https://github.com/ikasty) - added relative filename display to "`--watchfd`" * [Michael Weiß](https://github.com/quitschbo) - corrected behaviour when not attached to a terminal diff --git a/doc/NEWS.md b/doc/NEWS.md index 5e77bbb..8c76daf 100644 --- a/doc/NEWS.md +++ b/doc/NEWS.md @@ -1,8 +1,9 @@ UNRELEASED * dropped: support for Red Hat Enterprise Linux and its derivatives has been dropped; removed the RPM spec file, and will no longer build binaries - * fix: correction to `pv_in_foreground()` to behave as its comment block says it should, when not on a terminal - corrects [GH#19 "No output in Arch Linux initcpio after 1.6.6"](https://github.com/a-j-wood/pv/issues/19), [GH#55 "pv Stopped Working in the Background"](https://github.com/a-j-wood/pv/issues/55) (pull request [#64](https://github.com/a-j-wood/pv/pull/64) supplied by [Michael Weiß](https://github.com/quitschbo)) + * fix: correction to `pv_in_foreground()` to behave as its comment block says it should, when not on a terminal - corrects [GH#19 "No output in Arch Linux initcpio after 1.6.6"](https://github.com/a-j-wood/pv/issues/19), [GH#31 "No output written from inside zsh <() construct"](https://github.com/a-j-wood/pv/issues/31), [GH#55 "pv Stopped Working in the Background"](https://github.com/a-j-wood/pv/issues/55) (pull request [#64](https://github.com/a-j-wood/pv/pull/64) supplied by [Michael Weiß](https://github.com/quitschbo)) * fix: workaround for OS X 11 behaviour in configure script regarding stat64 at compile time (pull request [#57](https://github.com/a-j-wood/pv/pull/57) supplied by [Dave Beckett](https://github.com/dajobe)) * fix: add burst rate limit to transfer, so rate limits are not broken by bursty traffic (pull request [#62](https://github.com/a-j-wood/pv/pull/62) supplied by [Volodymyr Bychkovyak](https://github.com/vbychkoviak)) + * fix: corrected "`--force`" option so it will still output progress when not in the same process group as the owner of the terminal - corrects [GH#23 "No output with "`-f`" when run in background after 1.6.6"](https://github.com/a-j-wood/pv/issues/23) and helps to correct [GH#31 "No output written from inside zsh <() construct"](https://github.com/a-j-wood/pv/issues/31) * feature: the "`--size`" option now accepts "`@filename`" to use the size of another file (pull request [#57](https://github.com/a-j-wood/pv/pull/57) supplied by [Dave Beckett](https://github.com/dajobe)) * feature: the "`--watchfd`" option is now available on OS X (pull request [#60](https://github.com/a-j-wood/pv/pull/60) supplied by [christoph-zededa](https://github.com/christoph-zededa)) * feature: new "`--average-rate-window`" option, to set the window over which the average rate is calculated, also used for ETA (modified from pull request [#65](https://github.com/a-j-wood/pv/pull/65) supplied by [lemonsqueeze](https://github.com/lemonsqueeze)) diff --git a/doc/TODO.md b/doc/TODO.md index 8d047cd..746f78d 100644 --- a/doc/TODO.md +++ b/doc/TODO.md @@ -8,11 +8,9 @@ Bugs * ([GH#16](https://github.com/a-j-wood/pv/issues/16)) Show days in same format in ETA as in elapsed time * ([GH#18](https://github.com/a-j-wood/pv/issues/18)) No output in Cygwin from 1.6.19 onwards (Jacek M. Holeczek) * ([GH#20](https://github.com/a-j-wood/pv/issues/20)) Terminal state is not restored correctly in all cases (VA) - * ([GH#23](https://github.com/a-j-wood/pv/issues/23)) No output with "`-f`" when run in background after 1.6.6 (gray) * ([GH#24](https://github.com/a-j-wood/pv/issues/24)) Race condition with multiple "`pv -c`" leaves terminal state inconsistent (Lars Ellenberg, Viktor Ashirov) * ([GH#26](https://github.com/a-j-wood/pv/issues/26)) Correct "`-n`" behaviour when going past 100% of "`-s`" size (Marcel) * ([GH#27](https://github.com/a-j-wood/pv/issues/27)) Rate limit downgrade can take a long time to take effect (Stephen Kitt) - * ([GH#31](https://github.com/a-j-wood/pv/issues/31)) No output written from inside zsh `<()` construct (Frederik Eaton - Dec 2015) * ([GH#33](https://github.com/a-j-wood/pv/issues/33)) Fix compilation problems due to `stat64()` on Apple Silicon (Filippo Valsorda - Jan 2021) * ([GH#34](https://github.com/a-j-wood/pv/issues/34)) Continue timer even if input or output is blocking (Martin Probst - Jun 2017) diff --git a/doc/quickref.1.in b/doc/quickref.1.in index ff978e4..82d901f 100644 --- a/doc/quickref.1.in +++ b/doc/quickref.1.in @@ -590,6 +590,19 @@ The following problems are known to exist in .BR @PACKAGE@ : .TP .B * +In some versions of +.BR bash (1) +and +.BR zsh (1), +the construct +.B <(pv filename) +will not output any progress to the terminal when run from an interactive +shell, due to the subprocess being run in a separate process group from the +one that owns the terminal. In these cases, use +.BR \-\-force . +.P +.TP +.B * The .B -c option does not work properly on Cygwin without diff --git a/src/pv/display.c b/src/pv/display.c index e5ac746..dbd4176 100644 --- a/src/pv/display.c +++ b/src/pv/display.c @@ -1041,12 +1041,12 @@ void pv_display(pvstate_t state, long double esec, long long sl, if (state->numeric) { write(STDERR_FILENO, display, strlen(display)); } else if (state->cursor) { - if (pv_in_foreground()) { + if (state->force || pv_in_foreground()) { pv_crs_update(state, display); state->display_visible = true; } } else { - if (pv_in_foreground()) { + if (state->force || pv_in_foreground()) { write(STDERR_FILENO, display, strlen(display)); write(STDERR_FILENO, "\r", 1); state->display_visible = true;