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:
4
todo.sh
4
todo.sh
@@ -807,9 +807,9 @@ case $action in
|
|||||||
|
|
||||||
"help" )
|
"help" )
|
||||||
if [ -t 1 ] ; then # STDOUT is a TTY
|
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)
|
# we have a working PAGER (or less as a default)
|
||||||
help | exec ${PAGER:-less}
|
help | "${PAGER:-less}" && exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
help # just in case something failed above, we go ahead and just spew to STDOUT
|
help # just in case something failed above, we go ahead and just spew to STDOUT
|
||||||
|
|||||||
Reference in New Issue
Block a user