diff --git a/download b/download new file mode 100644 index 0000000000000000000000000000000000000000..4b6d13d6f0b2703985e07238c52cebeb77cd1cbd --- /dev/null +++ b/download @@ -0,0 +1 @@ +097ff1a324ae02e0a3b0369f07a7544a which-2.21.tar.gz diff --git a/which-2.21.tar.gz b/which-2.21.tar.gz deleted file mode 100644 index ee8c4280545400c6e478bd82839f9ae2cf185995..0000000000000000000000000000000000000000 Binary files a/which-2.21.tar.gz and /dev/null differ diff --git a/which.spec b/which.spec index 46d38a97f96d799be5b8620ab1fc27d353da82f6..489f39ca64d28ef40ada9698c959b7d693b37fdf 100644 --- a/which.spec +++ b/which.spec @@ -1,7 +1,7 @@ Summary: Displays where a particular program in your path is located Name: which Version: 2.21 -Release: 16%{?dist} +Release: 17%{?dist} License: GPLv3 Source0: http://ftp.gnu.org/gnu/which/%{name}-%{version}.tar.gz Source1: which2.sh @@ -9,7 +9,8 @@ Source2: which2.csh Patch0: which-2.21-coverity-fixes.patch Patch1: which-2.21-coverity.patch Url: https://savannah.gnu.org/projects/which/ -BuildRequires: gcc +Requires: coreutils +BuildRequires: gcc BuildRequires: readline-devel %description @@ -41,6 +42,10 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %{_mandir}/man1/which.1* %changelog +* Thu Nov 25 2021 Than Ngo - 2.21-17 +- Resolves: #2025709, check shell correctly +- Resolves: #2009547, which treats function contents as aliases when parsing ksh + * Wed May 05 2021 Than Ngo - 2.21-16 - Related: #1940468, fixed unbound variable diff --git a/which2.sh b/which2.sh index 6ef7979b1f61a0156d1fd3d9c9fa4965104ee95a..0f47f9e03b9ba64c2e9ff2b805ab07a35d40817c 100644 --- a/which2.sh +++ b/which2.sh @@ -1,18 +1,27 @@ # shellcheck shell=sh # Initialization script for bash, sh, mksh and ksh -which_declare="declare -f" -which_opt="-f" -which_shell="$(cat /proc/$$/comm)" +case "$(basename $(readlink /proc/$$/exe))" in +*ksh*) + which_declare="" + which_opt="" + ;; +zsh) + which_declare="typeset -f" + which_opt="" + ;; +bash|sh) + which_declare="declare -f" + which_opt="-f" + ;; +*) + which_declare="" + which_opt="" + ;; +esac -if [ "$which_shell" = "ksh" ] || [ "$which_shell" = "mksh" ] || [ "$which_shell" = "zsh" ] ; then - which_declare="typeset -f" - which_opt="" -fi - -which () -{ -(alias; eval ${which_declare}) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@" +which () { + (alias; eval ${which_declare}) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@ } export which_declare