Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2044450

Summary: which2.sh script should be more robust, sourcing 'which' from custom profile generates shell error
Product: Red Hat Enterprise Linux 8 Reporter: Steve Outteridge <soutteri>
Component: whichAssignee: Than Ngo <than>
Status: CLOSED ERRATA QA Contact: Jakub Haruda <jharuda>
Severity: low Docs Contact:
Priority: unspecified    
Version: 8.5CC: efedin, jharuda, j.k.moore+redhat, rmetrich, than
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: which-2.21-18.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-08 10:46:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Steve Outteridge 2022-01-24 16:22:15 UTC
Description of problem:
The which2.sh script should be more robust, sourcing 'which' from custom profile generates shell error 
 
Version-Release number of selected component (if applicable):
RHEL8

How reproducible:
Always

Steps to Reproduce:
Add profile that refers to which before which2.sh

 $ echo -e "alias which='/usr/bin/which --tty-only --read-alias --show-dot --show-tilde'\n" >/etc/profile.d/S99_test_alias.sh

Any login or su will generate which2 syntax error, the reason for this is S99_test_alias.sh is sourced before /etc/profile/which2.sh, which breaks the latter alias definition


Actual results:
-bash: /etc/profile.d/which2.sh: line 13: syntax error near unexpected token `('
-bash: /etc/profile.d/which2.sh: line 13: `which ()'


Additional info:
"Fix" use "function which" instead of "which()" in /etc/profile.d/which2.sh

Comment 1 Than Ngo 2022-02-04 13:57:20 UTC
i can reproduce this issue with your step, thanks for your report!

Comment 9 James Moore 2022-05-23 16:45:15 UTC
Just wanted to add that I might be seeing a related issue in the start process of a CentOS 7 derived Singularity image. Likely as a result of the Singularity environment setup.

This is currently reflected as:

```
singularity run --cleanenv --no-home  GCC-6.4.0-2.28.sif bash
UID: readonly variable
/usr/bin/cat: : No such file or directory
alias: could not parse "alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde": 1:7: | is not a valid wordLmod Warning: MODULEPATH is undefined.



Lmod has detected the following error: The following module(s) are unknown: "GCC/6.4.0-2.28"

Please check the spelling or version number. Also try "module spider ..."
It is also possible your cache file is out-of-date; it may help to try:
  $ module --ignore-cache load "GCC/6.4.0-2.28"

Also make sure that all modulefiles written in TCL start with the string #%Module
```

```
ls -al /etc/profile.d/
total 8
drwxr-xr-x  2 root root  229 May 23 15:10 .
drwxr-xr-x 50 root root 2091 May 23 16:19 ..
-rw-r--r--  1 root root  196 Mar 24  2017 colorgrep.csh
-rw-r--r--  1 root root  201 Mar 24  2017 colorgrep.sh
-rw-r--r--  1 root root 1741 Aug  6  2019 colorls.csh
-rw-r--r--  1 root root 1606 Aug  6  2019 colorls.sh
-rw-r--r--  1 root root   80 Apr  1  2020 csh.local
-rw-r--r--  1 root root  123 Jul 31  2015 less.csh
-rw-r--r--  1 root root  121 Jul 31  2015 less.sh
lrwxrwxrwx  1 root root   36 May 23 15:10 modules.csh -> /easybuild/deps/lmod/lmod/init/cshrc
lrwxrwxrwx  1 root root   38 May 23 15:09 modules.sh -> /easybuild/deps/lmod/lmod/init/profile
-rw-r--r--  1 root root   81 Apr  1  2020 sh.local
-rw-r--r--  1 root root  164 Jan 27  2014 which2.csh
-rw-r--r--  1 root root  169 Jan 27  2014 which2.sh
```

Build files for the Docker and Singularity image can be found here: https://github.com/jkwmoore/centos7-eb-singularity-image

Comment 11 errata-xmlrpc 2022-11-08 10:46:56 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (which bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:7706

Comment 12 christabelselina 2022-11-25 04:05:33 UTC Comment hidden (spam)