update sigpipe error fix in the doc

This commit is contained in:
Gokcehan 2021-02-06 00:19:09 +03:00
parent 9d451ffd19
commit 3e403bb888
3 changed files with 10 additions and 26 deletions

10
doc.go
View File

@ -1163,7 +1163,7 @@ Extensions can then be used to match cleanly within a conditional:
*.rar) unrar l "$1";;
*.7z) 7z l "$1";;
*.pdf) pdftotext "$1" -;;
*) highlight -O ansi "$1" || cat "$1";;
*) highlight -O ansi "$1";;
esac
Another important consideration for efficiency is the use of programs with short startup times for preview.
@ -1173,13 +1173,9 @@ This is especially relevant for big files.
lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read.
When everything else fails, you can make use of the height argument to only feed the first portion of the file to a program for preview.
Note that some programs may not respond well to SIGPIPE to exit with a non-zero return code and avoid caching.
You may trap SIGPIPE in your preview script to avoid error propogation:
You may add a trailing '|| true' command to avoid such errors:
#!/bin/sh
trap "" PIPE
...
highlight -O ansi "$1" || true
You may also use an existing preview filter as you like.
Your system may already come with a preview filter named 'lesspipe'.

View File

@ -1298,7 +1298,7 @@ match cleanly within a conditional:
*.rar) unrar l "$1";;
*.7z) 7z l "$1";;
*.pdf) pdftotext "$1" -;;
*) highlight -O ansi "$1" || cat "$1";;
*) highlight -O ansi "$1";;
esac
Another important consideration for efficiency is the use of programs with
@ -1311,14 +1311,10 @@ script output pipe with a SIGPIPE when enough lines are read. When
everything else fails, you can make use of the height argument to only feed
the first portion of the file to a program for preview. Note that some
programs may not respond well to SIGPIPE to exit with a non-zero return code
and avoid caching. You may trap SIGPIPE in your preview script to avoid
error propogation:
and avoid caching. You may add a trailing '|| true' command to avoid such
errors:
#!/bin/sh
trap "" PIPE
...
highlight -O ansi "$1" || true
You may also use an existing preview filter as you like. Your system may
already come with a preview filter named 'lesspipe'. These filters may have

14
lf.1
View File

@ -1292,22 +1292,14 @@ Since this script is called for each file selection change it needs to be as eff
*.rar) unrar l "$1";;
*.7z) 7z l "$1";;
*.pdf) pdftotext "$1" -;;
*) highlight -O ansi "$1" || cat "$1";;
*) highlight -O ansi "$1";;
esac
.EE
.PP
Another important consideration for efficiency is the use of programs with short startup times for preview. For this reason, 'highlight' is recommended over 'pygmentize' for syntax highlighting. Besides, it is also important that the application is processing the file on the fly rather than first reading it to the memory and then do the processing afterwards. This is especially relevant for big files. lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read. When everything else fails, you can make use of the height argument to only feed the first portion of the file to a program for preview. Note that some programs may not respond well to SIGPIPE to exit with a non-zero return code and avoid caching. You may trap SIGPIPE in your preview script to avoid error propogation:
Another important consideration for efficiency is the use of programs with short startup times for preview. For this reason, 'highlight' is recommended over 'pygmentize' for syntax highlighting. Besides, it is also important that the application is processing the file on the fly rather than first reading it to the memory and then do the processing afterwards. This is especially relevant for big files. lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read. When everything else fails, you can make use of the height argument to only feed the first portion of the file to a program for preview. Note that some programs may not respond well to SIGPIPE to exit with a non-zero return code and avoid caching. You may add a trailing '|| true' command to avoid such errors:
.PP
.EX
#!/bin/sh
.EE
.PP
.EX
trap "" PIPE
.EE
.PP
.EX
...
highlight -O ansi "$1" || true
.EE
.PP
You may also use an existing preview filter as you like. Your system may already come with a preview filter named 'lesspipe'. These filters may have a mechanism to add user customizations as well. See the related documentations for more information.