bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

builtin command `command' defect


From: ohki
Subject: builtin command `command' defect
Date: Wed, 1 Jul 2009 16:25:13 +0900 (JST)

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: freebsd6.2
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='freebsd6.2' -DCONF_MACHTYPE='i386-unknown-freebsd6.2' 
-DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib  -I/usr/local/include -g 
-O2
uname output: FreeBSD sma 6.2-RELEASE-p9 FreeBSD 6.2-RELEASE-p9 #1: Sat Dec  1 
15:59:32 JST 2007     address@hidden:/usr/src/sys/i386/compile/SMP  i386
Machine Type: i386-unknown-freebsd6.2

Bash Version: 4.0
Patch Level: 24
Release Status: release

Description:
        builtin command `command' does not report/execute an expected
        command path or description even if `-p' option is specified.
        should not report aliases or user defined functions,
        but it does.

Repeat-By:
        try following commands sequence.

        % ls
        % ...
        % cat /tmp/ls
        #!/bin/sh
        echo ls-/tmp

        % PATH=/tmp:/bin:/sbin:/usr/bin:/usr/sbin
        % command -p ls
           ...                <-- /tmp/ls is executed,
                               but /bin/ls should be
        % command -vp ls
        /bin/ls
        % hash -r
        % command -vp ls       <-- expected output,
        /tmp/ls                 after hash is cleared

Fix:
        apply following patch to builtin/command.def

#---------------------------------------------------------------------------
--- builtins/command.def-ORIG   Mon Jan  5 04:32:22 2009
+++ builtins/command.def        Wed Jul  1 14:19:37 2009
@@ -85,10 +85,10 @@
          use_standard_path = 1;
          break;
        case 'V':
-         verbose = CDESC_SHORTDESC|CDESC_ABSPATH;      /* look in common.h for 
constants */
+         verbose = CDESC_SHORTDESC|CDESC_ABSPATH|CDESC_NOFUNCS;        /* look 
in common.h for constants */
          break;
        case 'v':
-         verbose = CDESC_REUSABLE;     /* ditto */
+         verbose = CDESC_REUSABLE|CDESC_NOFUNCS;       /* ditto */
          break;
        default:
          builtin_usage ();
@@ -100,6 +100,7 @@
   if (list == 0)
     return (EXECUTION_SUCCESS);
 
+#if 0 /* XXXX */
   if (verbose)
     {
       int found, any_found;
@@ -115,6 +116,7 @@
        }
       return (any_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
     }
+#endif /* XXXX */
 
 #if defined (RESTRICTED_SHELL)
   if (use_standard_path && restricted)
@@ -140,8 +142,34 @@
       standard_path = get_standard_path ();
       bind_variable ("PATH", standard_path ? standard_path : "", 0);
       FREE (standard_path);
+      stupidly_hack_special_variables ("PATH"); /* XXXX */
     }
 
+#if 1 /* XXXX */
+  if (verbose)
+    {
+      int found, any_found;
+      extern int expand_aliases; /* XXXX */
+      static int old_expand_aliases; /* XXXX */
+
+      old_expand_aliases = expand_aliases; /* XXXX */
+      expand_aliases = 0; /* XXXX */
+
+      for (any_found = 0; list; list = list->next)
+       {
+         found = describe_command (list->word->word, verbose);
+
+         if (found == 0 && verbose != CDESC_REUSABLE)
+           sh_notfound (list->word->word);
+
+         any_found += found;
+       }
+      expand_aliases = old_expand_aliases; /* XXXX */
+      if (use_standard_path) restore_path(old_path);
+      return (any_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
+    }
+#endif /* XXXX */
+
 #define COMMAND_BUILTIN_FLAGS (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | 
CMD_COMMAND_BUILTIN)
 
   command = make_bare_simple_command ();
@@ -182,6 +210,8 @@
     }
   else
     unbind_variable ("PATH");
+
+  stupidly_hack_special_variables ("PATH"); /* XXXX */
 }
 
 /* Return a value for PATH that is guaranteed to find all of the standard





reply via email to

[Prev in Thread] Current Thread [Next in Thread]