mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-06-21 04:07:47 +02:00
lib: Fix issue when pagers read an empty argument as a file
This commit is contained in:
parent
d29915f141
commit
20a0058014
@ -36,15 +36,13 @@ pager_version() {
|
|||||||
# Example:
|
# Example:
|
||||||
# pager_exec echo hi
|
# pager_exec echo hi
|
||||||
pager_exec() {
|
pager_exec() {
|
||||||
if [[ -n "$1" ]]; then
|
|
||||||
if [[ -n "$SCRIPT_PAGER_CMD" ]]; then
|
if [[ -n "$SCRIPT_PAGER_CMD" ]]; then
|
||||||
"$@" | "${SCRIPT_PAGER_CMD[@]}" "${SCRIPT_PAGER_ARGS[@]}"
|
"$@" | pager_display
|
||||||
return $?
|
return $?
|
||||||
else
|
else
|
||||||
"$@"
|
"$@"
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Displays the output of a command or function inside the pager (if it exists).
|
# Displays the output of a command or function inside the pager (if it exists).
|
||||||
@ -53,7 +51,7 @@ pager_exec() {
|
|||||||
# bat | pager_display
|
# bat | pager_display
|
||||||
pager_display() {
|
pager_display() {
|
||||||
if [[ -n "$SCRIPT_PAGER_CMD" ]]; then
|
if [[ -n "$SCRIPT_PAGER_CMD" ]]; then
|
||||||
if [[ -n "$SCRIPT_PAGER_CMD" ]]; then
|
if [[ -n "$SCRIPT_PAGER_ARGS" ]]; then
|
||||||
"${SCRIPT_PAGER_CMD[@]}" "${SCRIPT_PAGER_ARGS[@]}"
|
"${SCRIPT_PAGER_CMD[@]}" "${SCRIPT_PAGER_ARGS[@]}"
|
||||||
return $?
|
return $?
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user