Skip to content

Commit

Permalink
improve handling of man pages, do not exit if called from man, git pe…
Browse files Browse the repository at this point in the history
…rldoc
  • Loading branch information
wofr06 committed Sep 23, 2024
1 parent 535826a commit 35aa015
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ the author by email.

### 4.2 List of preprocessed file types
- directory displayed using `ls -lA`
- nroff(man) requires `groff` or `mandoc`
- nroff(man) requires `mandoc` or `man` or `groff`
- shared library requires `nm`
- MS Word (doc) requires `wvText` or `catdoc` or `libreoffice`
- Powerpoint (ppt) requires `catppt`
Expand Down
6 changes: 3 additions & 3 deletions lesspipe.1
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ A single colon (disengage filter) or :extension (force language) is possible as
When the conditions for syntax highlighting are met directory listings and
listings of tar file contents get colorized as well.
.PP
As \fBless\fP is used as a default browser in other programs the choice of the
colorizer can affect the output of those programs.
For \fIman\fP, \fIgit\fP, and \fIperldoc\fP) lesspipe.sh does no filtering.
As \fBless\fP is used as a default browser in other programs (e.g. \fIman\fP,
\fIgit\fP, and \fIperldoc\fP)) \fBlesspipe.sh\fP may be engaged and alter
the output of those programs.
.SH WATCHING GROWING FILES
As soon as \fBlesspipe.sh\fP
calls a program to convert the input the ability to watch growing files
Expand Down
14 changes: 4 additions & 10 deletions lesspipe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,7 @@ analyze_args () {
cmdtree=$(ps -T -oargs= 2>/dev/null)
while read -r line; do
arg1=${line%% *}; arg1=${arg1##*/}
case $arg1 in
man|git|perldoc)
# if lesspipe is called in pipes, return immediately for some use cases
exit 0 ;;
less)
lessarg=$line ;;
esac
[[ $arg1 == less ]] && lessarg=$line
done <<< "$cmdtree"
# return if we want to watch growing files
[[ $lessarg == *less\ *\ +F\ * || $lessarg == *less\ *\ : ]] && exit 0
Expand Down Expand Up @@ -568,9 +562,9 @@ isfinal () {
declare macro=andoc
[[ "$fext" == me ]] && macro=e
[[ "$fext" == ms ]] && macro=s
{ has_cmd groff && cmd=(groff -s -p -t -e -Tutf8 -m "$macro" "$1"); } ||
{ has_cmd mandoc && cmd=(nodash mandoc "$1"); } ||
{ has_cmd man && cmd=(nodash man "$1"); } ;;
{ has_cmd man && cmd=(man -l "$1"); } ||
{ [[ $COLOR == *always ]] && has_cmd groff && cmd=(groff -s -p -t -e -Tutf8 -m "$macro" "$1"); } ;;
rtf)
{ has_cmd unrtf && cmd=(istemp "unrtf --text" "$1"); } ||
{ has_cmd libreoffice && cmd=(isoffice2 "$1"); } ;;
Expand All @@ -581,7 +575,7 @@ isfinal () {
pod)
[[ -z $file2 ]] &&
{ { has_cmd pod2text && cmd=(pod2text "$1"); } ||
{ has_cmd perldoc && cmd=(istemp perldoc "$1"); }; } ;;
{ has_cmd perldoc && cmd=(istemp "perldoc -T" "$1"); }; } ;;
hdf|hdf5)
{ has_cmd h5dump && cmd=(istemp h5dump "$1"); } ||
{ has_cmd ncdump && cmd=(istemp ncdump "$1"); } ;;
Expand Down

0 comments on commit 35aa015

Please sign in to comment.