which-bugs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Issue with which package adding strange environment variable


From: Nathan Hamilton
Subject: Issue with which package adding strange environment variable
Date: Tue, 10 Oct 2023 16:08:52 +0000

Hello,

Our company is using  Amazon Linux 2023 as the base image for the dockerfile of several of our applications and it natively includes the package which​ according to the documentation the Amazon has provided: https://docs.aws.amazon.com/linux/al2023/release-notes/all-packages-AL2023.2.html

However, when our applications load, we get a strange readout of an unrecognized environment variable. When I run the shell command printenv​ I get the following in the readout:

```
BASH_FUNC_which%%=() {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
```

I searched through the applications source files to see where this was getting set and I found this was being set in /etc/profile.d/which2.sh​. Here's the contents of this file:

```
[app@7b4e2c1bf547 app]$ cat /etc/profile.d/which2.sh
# shellcheck shell=sh
# Initialization script for bash, sh, mksh and ksh

which_declare="declare -f"
which_opt="-f"
which_shell="$(cat /proc/$$/comm)"

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 "$@"
}

export which_declare
export ${which_opt} which
```

Here is the version of the which package that amazonlinux:2023 is providing:
```
[app@7b4e2c1bf547 app]$ which -v
GNU which v2.21, Copyright (C) 1999 - 2015 Carlo Wood.
GNU which comes with ABSOLUTELY NO WARRANTY;
This program is free software; your freedom to use, change
and distribute this program is protected by the GPL.
```

Thankfully this is not affecting our applications operation at all, but it produces confusing output that leads to a lack of understanding of what's transpiring. Could you point me to a way this could be resolved? Thanks!


For Christ's Glory

Nathan Hamilton
Software Engineer

Lumerit / AP / Global Enabling Functions
San Antonio, TX
M (210) 436-9097
 
Learn more at pearson.com
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]