cat-highlight: Fix infinite loop, check if $LESSOPEN is set
This commit is contained in:
parent
224b12ffa6
commit
283971e3ad
|
@ -31,11 +31,12 @@ function export-emacs
|
||||||
# Highlight cat output with whatever less is using for highlighting
|
# Highlight cat output with whatever less is using for highlighting
|
||||||
function cat-highlight()
|
function cat-highlight()
|
||||||
{
|
{
|
||||||
if [[ -t 1 ]]; then # We're in a terminal
|
# Check if we are in a terminal and $LESSOPEN is not empty
|
||||||
|
if [[ -t 1 && -n "${LESSOPEN}" ]]; then
|
||||||
CATOPEN="${LESSOPEN/| }"
|
CATOPEN="${LESSOPEN/| }"
|
||||||
CATOPEN="${CATOPEN/ %s}"
|
CATOPEN="${CATOPEN/ %s}"
|
||||||
cat $@ | eval ${CATOPEN}
|
\cat $@ | eval ${CATOPEN}
|
||||||
else
|
else
|
||||||
cat $@
|
\cat $@
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user