This file is command.def, from which is created command.c.
It implements the builtin "command" in Bash.
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+Copyright (C) 1987-2009 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
-Bash is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
+Bash is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
-Bash is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
+Bash is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
-You should have received a copy of the GNU General Public License along
-with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+You should have received a copy of the GNU General Public License
+along with Bash. If not, see <http://www.gnu.org/licenses/>.
$PRODUCES command.c
$BUILTIN command
$FUNCTION command_builtin
$SHORT_DOC command [-pVv] command [arg ...]
-Runs COMMAND with ARGS ignoring shell functions. If you have a shell
-function called `ls', and you wish to call the command `ls', you can
-say "command ls". If the -p option is given, a default value is used
-for PATH that is guaranteed to find all of the standard utilities. If
-the -V or -v option is given, a string is printed describing COMMAND.
-The -V option produces a more verbose description.
+Execute a simple command or display information about commands.
+
+Runs COMMAND with ARGS suppressing shell function lookup, or display
+information about the specified COMMANDs. Can be used to invoke commands
+on disk when a function with the same name exists.
+
+Options:
+ -p use a default value for PATH that is guaranteed to find all of
+ the standard utilities
+ -v print a description of COMMAND similar to the `type' builtin
+ -V print a more verbose description of each COMMAND
+
+Exit Status:
+Returns exit status of COMMAND, or failure if COMMAND is not found.
$END
#include <config.h>
use_standard_path = 1;
break;
case 'V':
- verbose = 2;
+ verbose = CDESC_SHORTDESC|CDESC_ABSPATH; /* look in common.h for constants */
break;
case 'v':
- verbose = 4;
+ verbose = CDESC_REUSABLE; /* ditto */
break;
default:
builtin_usage ();
for (any_found = 0; list; list = list->next)
{
- found = describe_command (list->word->word, verbose, 0);
+ found = describe_command (list->word->word, verbose);
- if (found == 0)
- builtin_error ("%s: not found", list->word->word);
+ if (found == 0 && verbose != CDESC_REUSABLE)
+ sh_notfound (list->word->word);
any_found += found;
}
#if defined (RESTRICTED_SHELL)
if (use_standard_path && restricted)
{
- builtin_error ("restricted: cannot use -p");
+ sh_restricted ("-p");
return (EXECUTION_FAILURE);
}
#endif
add_unwind_protect ((Function *)restore_path, old_path);
standard_path = get_standard_path ();
- bind_variable ("PATH", standard_path ? standard_path : "");
+ bind_variable ("PATH", standard_path ? standard_path : "", 0);
FREE (standard_path);
}
{
if (var)
{
- bind_variable ("PATH", var);
+ bind_variable ("PATH", var, 0);
free (var);
}
else