Bash-4.4 distribution sources and documentation
This commit is contained in:
32
print_cmd.c
32
print_cmd.c
@@ -1,6 +1,6 @@
|
||||
/* print_command -- A way to make readable commands from a command tree. */
|
||||
|
||||
/* Copyright (C) 1989-2011 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "shell.h"
|
||||
#include "flags.h"
|
||||
#include <y.tab.h> /* use <...> so we pick it up from the build directory */
|
||||
#include "input.h"
|
||||
|
||||
#include "shmbutil.h"
|
||||
|
||||
@@ -51,6 +52,7 @@ extern int printf __P((const char *, ...)); /* Yuck. Double yuck. */
|
||||
#endif
|
||||
|
||||
extern int indirection_level;
|
||||
extern int posixly_correct;
|
||||
|
||||
static int indentation;
|
||||
static int indentation_amount = 4;
|
||||
@@ -513,7 +515,11 @@ xtrace_print_assignment (name, value, assign_list, xflags)
|
||||
fflush (xtrace_fp);
|
||||
}
|
||||
|
||||
/* A function to print the words of a simple command when set -x is on. */
|
||||
/* A function to print the words of a simple command when set -x is on. Also
|
||||
used to print the word list in a for or select command header; in that case,
|
||||
we suppress quoting the words because they haven't been expanded yet.
|
||||
XTFLAGS&1 means to print $PS4; XTFLAGS&2 means to suppress quoting the
|
||||
words in LIST. */
|
||||
void
|
||||
xtrace_print_word_list (list, xtflags)
|
||||
WORD_LIST *list;
|
||||
@@ -524,7 +530,7 @@ xtrace_print_word_list (list, xtflags)
|
||||
|
||||
CHECK_XTRACE_FP;
|
||||
|
||||
if (xtflags)
|
||||
if (xtflags&1)
|
||||
fprintf (xtrace_fp, "%s", indirection_level_string ());
|
||||
|
||||
for (w = list; w; w = w->next)
|
||||
@@ -532,6 +538,8 @@ xtrace_print_word_list (list, xtflags)
|
||||
t = w->word->word;
|
||||
if (t == 0 || *t == '\0')
|
||||
fprintf (xtrace_fp, "''%s", w->next ? " " : "");
|
||||
else if (xtflags & 2)
|
||||
fprintf (xtrace_fp, "%s%s", t, w->next ? " " : "");
|
||||
else if (sh_contains_shell_metas (t))
|
||||
{
|
||||
x = sh_single_quote (t);
|
||||
@@ -574,7 +582,7 @@ xtrace_print_for_command_head (for_command)
|
||||
CHECK_XTRACE_FP;
|
||||
fprintf (xtrace_fp, "%s", indirection_level_string ());
|
||||
fprintf (xtrace_fp, "for %s in ", for_command->name->word);
|
||||
xtrace_print_word_list (for_command->map_list, 0);
|
||||
xtrace_print_word_list (for_command->map_list, 2);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -632,7 +640,7 @@ xtrace_print_select_command_head (select_command)
|
||||
CHECK_XTRACE_FP;
|
||||
fprintf (xtrace_fp, "%s", indirection_level_string ());
|
||||
fprintf (xtrace_fp, "select %s in ", select_command->name->word);
|
||||
xtrace_print_word_list (select_command->map_list, 0);
|
||||
xtrace_print_word_list (select_command->map_list, 2);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -802,7 +810,7 @@ print_if_command (if_command)
|
||||
newline ("fi");
|
||||
}
|
||||
|
||||
#if defined (DPAREN_ARITHMETIC)
|
||||
#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)
|
||||
void
|
||||
print_arith_command (arith_cmd_list)
|
||||
WORD_LIST *arith_cmd_list;
|
||||
@@ -1275,7 +1283,11 @@ print_function_def (func)
|
||||
REDIRECT *func_redirects;
|
||||
|
||||
func_redirects = NULL;
|
||||
cprintf ("function %s () \n", func->name->word);
|
||||
/* When in posix mode, print functions as posix specifies them. */
|
||||
if (posixly_correct == 0)
|
||||
cprintf ("function %s () \n", func->name->word);
|
||||
else
|
||||
cprintf ("%s () \n", func->name->word);
|
||||
add_unwind_protect (reset_locals, 0);
|
||||
|
||||
indent (indentation);
|
||||
@@ -1334,7 +1346,11 @@ named_function_string (name, command, flags)
|
||||
deferred_heredocs = 0;
|
||||
|
||||
if (name && *name)
|
||||
cprintf ("%s ", name);
|
||||
{
|
||||
if (find_reserved_word (name) >= 0)
|
||||
cprintf ("function ");
|
||||
cprintf ("%s ", name);
|
||||
}
|
||||
|
||||
cprintf ("() ");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user