Skip to content

Commit

Permalink
lib: Fix issue when pagers read an empty argument as a file
Browse files Browse the repository at this point in the history
  • Loading branch information
eth-p committed May 2, 2020
1 parent d29915f commit 20a0058
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/pager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ pager_version() {
# Example:
# pager_exec echo hi
pager_exec() {
if [[ -n "$1" ]]; then
if [[ -n "$SCRIPT_PAGER_CMD" ]]; then
"$@" | "${SCRIPT_PAGER_CMD[@]}" "${SCRIPT_PAGER_ARGS[@]}"
return $?
else
"$@"
return $?
fi
if [[ -n "$SCRIPT_PAGER_CMD" ]]; then
"$@" | pager_display
return $?
else
"$@"
return $?
fi
}

Expand All @@ -53,7 +51,7 @@ pager_exec() {
# bat | pager_display
pager_display() {
if [[ -n "$SCRIPT_PAGER_CMD" ]]; then
if [[ -n "$SCRIPT_PAGER_CMD" ]]; then
if [[ -n "$SCRIPT_PAGER_ARGS" ]]; then
"${SCRIPT_PAGER_CMD[@]}" "${SCRIPT_PAGER_ARGS[@]}"
return $?
else
Expand Down

0 comments on commit 20a0058

Please sign in to comment.