From d52a1a7bd22b5e3ccfb309919e98f379a99ec0cf Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Tue, 25 May 2010 13:42:04 +0200 Subject: [PATCH] Bugfix: Doubled help output on TTY with PAGER. On "todo.sh help", first the long help output is printed through the pager, and after quitting the pager the output is printed once more in full. Didn't write a test for this, as this requires a connected terminal and cannot be observed in the test harness. Fix: The "exec" command has no effect inside a pipe; added an explicit "exit 0". Also simplified check for PAGER: No "exec" necessary, combining stderr and stdout. Also added quoting for PAGER so that it can contain spaces. --- todo.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/todo.sh b/todo.sh index 172dea8..d7136f9 100755 --- a/todo.sh +++ b/todo.sh @@ -807,9 +807,9 @@ case $action in "help" ) if [ -t 1 ] ; then # STDOUT is a TTY - if (exec which ${PAGER:-less} 2>/dev/null >/dev/null); then + if which "${PAGER:-less}" >/dev/null 2>&1; then # we have a working PAGER (or less as a default) - help | exec ${PAGER:-less} + help | "${PAGER:-less}" && exit 0 fi fi help # just in case something failed above, we go ahead and just spew to STDOUT