Bash-4.2 distribution sources and documentation
[platform/upstream/bash.git] / builtins / hash.def
index 7a8aced..6724ad1 100644 (file)
@@ -1,7 +1,7 @@
 This file is hash.def, from which is created hash.c.
 It implements the builtin "hash" in Bash.
 
-Copyright (C) 1987-2009 Free Software Foundation, Inc.
+Copyright (C) 1987-2010 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -159,7 +159,9 @@ hash_builtin (list)
     {
       /* Add, remove or rehash the specified commands. */
       w = list->word->word;
-      if (pathname)
+      if (absolute_program (w))
+       continue;
+      else if (pathname)
        {
          if (is_directory (pathname))
            {
@@ -173,8 +175,6 @@ hash_builtin (list)
          else
            phash_insert (w, pathname, 0, 0);
        }
-      else if (absolute_program (w))
-       continue;
       else if (delete)
        {
          if (phash_remove (w))
@@ -202,6 +202,7 @@ add_hashed_command (w, quiet)
   rv = 0;
   if (find_function (w) == 0 && find_shell_builtin (w) == 0)
     {
+      phash_remove (w);
       full_path = find_user_command (w);
       if (full_path && executable_file (full_path))
        phash_insert (w, full_path, dot_found_in_search, 0);