Bug 1410087
Summary: | bash searches $PATH only if the command is not already hashed | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Marek Haicman <mhaicman> |
Component: | bash | Assignee: | Siteshwar Vashisht <svashisht> |
Status: | CLOSED NOTABUG | QA Contact: | BaseOS QE - Apps <qe-baseos-apps> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 7.3 | CC: | kdudka |
Target Milestone: | rc | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2017-01-05 09:31:59 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
Marek Haicman
2017-01-04 12:35:24 UTC
(In reply to Marek Haicman from comment #0) > Actual results: > [dahaic@dhcp-24-168 ~]$ echo $PATH > /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/dahaic/. > local/bin:/home/dahaic/bin > [dahaic@dhcp-24-168 ~]$ sudo cp a_1.sh /usr/bin/a.sh > [dahaic@dhcp-24-168 ~]$ a.sh > 1 > [dahaic@dhcp-24-168 ~]$ sudo cp a_2.sh /usr/local/bin/a.sh > [dahaic@dhcp-24-168 ~]$ a.sh > 2 For me it already prints 1 in the above step, which is the documented behavior of bash -- see the bash(1) man page: Bash uses a hash table to remember the full pathnames of executable files (see hash under SHELL BUILTIN COMMANDS below). A full search of the directories in PATH is performed only if the command is not found in the hash table. So just use the 'hash' built-in to update the hash table in cases like this. Thank you for the explanation, Kamil. Can we at least ignore the hash table, when binary is not found in the location? It happened to me few times :) [dahaic@dhcp-24-168 openscap]$ oscap --version bash: /usr/bin/oscap: No such file or directory [dahaic@dhcp-24-168 openscap]$ hash -r [dahaic@dhcp-24-168 openscap]$ oscap --version OpenSCAP command line tool (oscap) 1.2.13 (In reply to Marek Haicman from comment #2) > Can we at least ignore the hash table, when binary is not found in the > location? It would contradict the current documentation for no real benefit. Even if you convince upstream that it is a good idea, the behavior is not going to change in any released products. > It happened to me few times :) Given the fact that the hashing affects only the current session, it should not happen in usual workflows. Why do you remove /usr/bin/oscap? If you do it intentionally to force using oscap from a different location, then just invoke 'hash oscap' to make it explicit. > [dahaic@dhcp-24-168 openscap]$ oscap --version > bash: /usr/bin/oscap: No such file or directory > [dahaic@dhcp-24-168 openscap]$ hash -r > [dahaic@dhcp-24-168 openscap]$ oscap --version > OpenSCAP command line tool (oscap) 1.2.13 Note that the hashing can also be disabled via 'set +h'. For posterity - I was doing make uninstall, to check whether version provided via RPM has the same error as the upstream version. Even though it's not very transparent behaviour for someone not aware of the hashing, it does behave in documented way. I have no more objections and we can close it as NOTABUG. Thank you for clarifying it! Closing... |