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.
This commit is contained in:
Ingo Karkat
2010-05-25 13:42:04 +02:00
parent 15084aa4d7
commit d52a1a7bd2

View File

@@ -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