Bash-4.4 distribution sources and documentation

This commit is contained in:
Chet Ramey
2016-09-15 16:59:08 -04:00
parent 30a978b7d8
commit a0c0a00fc4
588 changed files with 130746 additions and 80164 deletions
+12 -68
View File
@@ -1,7 +1,7 @@
This file is command.def, from which is created command.c.
It implements the builtin "command" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -30,10 +30,10 @@ 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
-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.
@@ -63,7 +63,6 @@ extern size_t confstr __P((int, char *, size_t));
extern int subshell_environment;
static void restore_path __P((char *));
static char *get_standard_path __P((void));
/* Run the commands mentioned in LIST without paying attention to shell
functions. */
@@ -82,7 +81,7 @@ command_builtin (list)
switch (opt)
{
case 'p':
use_standard_path = 1;
use_standard_path = CDESC_STDPATH;
break;
case 'V':
verbose = CDESC_SHORTDESC|CDESC_ABSPATH; /* look in common.h for constants */
@@ -90,6 +89,7 @@ command_builtin (list)
case 'v':
verbose = CDESC_REUSABLE; /* ditto */
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
@@ -108,30 +108,13 @@ command_builtin (list)
}
#endif
begin_unwind_frame ("command_builtin");
if (use_standard_path)
{
old_path = get_string_value ("PATH");
/* If old_path is NULL, $PATH is unset. If so, we want to make sure
it's unset after this command completes. */
if (old_path)
old_path = savestring (old_path);
add_unwind_protect ((Function *)restore_path, old_path);
standard_path = get_standard_path ();
bind_variable ("PATH", standard_path ? standard_path : "", 0);
stupidly_hack_special_variables ("PATH");
FREE (standard_path);
}
if (verbose)
{
int found, any_found;
for (any_found = 0; list; list = list->next)
{
found = describe_command (list->word->word, verbose);
found = describe_command (list->word->word, verbose|use_standard_path);
if (found == 0 && verbose != CDESC_REUSABLE)
sh_notfound (list->word->word);
@@ -139,11 +122,12 @@ command_builtin (list)
any_found += found;
}
run_unwind_frame ("command_builtin");
return (any_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
}
#define COMMAND_BUILTIN_FLAGS (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | CMD_COMMAND_BUILTIN)
begin_unwind_frame ("command_builtin");
#define COMMAND_BUILTIN_FLAGS (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | CMD_COMMAND_BUILTIN | (use_standard_path ? CMD_STDPATH : 0))
/* We don't want this to be reparsed (consider command echo 'foo &'), so
just make a simple_command structure and call execute_command with it. */
@@ -152,18 +136,7 @@ command_builtin (list)
command->value.Simple->redirects = (REDIRECT *)NULL;
command->flags |= COMMAND_BUILTIN_FLAGS;
command->value.Simple->flags |= COMMAND_BUILTIN_FLAGS;
#if 0
/* This breaks for things like ( cd /tmp ; command z ababa ; echo next )
or $(command echo a ; command echo b;) or even
{ command echo a; command echo b; } & */
/* If we're in a subshell, see if we can get away without forking
again, since we've already forked to run this builtin. */
if (subshell_environment)
{
command->flags |= CMD_NO_FORK;
command->value.Simple->flags |= CMD_NO_FORK;
}
#endif
add_unwind_protect ((char *)dispose_command, command);
result = execute_command (command);
@@ -188,32 +161,3 @@ restore_path (var)
stupidly_hack_special_variables ("PATH");
}
/* Return a value for PATH that is guaranteed to find all of the standard
utilities. This uses Posix.2 configuration variables, if present. It
uses a value defined in config.h as a last resort. */
static char *
get_standard_path ()
{
#if defined (_CS_PATH) && defined (HAVE_CONFSTR)
char *p;
size_t len;
len = (size_t)confstr (_CS_PATH, (char *)NULL, (size_t)0);
if (len > 0)
{
p = (char *)xmalloc (len + 2);
*p = '\0';
confstr (_CS_PATH, p, len);
return (p);
}
else
return (savestring (STANDARD_UTILS_PATH));
#else /* !_CS_PATH || !HAVE_CONFSTR */
# if defined (CS_PATH)
return (savestring (CS_PATH));
# else
return (savestring (STANDARD_UTILS_PATH));
# endif /* !CS_PATH */
#endif /* !_CS_PATH || !HAVE_CONFSTR */
}