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
|
Patch4: less-394-time.patch
|
||||||
Patch5: less-418-fsync.patch
|
Patch5: less-418-fsync.patch
|
||||||
Patch6: less-436-manpage.patch
|
Patch6: less-436-manpage.patch
|
||||||
|
Patch7: less-436-empty-lessopen-pipe.patch
|
||||||
URL: http://www.greenwoodsoftware.com/less/
|
URL: http://www.greenwoodsoftware.com/less/
|
||||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
BuildRequires: ncurses-devel
|
BuildRequires: ncurses-devel
|
||||||
@ -34,6 +35,7 @@ files, and you'll use it frequently.
|
|||||||
%patch4 -p1 -b .time
|
%patch4 -p1 -b .time
|
||||||
%patch5 -p1 -b .fsync
|
%patch5 -p1 -b .fsync
|
||||||
%patch6 -p1 -b .manpage
|
%patch6 -p1 -b .manpage
|
||||||
|
%patch7 -p1 -b .empty-lessopen-pipe
|
||||||
|
|
||||||
autoreconf
|
autoreconf
|
||||||
|
|
||||||
@ -65,6 +67,10 @@ ls -la $RPM_BUILD_ROOT/etc/profile.d
|
|||||||
rm -rf $RPM_BUILD_ROOT
|
rm -rf $RPM_BUILD_ROOT
|
||||||
|
|
||||||
%changelog
|
%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
|
* Wed Jan 20 2010 Nikola Pajkovsky <npajkovs@redhat.com> - 436-6
|
||||||
- RFE: lesspipe.sh could use a support for *.xz file
|
- RFE: lesspipe.sh could use a support for *.xz file
|
||||||
|
|
||||||
|
58
lesspipe.sh
58
lesspipe.sh
@ -2,23 +2,30 @@
|
|||||||
#
|
#
|
||||||
# To use this filter with less, define LESSOPEN:
|
# To use this filter with less, define LESSOPEN:
|
||||||
# export LESSOPEN="|/usr/bin/lesspipe.sh %s"
|
# 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() {
|
lesspipe() {
|
||||||
case "$1" in
|
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)
|
*.[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
|
case "$1" in
|
||||||
*.gz) DECOMPRESSOR="gunzip -c" ;;
|
*.gz) DECOMPRESSOR="gzip -dc" ;;
|
||||||
*.bz2) DECOMPRESSOR="bunzip2 -c" ;;
|
*.bz2) DECOMPRESSOR="bzip2 -dc" ;;
|
||||||
*) DECOMPRESSOR="cat" ;;
|
|
||||||
esac
|
esac
|
||||||
if $DECOMPRESSOR -- "$1" | file - | grep -q troff; then
|
if [ ! -z $DECOMPRESSOR ] ; then
|
||||||
if echo "$1" | grep -q ^/; then #absolute path
|
if $DECOMPRESSOR -- "$1" | file - | grep -q troff; then
|
||||||
man -- "$1" | cat -s
|
if echo "$1" | grep -q ^/; then #absolute path
|
||||||
else
|
man -- "$1" | cat -s
|
||||||
man -- "./$1" | cat -s
|
else
|
||||||
fi
|
man -- "./$1" | cat -s
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
$DECOMPRESSOR -- "$1"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
$DECOMPRESSOR -- "$1"
|
exit 1
|
||||||
fi ;;
|
fi ;;
|
||||||
*.tar) tar tvvf "$1" ;;
|
*.tar) tar tvvf "$1" ;;
|
||||||
*.tgz|*.tar.gz|*.tar.[zZ]) tar tzvvf "$1" ;;
|
*.tgz|*.tar.gz|*.tar.[zZ]) tar tzvvf "$1" ;;
|
||||||
@ -32,28 +39,27 @@ lesspipe() {
|
|||||||
*.rpm) rpm -qpivl --changelog -- "$1" ;;
|
*.rpm) rpm -qpivl --changelog -- "$1" ;;
|
||||||
*.cpi|*.cpio) cpio -itv < "$1" ;;
|
*.cpi|*.cpio) cpio -itv < "$1" ;;
|
||||||
*.gif|*.jpeg|*.jpg|*.pcd|*.png|*.tga|*.tiff|*.tif)
|
*.gif|*.jpeg|*.jpg|*.pcd|*.png|*.tga|*.tiff|*.tif)
|
||||||
if [ -x /usr/bin/identify ]; then
|
if [ -x /usr/bin/identify ]; then
|
||||||
identify "$1"
|
identify "$1"
|
||||||
elif [ -x /usr/bin/gm ]; then
|
elif [ -x /usr/bin/gm ]; then
|
||||||
gm identify "$1"
|
gm identify "$1"
|
||||||
else
|
else
|
||||||
echo "No identify available"
|
echo "No identify available"
|
||||||
echo "Install ImageMagick or GraphicsMagick to browse images"
|
echo "Install ImageMagick or GraphicsMagick to browse images"
|
||||||
fi ;;
|
fi ;;
|
||||||
*)
|
*)
|
||||||
case "$1" in
|
exit 1
|
||||||
*.gz) DECOMPRESSOR="gunzip -c" ;;
|
|
||||||
*.bz2) DECOMPRESSOR="bunzip2 -c" ;;
|
|
||||||
*.xz) DECOMPRESSOR="unxz -c" ;;
|
|
||||||
esac
|
|
||||||
if [ ! -z $DECOMPRESSOR ] ; then
|
|
||||||
$DECOMPRESSOR -- "$1" ;
|
|
||||||
fi
|
|
||||||
esac
|
esac
|
||||||
|
exit $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ ! -e "$1" ] ; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -d "$1" ] ; then
|
if [ -d "$1" ] ; then
|
||||||
/bin/ls -alF -- "$1"
|
/bin/ls -alF -- "$1"
|
||||||
|
exit $?
|
||||||
else
|
else
|
||||||
lesspipe "$1" 2> /dev/null
|
lesspipe "$1" 2> /dev/null
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user