parent
c90d7c25e5
commit
164583b460
39
less-436-empty-lessopen-pipe.patch
Normal file
39
less-436-empty-lessopen-pipe.patch
Normal file
@ -0,0 +1,39 @@
|
||||
--- less-436/filename.c 2009-07-06 22:52:23.000000000 +0200
|
||||
+++ less-436_vvitek/filename.c 2010-12-08 16:01:41.269695932 +0100
|
||||
@@ -879,17 +879,32 @@ open_altfile(filename, pf, pfd)
|
||||
*/
|
||||
f = fileno(fd);
|
||||
SET_BINARY(f);
|
||||
+ *pfd = (void *) fd;
|
||||
+ *pf = f;
|
||||
if (read(f, &c, 1) != 1)
|
||||
{
|
||||
/*
|
||||
- * Pipe is empty. This means there is no alt file.
|
||||
+ * Error or pipe is empty. Close it and
|
||||
+ * check exit status of the pipe process.
|
||||
*/
|
||||
- pclose(fd);
|
||||
+ if (pclose(fd) == 0) {
|
||||
+ /*
|
||||
+ * Exit status was zero, so the EOF was correct
|
||||
+ * empty output. Let the program open /dev/null
|
||||
+ * instead, as the pipe is already closed.
|
||||
+ * Set force_open to omit bad_file() check
|
||||
+ * failure, as it is special 'c' pseudo-device.
|
||||
+ */
|
||||
+ *pf = 0;
|
||||
+ *pfd = NULL;
|
||||
+ force_open = 1;
|
||||
+ return (save("/dev/null"));
|
||||
+ }
|
||||
+ *pf = 0;
|
||||
+ *pfd = NULL;
|
||||
return (NULL);
|
||||
}
|
||||
ch_ungetchar(c);
|
||||
- *pfd = (void *) fd;
|
||||
- *pf = f;
|
||||
return (save("-"));
|
||||
}
|
||||
#endif
|
@ -12,6 +12,7 @@ Patch1: less-406-Foption.patch
|
||||
Patch4: less-394-time.patch
|
||||
Patch5: less-418-fsync.patch
|
||||
Patch6: less-436-manpage.patch
|
||||
Patch7: less-436-empty-lessopen-pipe.patch
|
||||
URL: http://www.greenwoodsoftware.com/less/
|
||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: ncurses-devel
|
||||
@ -34,6 +35,7 @@ files, and you'll use it frequently.
|
||||
%patch4 -p1 -b .time
|
||||
%patch5 -p1 -b .fsync
|
||||
%patch6 -p1 -b .manpage
|
||||
%patch7 -p1 -b .empty-lessopen-pipe
|
||||
|
||||
autoreconf
|
||||
|
||||
@ -65,6 +67,10 @@ ls -la $RPM_BUILD_ROOT/etc/profile.d
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%changelog
|
||||
* Tue Dec 21 2010 Vojtech Vitek (V-Teq) <vvitek@redhat.com> - 436-7
|
||||
- Fix for valid empty LESSOPEN pipe output
|
||||
Resolves: #579251, #615303
|
||||
|
||||
* Wed Jan 20 2010 Nikola Pajkovsky <npajkovs@redhat.com> - 436-6
|
||||
- RFE: lesspipe.sh could use a support for *.xz file
|
||||
|
||||
|
28
lesspipe.sh
28
lesspipe.sh
@ -2,15 +2,19 @@
|
||||
#
|
||||
# To use this filter with less, define LESSOPEN:
|
||||
# export LESSOPEN="|/usr/bin/lesspipe.sh %s"
|
||||
#
|
||||
# Script should return zero on success. This is important in case
|
||||
# of empty output of any decompressor when the output pipe produces
|
||||
# just EOF (eg. while uncompressing gzipped empty file).
|
||||
|
||||
lesspipe() {
|
||||
case "$1" in
|
||||
*.[1-9n]|*.man|*.[1-9n].bz2|*.man.bz2|*.[1-9].gz|*.[1-9]x.gz|*.man.gz|*.[1-9].xz|*.[1-9]x.xz|*.man.xz)
|
||||
case "$1" in
|
||||
*.gz) DECOMPRESSOR="gunzip -c" ;;
|
||||
*.bz2) DECOMPRESSOR="bunzip2 -c" ;;
|
||||
*) DECOMPRESSOR="cat" ;;
|
||||
*.gz) DECOMPRESSOR="gzip -dc" ;;
|
||||
*.bz2) DECOMPRESSOR="bzip2 -dc" ;;
|
||||
esac
|
||||
if [ ! -z $DECOMPRESSOR ] ; then
|
||||
if $DECOMPRESSOR -- "$1" | file - | grep -q troff; then
|
||||
if echo "$1" | grep -q ^/; then #absolute path
|
||||
man -- "$1" | cat -s
|
||||
@ -19,6 +23,9 @@ lesspipe() {
|
||||
fi
|
||||
else
|
||||
$DECOMPRESSOR -- "$1"
|
||||
fi
|
||||
else
|
||||
exit 1
|
||||
fi ;;
|
||||
*.tar) tar tvvf "$1" ;;
|
||||
*.tgz|*.tar.gz|*.tar.[zZ]) tar tzvvf "$1" ;;
|
||||
@ -41,19 +48,18 @@ lesspipe() {
|
||||
echo "Install ImageMagick or GraphicsMagick to browse images"
|
||||
fi ;;
|
||||
*)
|
||||
case "$1" in
|
||||
*.gz) DECOMPRESSOR="gunzip -c" ;;
|
||||
*.bz2) DECOMPRESSOR="bunzip2 -c" ;;
|
||||
*.xz) DECOMPRESSOR="unxz -c" ;;
|
||||
esac
|
||||
if [ ! -z $DECOMPRESSOR ] ; then
|
||||
$DECOMPRESSOR -- "$1" ;
|
||||
fi
|
||||
exit 1
|
||||
esac
|
||||
exit $?
|
||||
}
|
||||
|
||||
if [ ! -e "$1" ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -d "$1" ] ; then
|
||||
/bin/ls -alF -- "$1"
|
||||
exit $?
|
||||
else
|
||||
lesspipe "$1" 2> /dev/null
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user