diff --git a/which.spec b/which.spec index fac26a9..676c9a0 100644 --- a/which.spec +++ b/which.spec @@ -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 - 2.21-25 +- improved which2.sh + * Tue Mar 23 2021 Than Ngo - 2.21-24 - fixed regression if SHELL=zsh diff --git a/which2.sh b/which2.sh index 2b8b20a..16b930c 100644 --- a/which2.sh +++ b/which2.sh @@ -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