Bug 921213 - PATH cache sticky
Summary: PATH cache sticky
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 18
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Roman Rakus
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-03-13 17:50 UTC by Bob Gustafson
Modified: 2014-01-13 00:15 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2013-03-14 14:16:01 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Bob Gustafson 2013-03-13 17:50:57 UTC
Description of problem:

While researching a different problem, I noticed that executable locations previously found using PATH and a relative pathname stick in a cache somewhere.

If the 'found' executable is deleted or renamed, the previously resolved location of the executable is used (and fails) instead of re-resolving the location using the PATH and the relative name.

Version-Release number of selected component (if applicable):

# bash --version
GNU bash, version 4.2.42(1)-release (x86_64-redhat-linux-gnu)

How reproducible:

  Consistent until logout/login

Steps to Reproduce:

1. make two executables that echo their absolute location in the file system.
   Such as - for /usr/bin/pathtest.sh

   #!/bin/bash
   echo "I am in /usr/bin/"

   and - for /usr/sbin/pathtest.sh

   #!/bin/bash
   echo "I am in /usr/sbin/"

2. execute the following commands:

# echo $PATH
/root/perl5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

# which -a pathtest.sh
/usr/sbin/pathtest.sh
/usr/bin/pathtest.sh

# pathtest.sh
I am in /usr/sbin/

# mv /usr/sbin/pathtest.sh /usr/sbin/xpathtest.sh

# which -a pathtest.sh
/usr/bin/pathtest.sh

# pathtest.sh
-bash: /usr/sbin/pathtest.sh: No such file or directory
#

3. Note that even though /usr/bin/pathtest.sh exists and is on a path within PATH, it is not found.
  
Actual results:

# which -a pathtest.sh
/usr/bin/pathtest.sh
# pathtest.sh
-bash: /usr/sbin/pathtest.sh: No such file or directory

Expected results:

# pathtest.sh
I am in /usr/bin/

Additional info:

Comment 1 Roman Rakus 2013-03-14 14:16:01 UTC
Use `type' instead of `which'. Bash is using hashtable to remember executed files. There are several ways to clean table, don't use table at all...


Note You need to log in before you can comment on or make changes to this bug.