- (lesspipe) better handling of exit status
fixing regression of #186931 - turns over the lesspipe exit behavior
This commit is contained in:
parent
e15ca03bd8
commit
632b88cf21
12
less-458-return-non-zero.patch
Normal file
12
less-458-return-non-zero.patch
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
diff -up ./filename.c.return-non-zero ./filename.c
|
||||||
|
--- ./filename.c.return-non-zero 2013-04-04 18:55:05.000000000 +0200
|
||||||
|
+++ ./filename.c 2014-06-19 13:10:50.692171380 +0200
|
||||||
|
@@ -915,7 +915,7 @@ open_altfile(filename, pf, pfd)
|
||||||
|
* If only one pipe char, just assume no alt file.
|
||||||
|
*/
|
||||||
|
int status = pclose(fd);
|
||||||
|
- if (returnfd > 1 && status == 0) {
|
||||||
|
+ if (returnfd > 1 && status != 0) {
|
||||||
|
*pfd = NULL;
|
||||||
|
*pf = -1;
|
||||||
|
return (save(FAKE_EMPTYFILE));
|
@ -1,7 +1,7 @@
|
|||||||
Summary: A text file browser similar to more, but better
|
Summary: A text file browser similar to more, but better
|
||||||
Name: less
|
Name: less
|
||||||
Version: 458
|
Version: 458
|
||||||
Release: 9%{?dist}
|
Release: 10%{?dist}
|
||||||
License: GPLv3+
|
License: GPLv3+
|
||||||
Group: Applications/Text
|
Group: Applications/Text
|
||||||
Source: http://www.greenwoodsoftware.com/less/%{name}-%{version}.tar.gz
|
Source: http://www.greenwoodsoftware.com/less/%{name}-%{version}.tar.gz
|
||||||
@ -19,6 +19,7 @@ Patch9: less-458-less-filters-man.patch
|
|||||||
Patch10: less-458-lesskey-usage.patch
|
Patch10: less-458-lesskey-usage.patch
|
||||||
Patch11: less-458-old-bot-in-help.patch
|
Patch11: less-458-old-bot-in-help.patch
|
||||||
Patch12: less-458-outdated-unicode-data.patch
|
Patch12: less-458-outdated-unicode-data.patch
|
||||||
|
Patch13: less-458-return-non-zero.patch
|
||||||
URL: http://www.greenwoodsoftware.com/less/
|
URL: http://www.greenwoodsoftware.com/less/
|
||||||
Requires: groff-base
|
Requires: groff-base
|
||||||
BuildRequires: ncurses-devel
|
BuildRequires: ncurses-devel
|
||||||
@ -47,6 +48,7 @@ files, and you'll use it frequently.
|
|||||||
%patch10 -p1 -b .lesskey-usage
|
%patch10 -p1 -b .lesskey-usage
|
||||||
%patch11 -p1 -b .old-bot
|
%patch11 -p1 -b .old-bot
|
||||||
%patch12 -p1 -b .outdated-unicode-data
|
%patch12 -p1 -b .outdated-unicode-data
|
||||||
|
%patch13 -p1 -b .return-non-zero
|
||||||
autoreconf
|
autoreconf
|
||||||
|
|
||||||
chmod -R a+w *
|
chmod -R a+w *
|
||||||
@ -76,6 +78,10 @@ ls -la $RPM_BUILD_ROOT/etc/profile.d
|
|||||||
rm -rf $RPM_BUILD_ROOT
|
rm -rf $RPM_BUILD_ROOT
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Jun 19 2014 Jozef Mlich <jmlich@redhat.com> - 458-10
|
||||||
|
- (lesspipe) better handling of exit status
|
||||||
|
fixing regression of #186931 - turns over the lesspipe exit behavior
|
||||||
|
|
||||||
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 458-9
|
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 458-9
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
|
||||||
|
|
||||||
|
57
lesspipe.sh
57
lesspipe.sh
@ -11,13 +11,25 @@
|
|||||||
# after the first one in the LESSOPEN environment variable:
|
# after the first one in the LESSOPEN environment variable:
|
||||||
# export LESSOPEN="||/usr/bin/lesspipe.sh %s"
|
# export LESSOPEN="||/usr/bin/lesspipe.sh %s"
|
||||||
|
|
||||||
if [ ! -e "$1" ] ; then
|
|
||||||
|
# This function turns over return values.
|
||||||
|
# 0 becomes 1 and anything else becomes 0
|
||||||
|
# This behavior is forced because backward compatiblity
|
||||||
|
# Bug #186931 - less breaks with tcsh's printexitvalue=1
|
||||||
|
function handle_exit_status() {
|
||||||
|
if [ $1 -eq 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ ! -e "$1" ] ; then
|
||||||
|
handle_exit_status 1 $1 # passing exit status and name of not existing file
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "$1" ] ; then
|
if [ -d "$1" ] ; then
|
||||||
ls -alF -- "$1"
|
ls -alF -- "$1"
|
||||||
exit $?
|
handle_exit_status $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec 2>/dev/null
|
exec 2>/dev/null
|
||||||
@ -26,7 +38,7 @@ exec 2>/dev/null
|
|||||||
if [ -x ~/.lessfilter ]; then
|
if [ -x ~/.lessfilter ]; then
|
||||||
~/.lessfilter "$1"
|
~/.lessfilter "$1"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
exit 0
|
handle_exit_status 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -39,35 +51,35 @@ case "$1" in
|
|||||||
esac
|
esac
|
||||||
if [ -n "$DECOMPRESSOR" ] && $DECOMPRESSOR -- "$1" | file - | grep -q troff; then
|
if [ -n "$DECOMPRESSOR" ] && $DECOMPRESSOR -- "$1" | file - | grep -q troff; then
|
||||||
$DECOMPRESSOR -- "$1" | groff -Tascii -mandoc -
|
$DECOMPRESSOR -- "$1" | groff -Tascii -mandoc -
|
||||||
exit $?
|
handle_exit_status $?
|
||||||
fi ;;&
|
fi ;;&
|
||||||
*.[1-9n]|*.[1-9]x|*.man)
|
*.[1-9n]|*.[1-9]x|*.man)
|
||||||
if file "$1" | grep -q troff; then
|
if file "$1" | grep -q troff; then
|
||||||
groff -Tascii -mandoc "$1" | cat -s
|
groff -Tascii -mandoc "$1" | cat -s
|
||||||
exit $?
|
handle_exit_status $?
|
||||||
fi ;;&
|
fi ;;&
|
||||||
*.tar) tar tvvf "$1" ;;
|
*.tar) tar tvvf "$1"; handle_exit_status $? ;;
|
||||||
*.tgz|*.tar.gz|*.tar.[zZ]) tar tzvvf "$1" ;;
|
*.tgz|*.tar.gz|*.tar.[zZ]) tar tzvvf "$1"; handle_exit_status $? ;;
|
||||||
*.tar.xz) tar Jtvvf "$1" ;;
|
*.tar.xz) tar Jtvvf "$1"; handle_exit_status $? ;;
|
||||||
*.xz|*.lzma) xz -dc -- "$1" ;;
|
*.xz|*.lzma) xz -dc -- "$1"; handle_exit_status $? ;;
|
||||||
*.tar.bz2|*.tbz2) bzip2 -dc -- "$1" | tar tvvf - ;;
|
*.tar.bz2|*.tbz2) bzip2 -dc -- "$1" | tar tvvf -; handle_exit_status $? ;;
|
||||||
*.[zZ]|*.gz) gzip -dc -- "$1" ;;
|
*.[zZ]|*.gz) gzip -dc -- "$1"; handle_exit_status $? ;;
|
||||||
*.bz2) bzip2 -dc -- "$1" ;;
|
*.bz2) bzip2 -dc -- "$1"; handle_exit_status $? ;;
|
||||||
*.zip|*.jar|*.nbm) zipinfo -- "$1" ;;
|
*.zip|*.jar|*.nbm) zipinfo -- "$1"; handle_exit_status $? ;;
|
||||||
*.rpm) rpm -qpivl --changelog -- "$1" ;;
|
*.rpm) rpm -qpivl --changelog -- "$1"; handle_exit_status $? ;;
|
||||||
*.cpi|*.cpio) cpio -itv < "$1" ;;
|
*.cpi|*.cpio) cpio -itv < "$1"; handle_exit_status $? ;;
|
||||||
*.gpg) gpg -d "$1" ;;
|
*.gpg) gpg -d "$1"; handle_exit_status $? ;;
|
||||||
*.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"
|
||||||
exit $?
|
handle_exit_status $?
|
||||||
elif [ -x /usr/bin/gm ]; then
|
elif [ -x /usr/bin/gm ]; then
|
||||||
gm identify "$1"
|
gm identify "$1"
|
||||||
exit $?
|
handle_exit_status $?
|
||||||
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"
|
||||||
exit 1
|
handle_exit_status 1
|
||||||
fi ;;
|
fi ;;
|
||||||
*)
|
*)
|
||||||
if [ -x /usr/bin/file ] && [ -x /usr/bin/iconv ] && [ -x /usr/bin/cut ]; then
|
if [ -x /usr/bin/file ] && [ -x /usr/bin/iconv ] && [ -x /usr/bin/cut ]; then
|
||||||
@ -79,12 +91,9 @@ case "$1" in
|
|||||||
env=`echo $LANG | cut -d. -f2`
|
env=`echo $LANG | cut -d. -f2`
|
||||||
if [ -n "$env" -a "$conv" != "$env" ]; then
|
if [ -n "$env" -a "$conv" != "$env" ]; then
|
||||||
iconv -f $conv -t $env "$1"
|
iconv -f $conv -t $env "$1"
|
||||||
exit $?
|
handle_exit_status $?
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cat "$1"
|
handle_exit_status 1
|
||||||
exit $?
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user