improved which2.sh

This commit is contained in:
Than Ngo 2021-04-26 14:02:33 +02:00
parent 9542d05e68
commit 98662a9c46
2 changed files with 13 additions and 9 deletions

View File

@ -1,13 +1,14 @@
Summary: Displays where a particular program in your path is located
Name: which
Version: 2.21
Release: 24%{?dist}
Release: 25%{?dist}
License: GPLv3
Source0: http://ftp.gnu.org/gnu/which/%{name}-%{version}.tar.gz
Source1: which2.sh
Source2: which2.csh
Patch0: which-2.21-coverity-fixes.patch
Url: https://savannah.gnu.org/projects/which/
Requires: coreutils
BuildRequires: make
BuildRequires: gcc
BuildRequires: readline-devel
@ -40,6 +41,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%{_mandir}/man1/which.1*
%changelog
* Mon Apr 26 2021 Than Ngo <than@redhat.com> - 2.21-25
- improved which2.sh
* Tue Mar 23 2021 Than Ngo <than@redhat.com> - 2.21-24
- fixed regression if SHELL=zsh

View File

@ -1,18 +1,18 @@
# shellcheck shell=sh
# Initialization script for bash, sh, mksh and ksh
_declare="declare -f"
_opt="-f"
_shell="$(basename $SHELL)"
which_declare="declare -f"
which_opt="-f"
which_shell="$(cat /proc/$$/comm)"
if [ "$_shell" = "ksh" ] || [ "$_shell" = "mksh" ] || [ "$_shell" = "zsh" ] ; then
_declare="typeset -f"
_opt=""
if [ "$which_shell" = "ksh" ] || [ "$which_shell" = "mksh" ] || [ "$which_shell" = "zsh" ] ; then
which_declare="typeset -f"
which_opt=""
fi
which ()
{
(alias; eval ${_declare}) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
(alias; eval ${which_declare}) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
export ${_opt} which
export ${which_opt} which