<h1>Problem</h1>
<p>After moving to RHEL 8.5 from 8.4, started having the issue of K8S pods failure.</p>
<pre><code>spec.template.spec.containers[0].env[52].name: Invalid value: &quot;BASH_FUNC_which%%&quot;: a valid environment variable name must 
consist of alphabetic characters, digits, '_', '-', or '.', and must not start with a digit (e.g. 'my.env-name',  or 'MY_ENV.NAME',  or 'MyEnvName1', regex used for validation is '[-._a-zA-Z][-._a-zA-Z0-9]*')
</code></pre>
<p>The <strong>env</strong> command in the login shell shows <code>BASH_FUNC_which%%</code> defined as below.</p>
<pre><code>BASH_FUNC_which%%=() {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot &quot;$@&quot;
}
</code></pre>
<p>Suggeted that <code>/etc/profile.d/which2.sh</code> is the one that sets up the <code>BASH_FUNC_which%%</code>.</p>
<ul>
<li>/etc/profile.d/which2.sh</li>
</ul>
<pre><code>
# shellcheck shell=sh
# Initialization script for bash, sh, mksh and ksh

which_declare=&quot;declare -f&quot;
which_opt=&quot;-f&quot;
which_shell=&quot;$(cat /proc/$$/comm)&quot;

if [ &quot;$which_shell&quot; = &quot;ksh&quot; ] || [ &quot;$which_shell&quot; = &quot;mksh&quot; ] || [ &quot;$which_shell&quot; = &quot;zsh&quot; ] ; then
  which_declare=&quot;typeset -f&quot;
  which_opt=&quot;&quot;
fi
 
which ()
{
(alias; eval ${which_declare}) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot &quot;$@&quot;
}

export which_declare
export ${which_opt} which
</code></pre>
<p>By removing it, the issue was fixed.</p>
<h1>Question</h1>
<p>Please help understand where exactly <code>BASH_FUNC_which%%</code> is setup in RHEL8.5 and what is the purpose of this <code>BASH_FUNC_which%%</code>, why is has been introduced in RHEL.</p>

mon
<p>Answering the first part:</p>
<p>Output of <code>rpm -q --changes which-2.21-28.el9.x86_64</code></p>
<pre><code>* Fri Apr 15 14:00:00 2022 Than Ngo &lt;than@redhat.com&gt; - 2.21-28
- Resolves: #2050996, error on login when using ksh as the default shell

* Tue Aug 10 14:00:00 2021 Mohan Boddu &lt;mboddu@redhat.com&gt; - 2.21-27
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
  Related: rhbz#1991688

* Fri May  7 14:00:00 2021 Than Ngo &lt;than@redhat.com&gt; - 2.21-26
- Related: #1940464, fixed unbound variable

* Fri Apr 16 14:00:00 2021 Mohan Boddu &lt;mboddu@redhat.com&gt; - 2.21-25
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937

* Tue Mar 23 13:00:00 2021 Than Ngo &lt;than@redhat.com&gt; - 2.21-24
- fix regression in zsh

* Sun Mar 21 13:00:00 2021 Than Ngo &lt;than@redhat.com&gt; - 2.21-23
- improved which2.sh
</code></pre>
<p>Possibly, than@redhat.com can elaborate what is going on?
Or, since you use RHEL, you could contact RedHat support?</p>
