bad path in bash

Smoot Carl-Mitchell smoot at tic.com
Tue Mar 24 17:11:22 UTC 2009


On Tue, 2009-03-24 at 00:48 -0700, Sundar Nagarajan wrote:
> Walton Hoops wrote:
> > 
> Did you uninstall the existing MySQL and in the same shell install from 
> source? Could it be that the original MySQL was in /usr/bin/mysql and 
> you required a 'rehash' for bash to re-read the locations of commands in 
> the path? That does not explain why 'which mysql' returned 
> /usr/local/bin/mysql, or does it? Maybe which is an external command 
> that is spawned in a new subshell that creates a new hash of the 
> locations of commands in the path - and thus finds mysql in /usr/local/bin?

'which' likely does not use the shell command cache.  To avoid the above
behavior you could put this in you .profile

shopt -s checkhash

This makes the shell check the existence of a command's path as found in
the cache.  If the command does not exist it then does a full PATH
search for the command.
-- 
Smoot Carl-Mitchell
Computer Systems and
Network Consultant
smoot at tic.com
+1 480 922 7313
cell: +1 602 421 9005




More information about the ubuntu-users mailing list