diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index e12e95b3..122d615c 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -7314,3 +7314,73 @@ execute_cmd.c is run and that call doesn't return. From a report by Harald van Dijk following up to a report by Martijn Dekker + + 2/10 + ---- +builtins/trap.def + - trap_builtin: in posix mode, when trap is run with -p, show + the disposition of all signals, even those that are still in the + default state, including signals that were ignored when the shell + starts up and haven't been reset. Don't do it in default mode. + From an austin-group discussion back in April, 2019 (interp 1211) + +findcmd.c + - search_for_command: don't add commands without the execute bit set + to the command hash table. From https://savannah.gnu.org/patch/?9789 + contributed by michaeljs1990 + + 2/11 + ---- +expr.c + - strlong: require `base#' to be followed by an integer constant; + otherwise throw an error. From a report from Jeremy Townshend + back in June, 2019 + +test.c + - unary_test: allow -v N to test whether or not positional parameter + N is set. Most recently suggested by Peng Yu + and Martijn Dekker + +builtins/getopts.def + - dogetopts: use number_of_args() to compute the number of positional + parameters + +{findcmd,variables,subst,trap,sig}.h,builtins/common.h + - __P --> PARAMS + +builtins/shift.def,builtins/common.c + - shift_builtin: moved code that modifies dollar_vars and rest_of_args + to common.c:shift_args(int times), part of move to localize changes + to positional parameters + +builtins/common.c,variables.c + - posparam_count: keep a running count of the number of posititional + parameters when dollar_vars and rest_of_args are set + + 2/12 + ---- +subst.c + - number_of_args: just return posparam_count + +builtins/shift.def + - shift_builtin: if asked to clear the positional parameters with + something like `shift $#', just call clear_dollar_vars instead of + iterating through them, unsetting them one by one + +subst.[ch],builtins/common.[ch] + - number_of_args: moved to builtins/common.c + + 2/14 + ---- +subst.c + - clear_fifo_list: when using named pipes, clear out the FIFO list + without unlinking anything and set NFIFO to 0 + +execute_cmd.c + - execute_disk_command: in the child, clear out the FIFO list, since + we haven't created any FIFOs yet + - execute_in_subshell: clear out the FIFO list, since we haven't + created any FIFOs yet + +parse.y + - special_case_tokens: allow `time -- command' diff --git a/arrayfunc.c b/arrayfunc.c index 5ecad4e8..67afb300 100644 --- a/arrayfunc.c +++ b/arrayfunc.c @@ -1006,7 +1006,7 @@ array_expand_index (var, s, len, flags) exp = (char *)xmalloc (len); strncpy (exp, s, len - 1); exp[len - 1] = '\0'; -#if 0 /* XXX - not yet -- maybe bash-5.1 */ +#if 0 /* TAG: maybe bash-5.1 */ if ((flags & AV_NOEXPAND) == 0) t = expand_arith_string (exp, Q_DOUBLE_QUOTES|Q_ARITH|Q_ARRAYSUB); /* XXX - Q_ARRAYSUB for future use */ else diff --git a/builtins/common.c b/builtins/common.c index 2facb0c8..3c9ac49d 100644 --- a/builtins/common.c +++ b/builtins/common.c @@ -1,6 +1,6 @@ /* common.c - utility functions for all builtins */ -/* Copyright (C) 1987-2017 Free Software Foundation, Inc. +/* Copyright (C) 1987-2020 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -373,7 +373,8 @@ make_builtin_argv (list, ip) /* Remember LIST in $1 ... $9, and REST_OF_ARGS. If DESTRUCTIVE is non-zero, then discard whatever the existing arguments are, else - only discard the ones that are to be replaced. */ + only discard the ones that are to be replaced. Set POSPARAM_COUNT + to the number of args assigned (length of LIST). */ void remember_args (list, destructive) WORD_LIST *list; @@ -381,6 +382,8 @@ remember_args (list, destructive) { register int i; + posparam_count = 0; + for (i = 1; i < 10; i++) { if ((destructive || list) && dollar_vars[i]) @@ -391,7 +394,7 @@ remember_args (list, destructive) if (list) { - dollar_vars[i] = savestring (list->word->word); + dollar_vars[posparam_count = i] = savestring (list->word->word); list = list->next; } } @@ -403,6 +406,7 @@ remember_args (list, destructive) { dispose_words (rest_of_args); rest_of_args = copy_word_list (list); + posparam_count += list_length (list); } if (destructive) @@ -411,6 +415,58 @@ remember_args (list, destructive) invalidate_cached_quoted_dollar_at (); } +void +shift_args (times) + int times; +{ + WORD_LIST *temp; + int count; + + if (times <= 0) /* caller should check */ + return; + + while (times-- > 0) + { + if (dollar_vars[1]) + free (dollar_vars[1]); + + for (count = 1; count < 9; count++) + dollar_vars[count] = dollar_vars[count + 1]; + + if (rest_of_args) + { + temp = rest_of_args; + dollar_vars[9] = savestring (temp->word->word); + rest_of_args = rest_of_args->next; + temp->next = (WORD_LIST *)NULL; + dispose_words (temp); + } + else + dollar_vars[9] = (char *)NULL; + + posparam_count--; + } +} + +int +number_of_args () +{ +#ifdef DEBUG + register WORD_LIST *list; + int n; + + for (n = 0; n < 9 && dollar_vars[n+1]; n++) + ; + for (list = rest_of_args; list; list = list->next) + n++; + +if (n != posparam_count) + itrace("number_of_args: n (%d) != posparam_count (%d)", n, posparam_count); +#endif + + return posparam_count; +} + static int changed_dollar_vars; /* Have the dollar variables been reset to new values since we last diff --git a/builtins/common.h b/builtins/common.h index 214a125f..d6fd99d9 100644 --- a/builtins/common.h +++ b/builtins/common.h @@ -1,6 +1,6 @@ /* common.h -- extern declarations for functions defined in common.c. */ -/* Copyright (C) 1993-2015 Free Software Foundation, Inc. +/* Copyright (C) 1993-2020 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -80,145 +80,147 @@ do { \ #define MAX_ATTRIBUTES 16 /* Functions from common.c */ -extern void builtin_error __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2))); -extern void builtin_warning __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2))); -extern void builtin_usage __P((void)); -extern void no_args __P((WORD_LIST *)); -extern int no_options __P((WORD_LIST *)); +extern void builtin_error PARAMS((const char *, ...)) __attribute__((__format__ (printf, 1, 2))); +extern void builtin_warning PARAMS((const char *, ...)) __attribute__((__format__ (printf, 1, 2))); +extern void builtin_usage PARAMS((void)); +extern void no_args PARAMS((WORD_LIST *)); +extern int no_options PARAMS((WORD_LIST *)); /* common error message functions */ -extern void sh_needarg __P((char *)); -extern void sh_neednumarg __P((char *)); -extern void sh_notfound __P((char *)); -extern void sh_invalidopt __P((char *)); -extern void sh_invalidoptname __P((char *)); -extern void sh_invalidid __P((char *)); -extern void sh_invalidnum __P((char *)); -extern void sh_invalidsig __P((char *)); -extern void sh_erange __P((char *, char *)); -extern void sh_badpid __P((char *)); -extern void sh_badjob __P((char *)); -extern void sh_readonly __P((const char *)); -extern void sh_nojobs __P((char *)); -extern void sh_restricted __P((char *)); -extern void sh_notbuiltin __P((char *)); -extern void sh_wrerror __P((void)); -extern void sh_ttyerror __P((int)); -extern int sh_chkwrite __P((int)); +extern void sh_needarg PARAMS((char *)); +extern void sh_neednumarg PARAMS((char *)); +extern void sh_notfound PARAMS((char *)); +extern void sh_invalidopt PARAMS((char *)); +extern void sh_invalidoptname PARAMS((char *)); +extern void sh_invalidid PARAMS((char *)); +extern void sh_invalidnum PARAMS((char *)); +extern void sh_invalidsig PARAMS((char *)); +extern void sh_erange PARAMS((char *, char *)); +extern void sh_badpid PARAMS((char *)); +extern void sh_badjob PARAMS((char *)); +extern void sh_readonly PARAMS((const char *)); +extern void sh_nojobs PARAMS((char *)); +extern void sh_restricted PARAMS((char *)); +extern void sh_notbuiltin PARAMS((char *)); +extern void sh_wrerror PARAMS((void)); +extern void sh_ttyerror PARAMS((int)); +extern int sh_chkwrite PARAMS((int)); -extern char **make_builtin_argv __P((WORD_LIST *, int *)); -extern void remember_args __P((WORD_LIST *, int)); +extern char **make_builtin_argv PARAMS((WORD_LIST *, int *)); +extern void remember_args PARAMS((WORD_LIST *, int)); +extern void shift_args PARAMS((int)); +extern int number_of_args PARAMS((void)); -extern int dollar_vars_changed __P((void)); -extern void set_dollar_vars_unchanged __P((void)); -extern void set_dollar_vars_changed __P((void)); +extern int dollar_vars_changed PARAMS((void)); +extern void set_dollar_vars_unchanged PARAMS((void)); +extern void set_dollar_vars_changed PARAMS((void)); -extern int get_numeric_arg __P((WORD_LIST *, int, intmax_t *)); -extern int get_exitstat __P((WORD_LIST *)); -extern int read_octal __P((char *)); +extern int get_numeric_arg PARAMS((WORD_LIST *, int, intmax_t *)); +extern int get_exitstat PARAMS((WORD_LIST *)); +extern int read_octal PARAMS((char *)); /* Keeps track of the current working directory. */ extern char *the_current_working_directory; -extern char *get_working_directory __P((char *)); -extern void set_working_directory __P((char *)); +extern char *get_working_directory PARAMS((char *)); +extern void set_working_directory PARAMS((char *)); #if defined (JOB_CONTROL) -extern int get_job_by_name __P((const char *, int)); -extern int get_job_spec __P((WORD_LIST *)); +extern int get_job_by_name PARAMS((const char *, int)); +extern int get_job_spec PARAMS((WORD_LIST *)); #endif -extern int display_signal_list __P((WORD_LIST *, int)); +extern int display_signal_list PARAMS((WORD_LIST *, int)); /* It's OK to declare a function as returning a Function * without providing a definition of what a `Function' is. */ -extern struct builtin *builtin_address_internal __P((char *, int)); -extern sh_builtin_func_t *find_shell_builtin __P((char *)); -extern sh_builtin_func_t *builtin_address __P((char *)); -extern sh_builtin_func_t *find_special_builtin __P((char *)); -extern void initialize_shell_builtins __P((void)); +extern struct builtin *builtin_address_internal PARAMS((char *, int)); +extern sh_builtin_func_t *find_shell_builtin PARAMS((char *)); +extern sh_builtin_func_t *builtin_address PARAMS((char *)); +extern sh_builtin_func_t *find_special_builtin PARAMS((char *)); +extern void initialize_shell_builtins PARAMS((void)); /* Functions from exit.def */ -extern void bash_logout __P((void)); +extern void bash_logout PARAMS((void)); /* Functions from getopts.def */ -extern void getopts_reset __P((int)); +extern void getopts_reset PARAMS((int)); /* Functions from help.def */ -extern void builtin_help __P((void)); +extern void builtin_help PARAMS((void)); /* Functions from read.def */ -extern void read_tty_cleanup __P((void)); -extern int read_tty_modified __P((void)); +extern void read_tty_cleanup PARAMS((void)); +extern int read_tty_modified PARAMS((void)); /* Functions from set.def */ -extern int minus_o_option_value __P((char *)); -extern void list_minus_o_opts __P((int, int)); -extern char **get_minus_o_opts __P((void)); -extern int set_minus_o_option __P((int, char *)); +extern int minus_o_option_value PARAMS((char *)); +extern void list_minus_o_opts PARAMS((int, int)); +extern char **get_minus_o_opts PARAMS((void)); +extern int set_minus_o_option PARAMS((int, char *)); -extern void set_shellopts __P((void)); -extern void parse_shellopts __P((char *)); -extern void initialize_shell_options __P((int)); +extern void set_shellopts PARAMS((void)); +extern void parse_shellopts PARAMS((char *)); +extern void initialize_shell_options PARAMS((int)); -extern void reset_shell_options __P((void)); +extern void reset_shell_options PARAMS((void)); -extern char *get_current_options __P((void)); -extern void set_current_options __P((const char *)); +extern char *get_current_options PARAMS((void)); +extern void set_current_options PARAMS((const char *)); /* Functions from shopt.def */ -extern void reset_shopt_options __P((void)); -extern char **get_shopt_options __P((void)); +extern void reset_shopt_options PARAMS((void)); +extern char **get_shopt_options PARAMS((void)); -extern int shopt_setopt __P((char *, int)); -extern int shopt_listopt __P((char *, int)); +extern int shopt_setopt PARAMS((char *, int)); +extern int shopt_listopt PARAMS((char *, int)); -extern int set_login_shell __P((char *, int)); +extern int set_login_shell PARAMS((char *, int)); -extern void set_bashopts __P((void)); -extern void parse_bashopts __P((char *)); -extern void initialize_bashopts __P((int)); +extern void set_bashopts PARAMS((void)); +extern void parse_bashopts PARAMS((char *)); +extern void initialize_bashopts PARAMS((int)); -extern void set_compatibility_opts __P((void)); +extern void set_compatibility_opts PARAMS((void)); /* Functions from type.def */ -extern int describe_command __P((char *, int)); +extern int describe_command PARAMS((char *, int)); /* Functions from setattr.def */ -extern int set_or_show_attributes __P((WORD_LIST *, int, int)); -extern int show_all_var_attributes __P((int, int)); -extern int show_var_attributes __P((SHELL_VAR *, int, int)); -extern int show_name_attributes __P((char *, int)); -extern int show_func_attributes __P((char *, int)); -extern void set_var_attribute __P((char *, int, int)); -extern int var_attribute_string __P((SHELL_VAR *, int, char *)); +extern int set_or_show_attributes PARAMS((WORD_LIST *, int, int)); +extern int show_all_var_attributes PARAMS((int, int)); +extern int show_var_attributes PARAMS((SHELL_VAR *, int, int)); +extern int show_name_attributes PARAMS((char *, int)); +extern int show_func_attributes PARAMS((char *, int)); +extern void set_var_attribute PARAMS((char *, int, int)); +extern int var_attribute_string PARAMS((SHELL_VAR *, int, char *)); /* Functions from pushd.def */ -extern char *get_dirstack_from_string __P((char *)); -extern char *get_dirstack_element __P((intmax_t, int)); -extern void set_dirstack_element __P((intmax_t, int, char *)); -extern WORD_LIST *get_directory_stack __P((int)); +extern char *get_dirstack_from_string PARAMS((char *)); +extern char *get_dirstack_element PARAMS((intmax_t, int)); +extern void set_dirstack_element PARAMS((intmax_t, int, char *)); +extern WORD_LIST *get_directory_stack PARAMS((int)); /* Functions from evalstring.c */ -extern int parse_and_execute __P((char *, const char *, int)); -extern int evalstring __P((char *, const char *, int)); -extern void parse_and_execute_cleanup __P((int)); -extern int parse_string __P((char *, const char *, int, char **)); -extern int should_suppress_fork __P((COMMAND *)); -extern int can_optimize_connection __P((COMMAND *)); -extern void optimize_fork __P((COMMAND *)); -extern void optimize_subshell_command __P((COMMAND *)); +extern int parse_and_execute PARAMS((char *, const char *, int)); +extern int evalstring PARAMS((char *, const char *, int)); +extern void parse_and_execute_cleanup PARAMS((int)); +extern int parse_string PARAMS((char *, const char *, int, char **)); +extern int should_suppress_fork PARAMS((COMMAND *)); +extern int can_optimize_connection PARAMS((COMMAND *)); +extern void optimize_fork PARAMS((COMMAND *)); +extern void optimize_subshell_command PARAMS((COMMAND *)); /* Functions from evalfile.c */ -extern int maybe_execute_file __P((const char *, int)); -extern int force_execute_file __P((const char *, int)); -extern int source_file __P((const char *, int)); -extern int fc_execute_file __P((const char *)); +extern int maybe_execute_file PARAMS((const char *, int)); +extern int force_execute_file PARAMS((const char *, int)); +extern int source_file PARAMS((const char *, int)); +extern int fc_execute_file PARAMS((const char *)); /* variables from common.c */ extern sh_builtin_func_t *this_shell_builtin; extern sh_builtin_func_t *last_shell_builtin; -extern SHELL_VAR *builtin_bind_variable __P((char *, char *, int)); -extern int builtin_unbind_variable __P((const char *)); +extern SHELL_VAR *builtin_bind_variable PARAMS((char *, char *, int)); +extern int builtin_unbind_variable PARAMS((const char *)); /* variables from evalfile.c */ extern int sourcelevel; diff --git a/builtins/getopts.def b/builtins/getopts.def index 06c06248..4c39c474 100644 --- a/builtins/getopts.def +++ b/builtins/getopts.def @@ -86,9 +86,9 @@ $END #define G_INVALID_OPT -2 #define G_ARG_MISSING -3 -static int getopts_unbind_variable __P((char *)); -static int getopts_bind_variable __P((char *, char *)); -static int dogetopts __P((int, char **)); +static int getopts_unbind_variable PARAMS((char *)); +static int getopts_bind_variable PARAMS((char *, char *)); +static int dogetopts PARAMS((int, char **)); /* getopts_reset is magic code for when OPTIND is reset. N is the value that has just been assigned to OPTIND. */ @@ -212,10 +212,7 @@ dogetopts (argc, argv) register WORD_LIST *words; char **v; - for (i = 0; i < 10 && dollar_vars[i]; i++) - ; - for (words = rest_of_args; words; words = words->next, i++) - ; + i = number_of_args () + 1; /* +1 for $0 */ v = strvec_create (i + 1); for (i = 0; i < 10 && dollar_vars[i]; i++) v[i] = dollar_vars[i]; diff --git a/builtins/shift.def b/builtins/shift.def index 589e3299..bb9af01b 100644 --- a/builtins/shift.def +++ b/builtins/shift.def @@ -1,7 +1,7 @@ This file is shift.def, from which is created shift.c. It implements the builtin "shift" in Bash. -Copyright (C) 1987-2009 Free Software Foundation, Inc. +Copyright (C) 1987-2020 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -58,8 +58,7 @@ shift_builtin (list) WORD_LIST *list; { intmax_t times; - register int count; - WORD_LIST *temp; + int itimes, nargs; CHECK_HELPOPT (list); @@ -73,32 +72,17 @@ shift_builtin (list) sh_erange (list ? list->word->word : NULL, _("shift count")); return (EXECUTION_FAILURE); } - else if (times > number_of_args ()) + nargs = number_of_args (); + if (times > nargs) { if (print_shift_error) sh_erange (list ? list->word->word : NULL, _("shift count")); return (EXECUTION_FAILURE); } - - while (times-- > 0) - { - if (dollar_vars[1]) - free (dollar_vars[1]); - - for (count = 1; count < 9; count++) - dollar_vars[count] = dollar_vars[count + 1]; - - if (rest_of_args) - { - temp = rest_of_args; - dollar_vars[9] = savestring (temp->word->word); - rest_of_args = rest_of_args->next; - temp->next = (WORD_LIST *)NULL; - dispose_words (temp); - } - else - dollar_vars[9] = (char *)NULL; - } + else if (times == nargs) + clear_dollar_vars (); + else + shift_args (itimes = times); invalidate_cached_quoted_dollar_at (); diff --git a/builtins/trap.def b/builtins/trap.def index b6bc05be..e3fe54d7 100644 --- a/builtins/trap.def +++ b/builtins/trap.def @@ -133,11 +133,7 @@ trap_builtin (list) { initialize_terminating_signals (); get_all_original_signals (); -#if 0 /* TAG:bash-5.1 */ return (sh_chkwrite (display_traps (list, display && posixly_correct))); -#else - return (sh_chkwrite (display_traps (list, 0))); -#endif } else { diff --git a/doc/bashref.texi b/doc/bashref.texi index 00909ed8..8cfb7759 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -7655,6 +7655,11 @@ When a command in the hash table no longer exists, Bash will re-search @env{$PATH} to find the new location. This is also available with @samp{shopt -s checkhash}. +@item +Bash will not insert a command without the execute bit set into the +command hash table, even if it returns it as a (last-ditch) result +from a @env{$PATH} search. + @item The message printed by the job control code and builtins when a job exits with a non-zero status is `Done(status)'. diff --git a/execute_cmd.c b/execute_cmd.c index e937e6cf..8a011607 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -1576,6 +1576,10 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close) coproc_closeall (); #endif +#if defined (PROCESS_SUBSTITUTION) + clear_fifo_list (); /* XXX- we haven't created any FIFOs */ +#endif + /* If this is a user subshell, set a flag if stdin was redirected. This is used later to decide whether to redirect fd 0 to /dev/null for async commands in the subshell. This adds more @@ -5426,6 +5430,10 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out, subshell_environment |= SUBSHELL_FORK; /* XXX - was just = */ +#if defined (PROCESS_SUBSTITUTION) && !defined (HAVE_DEV_FD) + clear_fifo_list (); /* XXX - we haven't created any FIFOs */ +#endif + if (redirects && (do_redirections (redirects, RX_ACTIVE) != 0)) { #if defined (PROCESS_SUBSTITUTION) @@ -5815,7 +5823,7 @@ shell_execve (command, args, env) unbind_args (); /* remove the positional parameters */ -#if defined (PROCESS_SUBSTITUTION) +#if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD) clear_fifo_list (); /* pipe fds are what they are now */ #endif diff --git a/expr.c b/expr.c index 6c147b79..b323d3ef 100644 --- a/expr.c +++ b/expr.c @@ -1,6 +1,6 @@ /* expr.c -- arithmetic expression evaluation. */ -/* Copyright (C) 1990-2015 Free Software Foundation, Inc. +/* Copyright (C) 1990-2020 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -181,43 +181,43 @@ static int already_expanded; static struct lvalue curlval = {0, 0, 0, -1}; static struct lvalue lastlval = {0, 0, 0, -1}; -static int _is_arithop __P((int)); -static void readtok __P((void)); /* lexical analyzer */ +static int _is_arithop PARAMS((int)); +static void readtok PARAMS((void)); /* lexical analyzer */ -static void init_lvalue __P((struct lvalue *)); -static struct lvalue *alloc_lvalue __P((void)); -static void free_lvalue __P((struct lvalue *)); +static void init_lvalue PARAMS((struct lvalue *)); +static struct lvalue *alloc_lvalue PARAMS((void)); +static void free_lvalue PARAMS((struct lvalue *)); -static intmax_t expr_streval __P((char *, int, struct lvalue *)); -static intmax_t strlong __P((char *)); -static void evalerror __P((const char *)); +static intmax_t expr_streval PARAMS((char *, int, struct lvalue *)); +static intmax_t strlong PARAMS((char *)); +static void evalerror PARAMS((const char *)); -static void pushexp __P((void)); -static void popexp __P((void)); -static void expr_unwind __P((void)); -static void expr_bind_variable __P((char *, char *)); +static void pushexp PARAMS((void)); +static void popexp PARAMS((void)); +static void expr_unwind PARAMS((void)); +static void expr_bind_variable PARAMS((char *, char *)); #if defined (ARRAY_VARS) -static void expr_bind_array_element __P((char *, arrayind_t, char *)); +static void expr_bind_array_element PARAMS((char *, arrayind_t, char *)); #endif -static intmax_t subexpr __P((char *)); +static intmax_t subexpr PARAMS((char *)); -static intmax_t expcomma __P((void)); -static intmax_t expassign __P((void)); -static intmax_t expcond __P((void)); -static intmax_t explor __P((void)); -static intmax_t expland __P((void)); -static intmax_t expbor __P((void)); -static intmax_t expbxor __P((void)); -static intmax_t expband __P((void)); -static intmax_t exp5 __P((void)); -static intmax_t exp4 __P((void)); -static intmax_t expshift __P((void)); -static intmax_t exp3 __P((void)); -static intmax_t expmuldiv __P((void)); -static intmax_t exppower __P((void)); -static intmax_t exp1 __P((void)); -static intmax_t exp0 __P((void)); +static intmax_t expcomma PARAMS((void)); +static intmax_t expassign PARAMS((void)); +static intmax_t expcond PARAMS((void)); +static intmax_t explor PARAMS((void)); +static intmax_t expland PARAMS((void)); +static intmax_t expbor PARAMS((void)); +static intmax_t expbxor PARAMS((void)); +static intmax_t expband PARAMS((void)); +static intmax_t exp5 PARAMS((void)); +static intmax_t exp4 PARAMS((void)); +static intmax_t expshift PARAMS((void)); +static intmax_t exp3 PARAMS((void)); +static intmax_t expmuldiv PARAMS((void)); +static intmax_t exppower PARAMS((void)); +static intmax_t exp1 PARAMS((void)); +static intmax_t exp0 PARAMS((void)); /* Global var which contains the stack of expression contexts. */ static EXPR_CONTEXT **expr_stack; @@ -1573,12 +1573,10 @@ strlong (num) val = 0; foundbase++; -#if 0 /* TAG:bash-5.1 */ /* Make sure a base# is followed by a character that can compose a valid integer constant. Jeremy Townshend */ if (VALID_NUMCHAR (*s) == 0) evalerror (_("invalid integer constant")); -#endif } else if (VALID_NUMCHAR (c)) { diff --git a/findcmd.c b/findcmd.c index 6cc4455e..e5944240 100644 --- a/findcmd.c +++ b/findcmd.c @@ -1,6 +1,6 @@ /* findcmd.c -- Functions to search for commands by name. */ -/* Copyright (C) 1997-2017 Free Software Foundation, Inc. +/* Copyright (C) 1997-2020 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -397,7 +397,6 @@ search_for_command (pathname, flags) if (st & FS_EXECABLE) phash_insert ((char *)pathname, command, dot_found_in_search, 1); } -#if 0 /* TAG:bash-5.1 */ /* If we're in posix mode, don't add files without the execute bit to the hash table. */ else if (posixly_correct) @@ -406,7 +405,6 @@ search_for_command (pathname, flags) if (st & FS_EXECABLE) phash_insert ((char *)pathname, command, dot_found_in_search, 1); } -#endif else phash_insert ((char *)pathname, command, dot_found_in_search, 1); } diff --git a/findcmd.h b/findcmd.h index 34b49149..bf457814 100644 --- a/findcmd.h +++ b/findcmd.h @@ -1,6 +1,6 @@ /* findcmd.h - functions from findcmd.c. */ -/* Copyright (C) 1997-2015 Free Software Foundation, Inc. +/* Copyright (C) 1997-2015,2020 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -28,16 +28,16 @@ #define CMDSRCH_STDPATH 0x02 #define CMDSRCH_TEMPENV 0x04 -extern int file_status __P((const char *)); -extern int executable_file __P((const char *)); -extern int is_directory __P((const char *)); -extern int executable_or_directory __P((const char *)); -extern char *find_user_command __P((const char *)); -extern char *find_in_path __P((const char *, char *, int)); -extern char *find_path_file __P((const char *)); -extern char *search_for_command __P((const char *, int)); -extern char *user_command_matches __P((const char *, int, int)); -extern void setup_exec_ignore __P((char *)); +extern int file_status PARAMS((const char *)); +extern int executable_file PARAMS((const char *)); +extern int is_directory PARAMS((const char *)); +extern int executable_or_directory PARAMS((const char *)); +extern char *find_user_command PARAMS((const char *)); +extern char *find_in_path PARAMS((const char *, char *, int)); +extern char *find_path_file PARAMS((const char *)); +extern char *search_for_command PARAMS((const char *, int)); +extern char *user_command_matches PARAMS((const char *, int, int)); +extern void setup_exec_ignore PARAMS((char *)); extern int dot_found_in_search; diff --git a/parse.y b/parse.y index f80a0348..0892ef14 100644 --- a/parse.y +++ b/parse.y @@ -1314,6 +1314,8 @@ timespec: TIME { $$ = CMD_TIME_PIPELINE; } | TIME TIMEOPT { $$ = CMD_TIME_PIPELINE|CMD_TIME_POSIX; } + | TIME TIMEIGN + { $$ = CMD_TIME_PIPELINE|CMD_TIME_POSIX; } | TIME TIMEOPT TIMEIGN { $$ = CMD_TIME_PIPELINE|CMD_TIME_POSIX; } ; @@ -3052,7 +3054,7 @@ time_command_acceptable () `}' is recognized if there is an unclosed `{' present. `-p' is returned as TIMEOPT if the last read token was TIME. - `--' is returned as TIMEIGN if the last read token was TIMEOPT. + `--' is returned as TIMEIGN if the last read token was TIME or TIMEOPT. ']]' is returned as COND_END if the parser is currently parsing a conditional expression ((parser_state & PST_CONDEXPR) != 0) @@ -3168,6 +3170,9 @@ special_case_tokens (tokstr) /* Handle -p after `time'. */ if (last_read_token == TIME && tokstr[0] == '-' && tokstr[1] == 'p' && !tokstr[2]) return (TIMEOPT); + /* Handle -- after `time'. */ + if (last_read_token == TIME && tokstr[0] == '-' && tokstr[1] == '-' && !tokstr[2]) + return (TIMEIGN); /* Handle -- after `time -p'. */ if (last_read_token == TIMEOPT && tokstr[0] == '-' && tokstr[1] == '-' && !tokstr[2]) return (TIMEIGN); diff --git a/subst.c b/subst.c index 716011a0..539834a2 100644 --- a/subst.c +++ b/subst.c @@ -143,7 +143,7 @@ extern int errno; /* An expansion function that takes a string and a quoted flag and returns a WORD_LIST *. Used as the type of the third argument to expand_string_if_necessary(). */ -typedef WORD_LIST *EXPFUNC __P((char *, int)); +typedef WORD_LIST *EXPFUNC PARAMS((char *, int)); /* Process ID of the last command executed within command substitution. */ pid_t last_command_subst_pid = NO_PID; @@ -195,7 +195,7 @@ extern PROCESS *last_procsub_child; #endif #if !defined (HAVE_WCSDUP) && defined (HANDLE_MULTIBYTE) -extern wchar_t *wcsdup __P((const wchar_t *)); +extern wchar_t *wcsdup PARAMS((const wchar_t *)); #endif #if 0 @@ -226,137 +226,137 @@ static int expand_no_split_dollar_star = 0; without any leading variable assignments. */ static WORD_LIST *garglist = (WORD_LIST *)NULL; -static char *quoted_substring __P((char *, int, int)); -static int quoted_strlen __P((char *)); -static char *quoted_strchr __P((char *, int, int)); +static char *quoted_substring PARAMS((char *, int, int)); +static int quoted_strlen PARAMS((char *)); +static char *quoted_strchr PARAMS((char *, int, int)); -static char *expand_string_if_necessary __P((char *, int, EXPFUNC *)); -static inline char *expand_string_to_string_internal __P((char *, int, EXPFUNC *)); -static WORD_LIST *call_expand_word_internal __P((WORD_DESC *, int, int, int *, int *)); -static WORD_LIST *expand_string_internal __P((char *, int)); -static WORD_LIST *expand_string_leave_quoted __P((char *, int)); -static WORD_LIST *expand_string_for_rhs __P((char *, int, int, int, int *, int *)); -static WORD_LIST *expand_string_for_pat __P((char *, int, int *, int *)); +static char *expand_string_if_necessary PARAMS((char *, int, EXPFUNC *)); +static inline char *expand_string_to_string_internal PARAMS((char *, int, EXPFUNC *)); +static WORD_LIST *call_expand_word_internal PARAMS((WORD_DESC *, int, int, int *, int *)); +static WORD_LIST *expand_string_internal PARAMS((char *, int)); +static WORD_LIST *expand_string_leave_quoted PARAMS((char *, int)); +static WORD_LIST *expand_string_for_rhs PARAMS((char *, int, int, int, int *, int *)); +static WORD_LIST *expand_string_for_pat PARAMS((char *, int, int *, int *)); -static char *quote_escapes_internal __P((const char *, int)); +static char *quote_escapes_internal PARAMS((const char *, int)); -static WORD_LIST *list_quote_escapes __P((WORD_LIST *)); -static WORD_LIST *list_dequote_escapes __P((WORD_LIST *)); +static WORD_LIST *list_quote_escapes PARAMS((WORD_LIST *)); +static WORD_LIST *list_dequote_escapes PARAMS((WORD_LIST *)); -static char *make_quoted_char __P((int)); -static WORD_LIST *quote_list __P((WORD_LIST *)); +static char *make_quoted_char PARAMS((int)); +static WORD_LIST *quote_list PARAMS((WORD_LIST *)); -static int unquoted_substring __P((char *, char *)); -static int unquoted_member __P((int, char *)); +static int unquoted_substring PARAMS((char *, char *)); +static int unquoted_member PARAMS((int, char *)); #if defined (ARRAY_VARS) -static SHELL_VAR *do_compound_assignment __P((char *, char *, int)); +static SHELL_VAR *do_compound_assignment PARAMS((char *, char *, int)); #endif -static int do_assignment_internal __P((const WORD_DESC *, int)); +static int do_assignment_internal PARAMS((const WORD_DESC *, int)); -static char *string_extract_verbatim __P((char *, size_t, int *, char *, int)); -static char *string_extract __P((char *, int *, char *, int)); -static char *string_extract_double_quoted __P((char *, int *, int)); -static inline char *string_extract_single_quoted __P((char *, int *)); -static inline int skip_single_quoted __P((const char *, size_t, int, int)); -static int skip_double_quoted __P((char *, size_t, int, int)); -static char *extract_delimited_string __P((char *, int *, char *, char *, char *, int)); -static char *extract_dollar_brace_string __P((char *, int *, int, int)); -static int skip_matched_pair __P((const char *, int, int, int, int)); +static char *string_extract_verbatim PARAMS((char *, size_t, int *, char *, int)); +static char *string_extract PARAMS((char *, int *, char *, int)); +static char *string_extract_double_quoted PARAMS((char *, int *, int)); +static inline char *string_extract_single_quoted PARAMS((char *, int *)); +static inline int skip_single_quoted PARAMS((const char *, size_t, int, int)); +static int skip_double_quoted PARAMS((char *, size_t, int, int)); +static char *extract_delimited_string PARAMS((char *, int *, char *, char *, char *, int)); +static char *extract_dollar_brace_string PARAMS((char *, int *, int, int)); +static int skip_matched_pair PARAMS((const char *, int, int, int, int)); -static char *pos_params __P((char *, int, int, int, int)); +static char *pos_params PARAMS((char *, int, int, int, int)); -static unsigned char *mb_getcharlens __P((char *, int)); +static unsigned char *mb_getcharlens PARAMS((char *, int)); -static char *remove_upattern __P((char *, char *, int)); +static char *remove_upattern PARAMS((char *, char *, int)); #if defined (HANDLE_MULTIBYTE) -static wchar_t *remove_wpattern __P((wchar_t *, size_t, wchar_t *, int)); +static wchar_t *remove_wpattern PARAMS((wchar_t *, size_t, wchar_t *, int)); #endif -static char *remove_pattern __P((char *, char *, int)); +static char *remove_pattern PARAMS((char *, char *, int)); -static int match_upattern __P((char *, char *, int, char **, char **)); +static int match_upattern PARAMS((char *, char *, int, char **, char **)); #if defined (HANDLE_MULTIBYTE) -static int match_wpattern __P((wchar_t *, char **, size_t, wchar_t *, int, char **, char **)); +static int match_wpattern PARAMS((wchar_t *, char **, size_t, wchar_t *, int, char **, char **)); #endif -static int match_pattern __P((char *, char *, int, char **, char **)); -static int getpatspec __P((int, char *)); -static char *getpattern __P((char *, int, int)); -static char *variable_remove_pattern __P((char *, char *, int, int)); -static char *list_remove_pattern __P((WORD_LIST *, char *, int, int, int)); -static char *parameter_list_remove_pattern __P((int, char *, int, int)); +static int match_pattern PARAMS((char *, char *, int, char **, char **)); +static int getpatspec PARAMS((int, char *)); +static char *getpattern PARAMS((char *, int, int)); +static char *variable_remove_pattern PARAMS((char *, char *, int, int)); +static char *list_remove_pattern PARAMS((WORD_LIST *, char *, int, int, int)); +static char *parameter_list_remove_pattern PARAMS((int, char *, int, int)); #ifdef ARRAY_VARS -static char *array_remove_pattern __P((SHELL_VAR *, char *, int, char *, int)); +static char *array_remove_pattern PARAMS((SHELL_VAR *, char *, int, char *, int)); #endif -static char *parameter_brace_remove_pattern __P((char *, char *, int, char *, int, int, int)); +static char *parameter_brace_remove_pattern PARAMS((char *, char *, int, char *, int, int, int)); -static char *string_var_assignment __P((SHELL_VAR *, char *)); +static char *string_var_assignment PARAMS((SHELL_VAR *, char *)); #if defined (ARRAY_VARS) -static char *array_var_assignment __P((SHELL_VAR *, int, int)); +static char *array_var_assignment PARAMS((SHELL_VAR *, int, int)); #endif -static char *pos_params_assignment __P((WORD_LIST *, int, int)); -static char *string_transform __P((int, SHELL_VAR *, char *)); -static char *list_transform __P((int, SHELL_VAR *, WORD_LIST *, int, int)); -static char *parameter_list_transform __P((int, int, int)); +static char *pos_params_assignment PARAMS((WORD_LIST *, int, int)); +static char *string_transform PARAMS((int, SHELL_VAR *, char *)); +static char *list_transform PARAMS((int, SHELL_VAR *, WORD_LIST *, int, int)); +static char *parameter_list_transform PARAMS((int, int, int)); #if defined ARRAY_VARS -static char *array_transform __P((int, SHELL_VAR *, char *, int)); +static char *array_transform PARAMS((int, SHELL_VAR *, char *, int)); #endif -static char *parameter_brace_transform __P((char *, char *, int, char *, int, int, int, int)); +static char *parameter_brace_transform PARAMS((char *, char *, int, char *, int, int, int, int)); -static char *process_substitute __P((char *, int)); +static char *process_substitute PARAMS((char *, int)); -static char *read_comsub __P((int, int, int, int *)); +static char *read_comsub PARAMS((int, int, int, int *)); #ifdef ARRAY_VARS -static arrayind_t array_length_reference __P((char *)); +static arrayind_t array_length_reference PARAMS((char *)); #endif -static int valid_brace_expansion_word __P((char *, int)); -static int chk_atstar __P((char *, int, int, int *, int *)); -static int chk_arithsub __P((const char *, int)); +static int valid_brace_expansion_word PARAMS((char *, int)); +static int chk_atstar PARAMS((char *, int, int, int *, int *)); +static int chk_arithsub PARAMS((const char *, int)); -static WORD_DESC *parameter_brace_expand_word __P((char *, int, int, int, arrayind_t *)); -static char *parameter_brace_find_indir __P((char *, int, int, int)); -static WORD_DESC *parameter_brace_expand_indir __P((char *, int, int, int, int *, int *)); -static WORD_DESC *parameter_brace_expand_rhs __P((char *, char *, int, int, int, int *, int *)); -static void parameter_brace_expand_error __P((char *, char *, int)); +static WORD_DESC *parameter_brace_expand_word PARAMS((char *, int, int, int, arrayind_t *)); +static char *parameter_brace_find_indir PARAMS((char *, int, int, int)); +static WORD_DESC *parameter_brace_expand_indir PARAMS((char *, int, int, int, int *, int *)); +static WORD_DESC *parameter_brace_expand_rhs PARAMS((char *, char *, int, int, int, int *, int *)); +static void parameter_brace_expand_error PARAMS((char *, char *, int)); -static int valid_length_expression __P((char *)); -static intmax_t parameter_brace_expand_length __P((char *)); +static int valid_length_expression PARAMS((char *)); +static intmax_t parameter_brace_expand_length PARAMS((char *)); -static char *skiparith __P((char *, int)); -static int verify_substring_values __P((SHELL_VAR *, char *, char *, int, intmax_t *, intmax_t *)); -static int get_var_and_type __P((char *, char *, arrayind_t, int, int, SHELL_VAR **, char **)); -static char *mb_substring __P((char *, int, int)); -static char *parameter_brace_substring __P((char *, char *, int, char *, int, int, int)); +static char *skiparith PARAMS((char *, int)); +static int verify_substring_values PARAMS((SHELL_VAR *, char *, char *, int, intmax_t *, intmax_t *)); +static int get_var_and_type PARAMS((char *, char *, arrayind_t, int, int, SHELL_VAR **, char **)); +static char *mb_substring PARAMS((char *, int, int)); +static char *parameter_brace_substring PARAMS((char *, char *, int, char *, int, int, int)); -static int shouldexp_replacement __P((char *)); +static int shouldexp_replacement PARAMS((char *)); -static char *pos_params_pat_subst __P((char *, char *, char *, int)); +static char *pos_params_pat_subst PARAMS((char *, char *, char *, int)); -static char *parameter_brace_patsub __P((char *, char *, int, char *, int, int, int)); +static char *parameter_brace_patsub PARAMS((char *, char *, int, char *, int, int, int)); -static char *pos_params_casemod __P((char *, char *, int, int)); -static char *parameter_brace_casemod __P((char *, char *, int, int, char *, int, int, int)); +static char *pos_params_casemod PARAMS((char *, char *, int, int)); +static char *parameter_brace_casemod PARAMS((char *, char *, int, int, char *, int, int, int)); -static WORD_DESC *parameter_brace_expand __P((char *, int *, int, int, int *, int *)); -static WORD_DESC *param_expand __P((char *, int *, int, int *, int *, int *, int *, int)); +static WORD_DESC *parameter_brace_expand PARAMS((char *, int *, int, int, int *, int *)); +static WORD_DESC *param_expand PARAMS((char *, int *, int, int *, int *, int *, int *, int)); -static WORD_LIST *expand_word_internal __P((WORD_DESC *, int, int, int *, int *)); +static WORD_LIST *expand_word_internal PARAMS((WORD_DESC *, int, int, int *, int *)); -static WORD_LIST *word_list_split __P((WORD_LIST *)); +static WORD_LIST *word_list_split PARAMS((WORD_LIST *)); -static void exp_jump_to_top_level __P((int)); +static void exp_jump_to_top_level PARAMS((int)); -static WORD_LIST *separate_out_assignments __P((WORD_LIST *)); -static WORD_LIST *glob_expand_word_list __P((WORD_LIST *, int)); +static WORD_LIST *separate_out_assignments PARAMS((WORD_LIST *)); +static WORD_LIST *glob_expand_word_list PARAMS((WORD_LIST *, int)); #ifdef BRACE_EXPANSION -static WORD_LIST *brace_expand_word_list __P((WORD_LIST *, int)); +static WORD_LIST *brace_expand_word_list PARAMS((WORD_LIST *, int)); #endif #if defined (ARRAY_VARS) -static int make_internal_declare __P((char *, char *, char *)); +static int make_internal_declare PARAMS((char *, char *, char *)); #endif -static WORD_LIST *shell_expand_word_list __P((WORD_LIST *, int)); -static WORD_LIST *expand_word_list_internal __P((WORD_LIST *, int)); +static WORD_LIST *shell_expand_word_list PARAMS((WORD_LIST *, int)); +static WORD_LIST *expand_word_list_internal PARAMS((WORD_LIST *, int)); /* **************************************************************** */ /* */ @@ -3372,19 +3372,6 @@ list_rest_of_args () return (REVERSE_LIST (list, WORD_LIST *)); } -int -number_of_args () -{ - register WORD_LIST *list; - int n; - - for (n = 0; n < 9 && dollar_vars[n+1]; n++) - ; - for (list = rest_of_args; list; list = list->next) - n++; - return n; -} - /* Return the value of a positional parameter. This handles values > 10. */ char * get_dollar_var_value (ind) @@ -5361,7 +5348,7 @@ parameter_brace_remove_pattern (varname, value, ind, patstr, rtype, quoted, flag #if defined (PROCESS_SUBSTITUTION) -static void reap_some_procsubs __P((int)); +static void reap_some_procsubs PARAMS((int)); /*****************************************************************/ /* */ @@ -5390,6 +5377,16 @@ static int fifo_list_size; void clear_fifo_list () { + int i; + + for (i = 0; i < fifo_list_size; i++) + { + if (fifo_list[i].file) + free (fifo_list[i].file); + fifo_list[i].file = NULL; + fifo_list[i].proc = 0; + } + nfifo = 0; } char * diff --git a/subst.h b/subst.h index d607f203..7a18b18d 100644 --- a/subst.h +++ b/subst.h @@ -71,230 +71,228 @@ /* Remove backslashes which are quoting backquotes from STRING. Modifies STRING, and returns a pointer to it. */ -extern char * de_backslash __P((char *)); +extern char * de_backslash PARAMS((char *)); /* Replace instances of \! in a string with !. */ -extern void unquote_bang __P((char *)); +extern void unquote_bang PARAMS((char *)); /* Extract the $( construct in STRING, and return a new string. Start extracting at (SINDEX) as if we had just seen "$(". Make (SINDEX) get the position just after the matching ")". XFLAGS is additional flags to pass to other extraction functions, */ -extern char *extract_command_subst __P((char *, int *, int)); +extern char *extract_command_subst PARAMS((char *, int *, int)); /* Extract the $[ construct in STRING, and return a new string. Start extracting at (SINDEX) as if we had just seen "$[". Make (SINDEX) get the position just after the matching "]". */ -extern char *extract_arithmetic_subst __P((char *, int *)); +extern char *extract_arithmetic_subst PARAMS((char *, int *)); #if defined (PROCESS_SUBSTITUTION) /* Extract the <( or >( construct in STRING, and return a new string. Start extracting at (SINDEX) as if we had just seen "<(". Make (SINDEX) get the position just after the matching ")". */ -extern char *extract_process_subst __P((char *, char *, int *, int)); +extern char *extract_process_subst PARAMS((char *, char *, int *, int)); #endif /* PROCESS_SUBSTITUTION */ /* Extract the name of the variable to bind to from the assignment string. */ -extern char *assignment_name __P((char *)); +extern char *assignment_name PARAMS((char *)); /* Return a single string of all the words present in LIST, separating each word with SEP. */ -extern char *string_list_internal __P((WORD_LIST *, char *)); +extern char *string_list_internal PARAMS((WORD_LIST *, char *)); /* Return a single string of all the words present in LIST, separating each word with a space. */ -extern char *string_list __P((WORD_LIST *)); +extern char *string_list PARAMS((WORD_LIST *)); /* Turn $* into a single string, obeying POSIX rules. */ -extern char *string_list_dollar_star __P((WORD_LIST *, int, int)); +extern char *string_list_dollar_star PARAMS((WORD_LIST *, int, int)); /* Expand $@ into a single string, obeying POSIX rules. */ -extern char *string_list_dollar_at __P((WORD_LIST *, int, int)); +extern char *string_list_dollar_at PARAMS((WORD_LIST *, int, int)); /* Turn the positional parameters into a string, understanding quoting and the various subtleties of using the first character of $IFS as the separator. Calls string_list_dollar_at, string_list_dollar_star, and string_list as appropriate. */ -extern char *string_list_pos_params __P((int, WORD_LIST *, int, int)); +extern char *string_list_pos_params PARAMS((int, WORD_LIST *, int, int)); /* Perform quoted null character removal on each element of LIST. This modifies LIST. */ -extern void word_list_remove_quoted_nulls __P((WORD_LIST *)); +extern void word_list_remove_quoted_nulls PARAMS((WORD_LIST *)); /* This performs word splitting and quoted null character removal on STRING. */ -extern WORD_LIST *list_string __P((char *, char *, int)); +extern WORD_LIST *list_string PARAMS((char *, char *, int)); -extern char *ifs_firstchar __P((int *)); -extern char *get_word_from_string __P((char **, char *, char **)); -extern char *strip_trailing_ifs_whitespace __P((char *, char *, int)); +extern char *ifs_firstchar PARAMS((int *)); +extern char *get_word_from_string PARAMS((char **, char *, char **)); +extern char *strip_trailing_ifs_whitespace PARAMS((char *, char *, int)); /* Given STRING, an assignment string, get the value of the right side of the `=', and bind it to the left side. If EXPAND is true, then perform tilde expansion, parameter expansion, command substitution, and arithmetic expansion on the right-hand side. Do not perform word splitting on the result of expansion. */ -extern int do_assignment __P((char *)); -extern int do_assignment_no_expand __P((char *)); -extern int do_word_assignment __P((WORD_DESC *, int)); +extern int do_assignment PARAMS((char *)); +extern int do_assignment_no_expand PARAMS((char *)); +extern int do_word_assignment PARAMS((WORD_DESC *, int)); /* Append SOURCE to TARGET at INDEX. SIZE is the current amount of space allocated to TARGET. SOURCE can be NULL, in which case nothing happens. Gets rid of SOURCE by free ()ing it. Returns TARGET in case the location has changed. */ -extern char *sub_append_string __P((char *, char *, int *, size_t *)); +extern char *sub_append_string PARAMS((char *, char *, int *, size_t *)); /* Append the textual representation of NUMBER to TARGET. INDEX and SIZE are as in SUB_APPEND_STRING. */ -extern char *sub_append_number __P((intmax_t, char *, int *, int *)); +extern char *sub_append_number PARAMS((intmax_t, char *, int *, int *)); /* Return the word list that corresponds to `$*'. */ -extern WORD_LIST *list_rest_of_args __P((void)); +extern WORD_LIST *list_rest_of_args PARAMS((void)); /* Make a single large string out of the dollar digit variables, and the rest_of_args. If DOLLAR_STAR is 1, then obey the special case of "$*" with respect to IFS. */ -extern char *string_rest_of_args __P((int)); - -extern int number_of_args __P((void)); +extern char *string_rest_of_args PARAMS((int)); /* Expand STRING by performing parameter expansion, command substitution, and arithmetic expansion. Dequote the resulting WORD_LIST before returning it, but do not perform word splitting. The call to remove_quoted_nulls () is made here because word splitting normally takes care of quote removal. */ -extern WORD_LIST *expand_string_unsplit __P((char *, int)); +extern WORD_LIST *expand_string_unsplit PARAMS((char *, int)); /* Expand the rhs of an assignment statement. */ -extern WORD_LIST *expand_string_assignment __P((char *, int)); +extern WORD_LIST *expand_string_assignment PARAMS((char *, int)); /* Expand a prompt string. */ -extern WORD_LIST *expand_prompt_string __P((char *, int, int)); +extern WORD_LIST *expand_prompt_string PARAMS((char *, int, int)); /* Expand STRING just as if you were expanding a word. This also returns a list of words. Note that filename globbing is *NOT* done for word or string expansion, just when the shell is expanding a command. This does parameter expansion, command substitution, arithmetic expansion, and word splitting. Dequote the resultant WORD_LIST before returning. */ -extern WORD_LIST *expand_string __P((char *, int)); +extern WORD_LIST *expand_string PARAMS((char *, int)); /* Convenience functions that expand strings to strings, taking care of converting the WORD_LIST * returned by the expand_string* functions to a string and deallocating the WORD_LIST *. */ -extern char *expand_string_to_string __P((char *, int)); -extern char *expand_string_unsplit_to_string __P((char *, int)); -extern char *expand_assignment_string_to_string __P((char *, int)); +extern char *expand_string_to_string PARAMS((char *, int)); +extern char *expand_string_unsplit_to_string PARAMS((char *, int)); +extern char *expand_assignment_string_to_string PARAMS((char *, int)); /* Expand an arithmetic expression string */ -extern char *expand_arith_string __P((char *, int)); +extern char *expand_arith_string PARAMS((char *, int)); /* De-quote quoted characters in STRING. */ -extern char *dequote_string __P((char *)); +extern char *dequote_string PARAMS((char *)); /* De-quote CTLESC-escaped CTLESC or CTLNUL characters in STRING. */ -extern char *dequote_escapes __P((const char *)); +extern char *dequote_escapes PARAMS((const char *)); -extern WORD_DESC *dequote_word __P((WORD_DESC *)); +extern WORD_DESC *dequote_word PARAMS((WORD_DESC *)); /* De-quote quoted characters in each word in LIST. */ -extern WORD_LIST *dequote_list __P((WORD_LIST *)); +extern WORD_LIST *dequote_list PARAMS((WORD_LIST *)); /* Expand WORD, performing word splitting on the result. This does parameter expansion, command substitution, arithmetic expansion, word splitting, and quote removal. */ -extern WORD_LIST *expand_word __P((WORD_DESC *, int)); +extern WORD_LIST *expand_word PARAMS((WORD_DESC *, int)); /* Expand WORD, but do not perform word splitting on the result. This does parameter expansion, command substitution, arithmetic expansion, and quote removal. */ -extern WORD_LIST *expand_word_unsplit __P((WORD_DESC *, int)); -extern WORD_LIST *expand_word_leave_quoted __P((WORD_DESC *, int)); +extern WORD_LIST *expand_word_unsplit PARAMS((WORD_DESC *, int)); +extern WORD_LIST *expand_word_leave_quoted PARAMS((WORD_DESC *, int)); /* Return the value of a positional parameter. This handles values > 10. */ -extern char *get_dollar_var_value __P((intmax_t)); +extern char *get_dollar_var_value PARAMS((intmax_t)); /* Quote a string to protect it from word splitting. */ -extern char *quote_string __P((char *)); +extern char *quote_string PARAMS((char *)); /* Quote escape characters (characters special to internals of expansion) in a string. */ -extern char *quote_escapes __P((const char *)); +extern char *quote_escapes PARAMS((const char *)); /* And remove such quoted special characters. */ -extern char *remove_quoted_escapes __P((char *)); +extern char *remove_quoted_escapes PARAMS((char *)); /* Remove CTLNUL characters from STRING unless they are quoted with CTLESC. */ -extern char *remove_quoted_nulls __P((char *)); +extern char *remove_quoted_nulls PARAMS((char *)); /* Perform quote removal on STRING. If QUOTED > 0, assume we are obeying the backslash quoting rules for within double quotes. */ -extern char *string_quote_removal __P((char *, int)); +extern char *string_quote_removal PARAMS((char *, int)); /* Perform quote removal on word WORD. This allocates and returns a new WORD_DESC *. */ -extern WORD_DESC *word_quote_removal __P((WORD_DESC *, int)); +extern WORD_DESC *word_quote_removal PARAMS((WORD_DESC *, int)); /* Perform quote removal on all words in LIST. If QUOTED is non-zero, the members of the list are treated as if they are surrounded by double quotes. Return a new list, or NULL if LIST is NULL. */ -extern WORD_LIST *word_list_quote_removal __P((WORD_LIST *, int)); +extern WORD_LIST *word_list_quote_removal PARAMS((WORD_LIST *, int)); /* Called when IFS is changed to maintain some private variables. */ -extern void setifs __P((SHELL_VAR *)); +extern void setifs PARAMS((SHELL_VAR *)); /* Return the value of $IFS, or " \t\n" if IFS is unset. */ -extern char *getifs __P((void)); +extern char *getifs PARAMS((void)); /* This splits a single word into a WORD LIST on $IFS, but only if the word is not quoted. list_string () performs quote removal for us, even if we don't do any splitting. */ -extern WORD_LIST *word_split __P((WORD_DESC *, char *)); +extern WORD_LIST *word_split PARAMS((WORD_DESC *, char *)); /* Take the list of words in LIST and do the various substitutions. Return a new list of words which is the expanded list, and without things like variable assignments. */ -extern WORD_LIST *expand_words __P((WORD_LIST *)); +extern WORD_LIST *expand_words PARAMS((WORD_LIST *)); /* Same as expand_words (), but doesn't hack variable or environment variables. */ -extern WORD_LIST *expand_words_no_vars __P((WORD_LIST *)); +extern WORD_LIST *expand_words_no_vars PARAMS((WORD_LIST *)); /* Perform the `normal shell expansions' on a WORD_LIST. These are brace expansion, tilde expansion, parameter and variable substitution, command substitution, arithmetic expansion, and word splitting. */ -extern WORD_LIST *expand_words_shellexp __P((WORD_LIST *)); +extern WORD_LIST *expand_words_shellexp PARAMS((WORD_LIST *)); -extern WORD_DESC *command_substitute __P((char *, int, int)); -extern char *pat_subst __P((char *, char *, char *, int)); +extern WORD_DESC *command_substitute PARAMS((char *, int, int)); +extern char *pat_subst PARAMS((char *, char *, char *, int)); #if defined (PROCESS_SUBSTITUTION) -extern int fifos_pending __P((void)); -extern int num_fifos __P((void)); -extern void unlink_fifo_list __P((void)); -extern void unlink_fifo __P((int)); +extern int fifos_pending PARAMS((void)); +extern int num_fifos PARAMS((void)); +extern void unlink_fifo_list PARAMS((void)); +extern void unlink_fifo PARAMS((int)); -extern char *copy_fifo_list __P((int *)); -extern void unlink_new_fifos __P((char *, int)); -extern void close_new_fifos __P((char *, int)); +extern char *copy_fifo_list PARAMS((int *)); +extern void unlink_new_fifos PARAMS((char *, int)); +extern void close_new_fifos PARAMS((char *, int)); -extern void clear_fifo_list __P((void)); +extern void clear_fifo_list PARAMS((void)); -extern int find_procsub_child __P((pid_t)); -extern void set_procsub_status __P((int, pid_t, int)); +extern int find_procsub_child PARAMS((pid_t)); +extern void set_procsub_status PARAMS((int, pid_t, int)); -extern void wait_procsubs __P((void)); -extern void reap_procsubs __P((void)); +extern void wait_procsubs PARAMS((void)); +extern void reap_procsubs PARAMS((void)); #endif -extern WORD_LIST *list_string_with_quotes __P((char *)); +extern WORD_LIST *list_string_with_quotes PARAMS((char *)); #if defined (ARRAY_VARS) -extern char *extract_array_assignment_list __P((char *, int *)); +extern char *extract_array_assignment_list PARAMS((char *, int *)); #endif #if defined (COND_COMMAND) -extern char *remove_backslashes __P((char *)); -extern char *cond_expand_word __P((WORD_DESC *, int)); +extern char *remove_backslashes PARAMS((char *)); +extern char *cond_expand_word PARAMS((WORD_DESC *, int)); #endif /* Flags for skip_to_delim */ @@ -310,16 +308,16 @@ extern char *cond_expand_word __P((WORD_DESC *, int)); #define SD_HISTEXP 0x200 /* skip_to_delim during history expansion */ #define SD_ARITHEXP 0x400 /* skip_to_delim during arithmetic expansion */ -extern int skip_to_delim __P((char *, int, char *, int)); +extern int skip_to_delim PARAMS((char *, int, char *, int)); #if defined (BANG_HISTORY) -extern int skip_to_histexp __P((char *, int, char *, int)); +extern int skip_to_histexp PARAMS((char *, int, char *, int)); #endif #if defined (READLINE) -extern int char_is_quoted __P((char *, int)); -extern int unclosed_pair __P((char *, int, char *)); -extern WORD_LIST *split_at_delims __P((char *, int, char *, int, int, int *, int *)); +extern int char_is_quoted PARAMS((char *, int)); +extern int unclosed_pair PARAMS((char *, int, char *)); +extern WORD_LIST *split_at_delims PARAMS((char *, int, char *, int, int, int *, int *)); #endif /* Variables used to keep track of the characters in IFS. */ @@ -350,6 +348,6 @@ extern pid_t last_command_subst_pid; /* Is the first character of STRING a quoted NULL character? */ #define QUOTED_NULL(string) ((string)[0] == CTLNUL && (string)[1] == '\0') -extern void invalidate_cached_quoted_dollar_at __P((void)); +extern void invalidate_cached_quoted_dollar_at PARAMS((void)); #endif /* !_SUBST_H_ */ diff --git a/test.c b/test.c index a0b143b7..6cf356d5 100644 --- a/test.c +++ b/test.c @@ -2,7 +2,7 @@ /* Modified to run with the GNU shell Apr 25, 1988 by bfox. */ -/* Copyright (C) 1987-2010 Free Software Foundation, Inc. +/* Copyright (C) 1987-2020 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -103,31 +103,31 @@ static int test_error_return; #define test_exit(val) \ do { test_error_return = val; sh_longjmp (test_exit_buf, 1); } while (0) -extern int sh_stat __P((const char *, struct stat *)); +extern int sh_stat PARAMS((const char *, struct stat *)); static int pos; /* The offset of the current argument in ARGV. */ static int argc; /* The number of arguments present in ARGV. */ static char **argv; /* The argument list. */ static int noeval; -static void test_syntax_error __P((char *, char *)) __attribute__((__noreturn__)); -static void beyond __P((void)) __attribute__((__noreturn__)); -static void integer_expected_error __P((char *)) __attribute__((__noreturn__)); +static void test_syntax_error PARAMS((char *, char *)) __attribute__((__noreturn__)); +static void beyond PARAMS((void)) __attribute__((__noreturn__)); +static void integer_expected_error PARAMS((char *)) __attribute__((__noreturn__)); -static int unary_operator __P((void)); -static int binary_operator __P((void)); -static int two_arguments __P((void)); -static int three_arguments __P((void)); -static int posixtest __P((void)); +static int unary_operator PARAMS((void)); +static int binary_operator PARAMS((void)); +static int two_arguments PARAMS((void)); +static int three_arguments PARAMS((void)); +static int posixtest PARAMS((void)); -static int expr __P((void)); -static int term __P((void)); -static int and __P((void)); -static int or __P((void)); +static int expr PARAMS((void)); +static int term PARAMS((void)); +static int and PARAMS((void)); +static int or PARAMS((void)); -static int filecomp __P((char *, char *, int)); -static int arithcomp __P((char *, char *, int, int)); -static int patcomp __P((char *, char *, int)); +static int filecomp PARAMS((char *, char *, int)); +static int arithcomp PARAMS((char *, char *, int, int)); +static int patcomp PARAMS((char *, char *, int)); static void test_syntax_error (format, arg) @@ -637,10 +637,8 @@ unary_test (op, arg) free (t); return ret; } -#if 0 /* TAG:bash-5.1 from Martijn Dekker */ else if (legal_number (arg, &r)) /* -v n == is $n set? */ return ((r >= 0 && r <= number_of_args()) ? TRUE : FALSE); -#endif v = find_variable (arg); if (v && invisible_p (v) == 0 && array_p (v)) { diff --git a/tests/RUN-ONE-TEST b/tests/RUN-ONE-TEST index 0b063810..a3a5e471 100755 --- a/tests/RUN-ONE-TEST +++ b/tests/RUN-ONE-TEST @@ -1,4 +1,5 @@ -BUILD_DIR=/usr/local/build/chet/bash/bash-current +BUILD_DIR=/usr/local/build/bash/bash-current +#BUILD_DIR=/fs2/chet/scratch/bash-20200214.fifo THIS_SH=$BUILD_DIR/bash PATH=$PATH:$BUILD_DIR diff --git a/tests/arith.right b/tests/arith.right index 38941e1e..c74602e3 100644 --- a/tests/arith.right +++ b/tests/arith.right @@ -81,7 +81,7 @@ 62 63 ./arith.tests: line 162: 3425#56: invalid arithmetic base (error token is "3425#56") -0 +./arith.tests: line 165: 2#: invalid integer constant (error token is "2#") ./arith.tests: line 168: 7 = 43 : attempted assignment to non-variable (error token is "= 43 ") ./arith.tests: line 169: 2#44: value too great for base (error token is "2#44") ./arith.tests: line 170: 44 / 0 : division by 0 (error token is "0 ") diff --git a/tests/arith.tests b/tests/arith.tests index 606de39d..1a3501aa 100644 --- a/tests/arith.tests +++ b/tests/arith.tests @@ -161,7 +161,7 @@ echo $(( 64#_ )) # weird bases echo $(( 3425#56 )) -# missing number after base +# missing number after base now generates an error echo $(( 2# )) # these should generate errors diff --git a/tests/procsub.tests b/tests/procsub.tests index 136ab98f..1d65f000 100644 --- a/tests/procsub.tests +++ b/tests/procsub.tests @@ -83,10 +83,10 @@ count_lines() { wc -l < $1 -# case "$1" in -# *sh-np*) [ -e "$1" ] || { echo 0; echo 0; echo 0; echo 0; return; } ;; -# *) ;; -# esac + case "$1" in + *sh-np*) [ -e "$1" ] || { echo 0; echo 0; echo 0; echo 0; return; } ;; + *) ;; + esac wc -l < $1 wc -l < $1 diff --git a/trap.h b/trap.h index 91cec2d8..e8c93dd4 100644 --- a/trap.h +++ b/trap.h @@ -66,58 +66,58 @@ extern int running_trap; extern int trap_saved_exit_value; /* Externally-visible functions declared in trap.c. */ -extern void initialize_traps __P((void)); +extern void initialize_traps PARAMS((void)); -extern void run_pending_traps __P((void)); +extern void run_pending_traps PARAMS((void)); -extern void queue_sigchld_trap __P((int)); -extern void maybe_set_sigchld_trap __P((char *)); -extern void set_impossible_sigchld_trap __P((void)); -extern void set_sigchld_trap __P((char *)); +extern void queue_sigchld_trap PARAMS((int)); +extern void maybe_set_sigchld_trap PARAMS((char *)); +extern void set_impossible_sigchld_trap PARAMS((void)); +extern void set_sigchld_trap PARAMS((char *)); -extern void set_debug_trap __P((char *)); -extern void set_error_trap __P((char *)); -extern void set_return_trap __P((char *)); +extern void set_debug_trap PARAMS((char *)); +extern void set_error_trap PARAMS((char *)); +extern void set_return_trap PARAMS((char *)); -extern void maybe_set_debug_trap __P((char *)); -extern void maybe_set_error_trap __P((char *)); -extern void maybe_set_return_trap __P((char *)); +extern void maybe_set_debug_trap PARAMS((char *)); +extern void maybe_set_error_trap PARAMS((char *)); +extern void maybe_set_return_trap PARAMS((char *)); -extern void set_sigint_trap __P((char *)); -extern void set_signal __P((int, char *)); +extern void set_sigint_trap PARAMS((char *)); +extern void set_signal PARAMS((int, char *)); -extern void restore_default_signal __P((int)); -extern void ignore_signal __P((int)); -extern int run_exit_trap __P((void)); -extern void run_trap_cleanup __P((int)); -extern int run_debug_trap __P((void)); -extern void run_error_trap __P((void)); -extern void run_return_trap __P((void)); +extern void restore_default_signal PARAMS((int)); +extern void ignore_signal PARAMS((int)); +extern int run_exit_trap PARAMS((void)); +extern void run_trap_cleanup PARAMS((int)); +extern int run_debug_trap PARAMS((void)); +extern void run_error_trap PARAMS((void)); +extern void run_return_trap PARAMS((void)); -extern void free_trap_strings __P((void)); -extern void reset_signal_handlers __P((void)); -extern void restore_original_signals __P((void)); +extern void free_trap_strings PARAMS((void)); +extern void reset_signal_handlers PARAMS((void)); +extern void restore_original_signals PARAMS((void)); -extern void get_original_signal __P((int)); -extern void get_all_original_signals __P((void)); +extern void get_original_signal PARAMS((int)); +extern void get_all_original_signals PARAMS((void)); -extern char *signal_name __P((int)); +extern char *signal_name PARAMS((int)); -extern int decode_signal __P((char *, int)); -extern void run_interrupt_trap __P((int)); -extern int maybe_call_trap_handler __P((int)); -extern int signal_is_special __P((int)); -extern int signal_is_trapped __P((int)); -extern int signal_is_pending __P((int)); -extern int signal_is_ignored __P((int)); -extern int signal_is_hard_ignored __P((int)); -extern void set_signal_hard_ignored __P((int)); -extern void set_signal_ignored __P((int)); -extern int signal_in_progress __P((int)); +extern int decode_signal PARAMS((char *, int)); +extern void run_interrupt_trap PARAMS((int)); +extern int maybe_call_trap_handler PARAMS((int)); +extern int signal_is_special PARAMS((int)); +extern int signal_is_trapped PARAMS((int)); +extern int signal_is_pending PARAMS((int)); +extern int signal_is_ignored PARAMS((int)); +extern int signal_is_hard_ignored PARAMS((int)); +extern void set_signal_hard_ignored PARAMS((int)); +extern void set_signal_ignored PARAMS((int)); +extern int signal_in_progress PARAMS((int)); -extern int first_pending_trap __P((void)); -extern int any_signals_trapped __P((void)); -extern void check_signals __P((void)); -extern void check_signals_and_traps __P((void)); +extern int first_pending_trap PARAMS((void)); +extern int any_signals_trapped PARAMS((void)); +extern void check_signals PARAMS((void)); +extern void check_signals_and_traps PARAMS((void)); #endif /* _TRAP_H_ */ diff --git a/variables.c b/variables.c index f2b15c89..01282d28 100644 --- a/variables.c +++ b/variables.c @@ -144,6 +144,7 @@ int tempenv_assign_error; "$*", "$1", and all the cruft is kept. */ char *dollar_vars[10]; WORD_LIST *rest_of_args = (WORD_LIST *)NULL; +int posparam_count = 0; /* The value of $$. */ pid_t dollar_dollar_pid; @@ -173,161 +174,161 @@ static HASH_TABLE *last_table_searched; /* hash_lookup sets this */ static VAR_CONTEXT *last_context_searched; /* Some forward declarations. */ -static void create_variable_tables __P((void)); +static void create_variable_tables PARAMS((void)); -static void set_machine_vars __P((void)); -static void set_home_var __P((void)); -static void set_shell_var __P((void)); -static char *get_bash_name __P((void)); -static void initialize_shell_level __P((void)); -static void uidset __P((void)); +static void set_machine_vars PARAMS((void)); +static void set_home_var PARAMS((void)); +static void set_shell_var PARAMS((void)); +static char *get_bash_name PARAMS((void)); +static void initialize_shell_level PARAMS((void)); +static void uidset PARAMS((void)); #if defined (ARRAY_VARS) -static void make_vers_array __P((void)); +static void make_vers_array PARAMS((void)); #endif -static SHELL_VAR *null_assign __P((SHELL_VAR *, char *, arrayind_t, char *)); +static SHELL_VAR *null_assign PARAMS((SHELL_VAR *, char *, arrayind_t, char *)); #if defined (ARRAY_VARS) -static SHELL_VAR *null_array_assign __P((SHELL_VAR *, char *, arrayind_t, char *)); +static SHELL_VAR *null_array_assign PARAMS((SHELL_VAR *, char *, arrayind_t, char *)); #endif -static SHELL_VAR *get_self __P((SHELL_VAR *)); +static SHELL_VAR *get_self PARAMS((SHELL_VAR *)); #if defined (ARRAY_VARS) -static SHELL_VAR *init_dynamic_array_var __P((char *, sh_var_value_func_t *, sh_var_assign_func_t *, int)); -static SHELL_VAR *init_dynamic_assoc_var __P((char *, sh_var_value_func_t *, sh_var_assign_func_t *, int)); +static SHELL_VAR *init_dynamic_array_var PARAMS((char *, sh_var_value_func_t *, sh_var_assign_func_t *, int)); +static SHELL_VAR *init_dynamic_assoc_var PARAMS((char *, sh_var_value_func_t *, sh_var_assign_func_t *, int)); #endif -static SHELL_VAR *assign_seconds __P((SHELL_VAR *, char *, arrayind_t, char *)); -static SHELL_VAR *get_seconds __P((SHELL_VAR *)); -static SHELL_VAR *init_seconds_var __P((void)); +static SHELL_VAR *assign_seconds PARAMS((SHELL_VAR *, char *, arrayind_t, char *)); +static SHELL_VAR *get_seconds PARAMS((SHELL_VAR *)); +static SHELL_VAR *init_seconds_var PARAMS((void)); -static u_bits32_t intrand32 __P((u_bits32_t)); -static u_bits32_t genseed __P((void)); +static u_bits32_t intrand32 PARAMS((u_bits32_t)); +static u_bits32_t genseed PARAMS((void)); -static int brand __P((void)); -static void sbrand __P((unsigned long)); /* set bash random number generator. */ -static void seedrand __P((void)); /* seed generator randomly */ +static int brand PARAMS((void)); +static void sbrand PARAMS((unsigned long)); /* set bash random number generator. */ +static void seedrand PARAMS((void)); /* seed generator randomly */ -static u_bits32_t brand32 __P((void)); -static void sbrand32 __P((u_bits32_t)); -static void seedrand32 __P((void)); -static void perturb_rand32 __P((void)); -static u_bits32_t get_urandom32 __P((void)); +static u_bits32_t brand32 PARAMS((void)); +static void sbrand32 PARAMS((u_bits32_t)); +static void seedrand32 PARAMS((void)); +static void perturb_rand32 PARAMS((void)); +static u_bits32_t get_urandom32 PARAMS((void)); -static SHELL_VAR *assign_random __P((SHELL_VAR *, char *, arrayind_t, char *)); -static SHELL_VAR *get_random __P((SHELL_VAR *)); +static SHELL_VAR *assign_random PARAMS((SHELL_VAR *, char *, arrayind_t, char *)); +static SHELL_VAR *get_random PARAMS((SHELL_VAR *)); -static SHELL_VAR *get_urandom __P((SHELL_VAR *)); +static SHELL_VAR *get_urandom PARAMS((SHELL_VAR *)); -static SHELL_VAR *assign_lineno __P((SHELL_VAR *, char *, arrayind_t, char *)); -static SHELL_VAR *get_lineno __P((SHELL_VAR *)); +static SHELL_VAR *assign_lineno PARAMS((SHELL_VAR *, char *, arrayind_t, char *)); +static SHELL_VAR *get_lineno PARAMS((SHELL_VAR *)); -static SHELL_VAR *assign_subshell __P((SHELL_VAR *, char *, arrayind_t, char *)); -static SHELL_VAR *get_subshell __P((SHELL_VAR *)); +static SHELL_VAR *assign_subshell PARAMS((SHELL_VAR *, char *, arrayind_t, char *)); +static SHELL_VAR *get_subshell PARAMS((SHELL_VAR *)); -static SHELL_VAR *get_epochseconds __P((SHELL_VAR *)); -static SHELL_VAR *get_epochrealtime __P((SHELL_VAR *)); +static SHELL_VAR *get_epochseconds PARAMS((SHELL_VAR *)); +static SHELL_VAR *get_epochrealtime PARAMS((SHELL_VAR *)); -static SHELL_VAR *get_bashpid __P((SHELL_VAR *)); +static SHELL_VAR *get_bashpid PARAMS((SHELL_VAR *)); -static SHELL_VAR *get_bash_argv0 __P((SHELL_VAR *)); -static SHELL_VAR *assign_bash_argv0 __P((SHELL_VAR *, char *, arrayind_t, char *)); -static void set_argv0 __P((void)); +static SHELL_VAR *get_bash_argv0 PARAMS((SHELL_VAR *)); +static SHELL_VAR *assign_bash_argv0 PARAMS((SHELL_VAR *, char *, arrayind_t, char *)); +static void set_argv0 PARAMS((void)); #if defined (HISTORY) -static SHELL_VAR *get_histcmd __P((SHELL_VAR *)); +static SHELL_VAR *get_histcmd PARAMS((SHELL_VAR *)); #endif #if defined (READLINE) -static SHELL_VAR *get_comp_wordbreaks __P((SHELL_VAR *)); -static SHELL_VAR *assign_comp_wordbreaks __P((SHELL_VAR *, char *, arrayind_t, char *)); +static SHELL_VAR *get_comp_wordbreaks PARAMS((SHELL_VAR *)); +static SHELL_VAR *assign_comp_wordbreaks PARAMS((SHELL_VAR *, char *, arrayind_t, char *)); #endif #if defined (PUSHD_AND_POPD) && defined (ARRAY_VARS) -static SHELL_VAR *assign_dirstack __P((SHELL_VAR *, char *, arrayind_t, char *)); -static SHELL_VAR *get_dirstack __P((SHELL_VAR *)); +static SHELL_VAR *assign_dirstack PARAMS((SHELL_VAR *, char *, arrayind_t, char *)); +static SHELL_VAR *get_dirstack PARAMS((SHELL_VAR *)); #endif #if defined (ARRAY_VARS) -static SHELL_VAR *get_groupset __P((SHELL_VAR *)); +static SHELL_VAR *get_groupset PARAMS((SHELL_VAR *)); # if defined (DEBUGGER) -static SHELL_VAR *get_bashargcv __P((SHELL_VAR *)); +static SHELL_VAR *get_bashargcv PARAMS((SHELL_VAR *)); # endif -static SHELL_VAR *build_hashcmd __P((SHELL_VAR *)); -static SHELL_VAR *get_hashcmd __P((SHELL_VAR *)); -static SHELL_VAR *assign_hashcmd __P((SHELL_VAR *, char *, arrayind_t, char *)); +static SHELL_VAR *build_hashcmd PARAMS((SHELL_VAR *)); +static SHELL_VAR *get_hashcmd PARAMS((SHELL_VAR *)); +static SHELL_VAR *assign_hashcmd PARAMS((SHELL_VAR *, char *, arrayind_t, char *)); # if defined (ALIAS) -static SHELL_VAR *build_aliasvar __P((SHELL_VAR *)); -static SHELL_VAR *get_aliasvar __P((SHELL_VAR *)); -static SHELL_VAR *assign_aliasvar __P((SHELL_VAR *, char *, arrayind_t, char *)); +static SHELL_VAR *build_aliasvar PARAMS((SHELL_VAR *)); +static SHELL_VAR *get_aliasvar PARAMS((SHELL_VAR *)); +static SHELL_VAR *assign_aliasvar PARAMS((SHELL_VAR *, char *, arrayind_t, char *)); # endif #endif -static SHELL_VAR *get_funcname __P((SHELL_VAR *)); -static SHELL_VAR *init_funcname_var __P((void)); +static SHELL_VAR *get_funcname PARAMS((SHELL_VAR *)); +static SHELL_VAR *init_funcname_var PARAMS((void)); -static void initialize_dynamic_variables __P((void)); +static void initialize_dynamic_variables PARAMS((void)); -static SHELL_VAR *bind_invalid_envvar __P((const char *, char *, int)); +static SHELL_VAR *bind_invalid_envvar PARAMS((const char *, char *, int)); -static int var_sametype __P((SHELL_VAR *, SHELL_VAR *)); +static int var_sametype PARAMS((SHELL_VAR *, SHELL_VAR *)); -static SHELL_VAR *hash_lookup __P((const char *, HASH_TABLE *)); -static SHELL_VAR *new_shell_variable __P((const char *)); -static SHELL_VAR *make_new_variable __P((const char *, HASH_TABLE *)); -static SHELL_VAR *bind_variable_internal __P((const char *, char *, HASH_TABLE *, int, int)); +static SHELL_VAR *hash_lookup PARAMS((const char *, HASH_TABLE *)); +static SHELL_VAR *new_shell_variable PARAMS((const char *)); +static SHELL_VAR *make_new_variable PARAMS((const char *, HASH_TABLE *)); +static SHELL_VAR *bind_variable_internal PARAMS((const char *, char *, HASH_TABLE *, int, int)); -static void dispose_variable_value __P((SHELL_VAR *)); -static void free_variable_hash_data __P((PTR_T)); +static void dispose_variable_value PARAMS((SHELL_VAR *)); +static void free_variable_hash_data PARAMS((PTR_T)); -static VARLIST *vlist_alloc __P((int)); -static VARLIST *vlist_realloc __P((VARLIST *, int)); -static void vlist_add __P((VARLIST *, SHELL_VAR *, int)); +static VARLIST *vlist_alloc PARAMS((int)); +static VARLIST *vlist_realloc PARAMS((VARLIST *, int)); +static void vlist_add PARAMS((VARLIST *, SHELL_VAR *, int)); -static void flatten __P((HASH_TABLE *, sh_var_map_func_t *, VARLIST *, int)); +static void flatten PARAMS((HASH_TABLE *, sh_var_map_func_t *, VARLIST *, int)); -static int qsort_var_comp __P((SHELL_VAR **, SHELL_VAR **)); +static int qsort_var_comp PARAMS((SHELL_VAR **, SHELL_VAR **)); -static SHELL_VAR **vapply __P((sh_var_map_func_t *)); -static SHELL_VAR **fapply __P((sh_var_map_func_t *)); +static SHELL_VAR **vapply PARAMS((sh_var_map_func_t *)); +static SHELL_VAR **fapply PARAMS((sh_var_map_func_t *)); -static int visible_var __P((SHELL_VAR *)); -static int visible_and_exported __P((SHELL_VAR *)); -static int export_environment_candidate __P((SHELL_VAR *)); -static int local_and_exported __P((SHELL_VAR *)); -static int variable_in_context __P((SHELL_VAR *)); +static int visible_var PARAMS((SHELL_VAR *)); +static int visible_and_exported PARAMS((SHELL_VAR *)); +static int export_environment_candidate PARAMS((SHELL_VAR *)); +static int local_and_exported PARAMS((SHELL_VAR *)); +static int variable_in_context PARAMS((SHELL_VAR *)); #if defined (ARRAY_VARS) -static int visible_array_vars __P((SHELL_VAR *)); +static int visible_array_vars PARAMS((SHELL_VAR *)); #endif -static SHELL_VAR *find_variable_internal __P((const char *, int)); +static SHELL_VAR *find_variable_internal PARAMS((const char *, int)); -static SHELL_VAR *find_nameref_at_context __P((SHELL_VAR *, VAR_CONTEXT *)); -static SHELL_VAR *find_variable_nameref_context __P((SHELL_VAR *, VAR_CONTEXT *, VAR_CONTEXT **)); -static SHELL_VAR *find_variable_last_nameref_context __P((SHELL_VAR *, VAR_CONTEXT *, VAR_CONTEXT **)); +static SHELL_VAR *find_nameref_at_context PARAMS((SHELL_VAR *, VAR_CONTEXT *)); +static SHELL_VAR *find_variable_nameref_context PARAMS((SHELL_VAR *, VAR_CONTEXT *, VAR_CONTEXT **)); +static SHELL_VAR *find_variable_last_nameref_context PARAMS((SHELL_VAR *, VAR_CONTEXT *, VAR_CONTEXT **)); -static SHELL_VAR *bind_tempenv_variable __P((const char *, char *)); -static void push_posix_temp_var __P((PTR_T)); -static void push_temp_var __P((PTR_T)); -static void propagate_temp_var __P((PTR_T)); -static void dispose_temporary_env __P((sh_free_func_t *)); +static SHELL_VAR *bind_tempenv_variable PARAMS((const char *, char *)); +static void push_posix_temp_var PARAMS((PTR_T)); +static void push_temp_var PARAMS((PTR_T)); +static void propagate_temp_var PARAMS((PTR_T)); +static void dispose_temporary_env PARAMS((sh_free_func_t *)); -static inline char *mk_env_string __P((const char *, const char *, int)); -static char **make_env_array_from_var_list __P((SHELL_VAR **)); -static char **make_var_export_array __P((VAR_CONTEXT *)); -static char **make_func_export_array __P((void)); -static void add_temp_array_to_env __P((char **, int, int)); +static inline char *mk_env_string PARAMS((const char *, const char *, int)); +static char **make_env_array_from_var_list PARAMS((SHELL_VAR **)); +static char **make_var_export_array PARAMS((VAR_CONTEXT *)); +static char **make_func_export_array PARAMS((void)); +static void add_temp_array_to_env PARAMS((char **, int, int)); -static int n_shell_variables __P((void)); -static int set_context __P((SHELL_VAR *)); +static int n_shell_variables PARAMS((void)); +static int set_context PARAMS((SHELL_VAR *)); -static void push_func_var __P((PTR_T)); -static void push_builtin_var __P((PTR_T)); -static void push_exported_var __P((PTR_T)); +static void push_func_var PARAMS((PTR_T)); +static void push_builtin_var PARAMS((PTR_T)); +static void push_exported_var PARAMS((PTR_T)); /* This needs to be looked at again. */ -static inline void push_posix_tempvar_internal __P((SHELL_VAR *, int)); +static inline void push_posix_tempvar_internal PARAMS((SHELL_VAR *, int)); -static inline int find_special_var __P((const char *)); +static inline int find_special_var PARAMS((const char *)); static void create_variable_tables () @@ -5561,6 +5562,7 @@ pop_scope (is_special) struct saved_dollar_vars { char **first_ten; WORD_LIST *rest; + int count; }; static struct saved_dollar_vars *dollar_arg_stack = (struct saved_dollar_vars *)NULL; @@ -5616,6 +5618,17 @@ free_saved_dollar_vars (args) FREE (args[i]); } +/* Do what remember_args (xxx, 1) would have done. */ +void +clear_dollar_vars () +{ + free_dollar_vars (); + dispose_words (rest_of_args); + + rest_of_args = (WORD_LIST *)NULL; + posparam_count = 0; +} + /* XXX - should always be followed by remember_args () */ void push_context (name, is_subshell, tempvars) @@ -5651,10 +5664,12 @@ push_dollar_vars () xrealloc (dollar_arg_stack, (dollar_arg_stack_slots += 10) * sizeof (struct saved_dollar_vars)); } - + + dollar_arg_stack[dollar_arg_stack_index].count = posparam_count; dollar_arg_stack[dollar_arg_stack_index].first_ten = save_dollar_vars (); dollar_arg_stack[dollar_arg_stack_index++].rest = rest_of_args; rest_of_args = (WORD_LIST *)NULL; + posparam_count = 0; dollar_arg_stack[dollar_arg_stack_index].first_ten = (char **)NULL; dollar_arg_stack[dollar_arg_stack_index].rest = (WORD_LIST *)NULL; @@ -5667,17 +5682,18 @@ pop_dollar_vars () if (dollar_arg_stack == 0 || dollar_arg_stack_index == 0) return; - /* Do what remember_args (xxx, 1) would have done. */ - free_dollar_vars (); - dispose_words (rest_of_args); - + /* Wipe out current values */ + clear_dollar_vars (); + rest_of_args = dollar_arg_stack[--dollar_arg_stack_index].rest; restore_dollar_vars (dollar_arg_stack[dollar_arg_stack_index].first_ten); free (dollar_arg_stack[dollar_arg_stack_index].first_ten); + posparam_count = dollar_arg_stack[dollar_arg_stack_index].count; dollar_arg_stack[dollar_arg_stack_index].first_ten = (char **)NULL; dollar_arg_stack[dollar_arg_stack_index].rest = (WORD_LIST *)NULL; - + dollar_arg_stack[dollar_arg_stack_index].count = 0; + set_dollar_vars_unchanged (); invalidate_cached_quoted_dollar_at (); } @@ -5694,6 +5710,7 @@ dispose_saved_dollar_vars () dollar_arg_stack[dollar_arg_stack_index].first_ten = (char **)NULL; dollar_arg_stack[dollar_arg_stack_index].rest = (WORD_LIST *)NULL; + dollar_arg_stack[dollar_arg_stack_index].count = 0; } /* Initialize BASH_ARGV and BASH_ARGC after turning on extdebug after the diff --git a/variables.h b/variables.h index 4097e797..5911cfe7 100644 --- a/variables.h +++ b/variables.h @@ -1,6 +1,6 @@ /* variables.h -- data structures for shell variables. */ -/* Copyright (C) 1987-2018 Free Software Foundation, Inc. +/* Copyright (C) 1987-2020 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -61,8 +61,8 @@ typedef struct var_context { /* What a shell variable looks like. */ -typedef struct variable *sh_var_value_func_t __P((struct variable *)); -typedef struct variable *sh_var_assign_func_t __P((struct variable *, char *, arrayind_t, char *)); +typedef struct variable *sh_var_value_func_t PARAMS((struct variable *)); +typedef struct variable *sh_var_assign_func_t PARAMS((struct variable *, char *, arrayind_t, char *)); /* For the future */ union _value { @@ -229,7 +229,7 @@ extern SHELL_VAR nameref_invalid_value; #define INVALID_NAMEREF_VALUE (void *)&nameref_invalid_value /* Stuff for hacking variables. */ -typedef int sh_var_map_func_t __P((SHELL_VAR *)); +typedef int sh_var_map_func_t PARAMS((SHELL_VAR *)); /* Where we keep the variables and functions */ extern VAR_CONTEXT *global_variables; @@ -248,204 +248,207 @@ extern int shell_level; /* XXX */ extern WORD_LIST *rest_of_args; +extern int posparam_count; extern pid_t dollar_dollar_pid; -extern void initialize_shell_variables __P((char **, int)); +extern void initialize_shell_variables PARAMS((char **, int)); -extern int validate_inherited_value __P((SHELL_VAR *, int)); +extern int validate_inherited_value PARAMS((SHELL_VAR *, int)); -extern SHELL_VAR *set_if_not __P((char *, char *)); +extern SHELL_VAR *set_if_not PARAMS((char *, char *)); -extern void sh_set_lines_and_columns __P((int, int)); -extern void set_pwd __P((void)); -extern void set_ppid __P((void)); -extern void make_funcname_visible __P((int)); +extern void sh_set_lines_and_columns PARAMS((int, int)); +extern void set_pwd PARAMS((void)); +extern void set_ppid PARAMS((void)); +extern void make_funcname_visible PARAMS((int)); -extern SHELL_VAR *var_lookup __P((const char *, VAR_CONTEXT *)); +extern SHELL_VAR *var_lookup PARAMS((const char *, VAR_CONTEXT *)); -extern SHELL_VAR *find_function __P((const char *)); -extern FUNCTION_DEF *find_function_def __P((const char *)); -extern SHELL_VAR *find_variable __P((const char *)); -extern SHELL_VAR *find_variable_noref __P((const char *)); -extern SHELL_VAR *find_variable_last_nameref __P((const char *, int)); -extern SHELL_VAR *find_global_variable_last_nameref __P((const char *, int)); -extern SHELL_VAR *find_variable_nameref __P((SHELL_VAR *)); -extern SHELL_VAR *find_variable_nameref_for_create __P((const char *, int)); -extern SHELL_VAR *find_variable_nameref_for_assignment __P((const char *, int)); -/*extern SHELL_VAR *find_variable_internal __P((const char *, int));*/ -extern SHELL_VAR *find_variable_tempenv __P((const char *)); -extern SHELL_VAR *find_variable_notempenv __P((const char *)); -extern SHELL_VAR *find_global_variable __P((const char *)); -extern SHELL_VAR *find_global_variable_noref __P((const char *)); -extern SHELL_VAR *find_shell_variable __P((const char *)); -extern SHELL_VAR *find_tempenv_variable __P((const char *)); -extern SHELL_VAR *find_variable_no_invisible __P((const char *)); -extern SHELL_VAR *find_variable_for_assignment __P((const char *)); -extern char *nameref_transform_name __P((char *, int)); -extern SHELL_VAR *copy_variable __P((SHELL_VAR *)); -extern SHELL_VAR *make_local_variable __P((const char *, int)); -extern SHELL_VAR *bind_variable __P((const char *, char *, int)); -extern SHELL_VAR *bind_global_variable __P((const char *, char *, int)); -extern SHELL_VAR *bind_function __P((const char *, COMMAND *)); +extern SHELL_VAR *find_function PARAMS((const char *)); +extern FUNCTION_DEF *find_function_def PARAMS((const char *)); +extern SHELL_VAR *find_variable PARAMS((const char *)); +extern SHELL_VAR *find_variable_noref PARAMS((const char *)); +extern SHELL_VAR *find_variable_last_nameref PARAMS((const char *, int)); +extern SHELL_VAR *find_global_variable_last_nameref PARAMS((const char *, int)); +extern SHELL_VAR *find_variable_nameref PARAMS((SHELL_VAR *)); +extern SHELL_VAR *find_variable_nameref_for_create PARAMS((const char *, int)); +extern SHELL_VAR *find_variable_nameref_for_assignment PARAMS((const char *, int)); +/*extern SHELL_VAR *find_variable_internal PARAMS((const char *, int));*/ +extern SHELL_VAR *find_variable_tempenv PARAMS((const char *)); +extern SHELL_VAR *find_variable_notempenv PARAMS((const char *)); +extern SHELL_VAR *find_global_variable PARAMS((const char *)); +extern SHELL_VAR *find_global_variable_noref PARAMS((const char *)); +extern SHELL_VAR *find_shell_variable PARAMS((const char *)); +extern SHELL_VAR *find_tempenv_variable PARAMS((const char *)); +extern SHELL_VAR *find_variable_no_invisible PARAMS((const char *)); +extern SHELL_VAR *find_variable_for_assignment PARAMS((const char *)); +extern char *nameref_transform_name PARAMS((char *, int)); +extern SHELL_VAR *copy_variable PARAMS((SHELL_VAR *)); +extern SHELL_VAR *make_local_variable PARAMS((const char *, int)); +extern SHELL_VAR *bind_variable PARAMS((const char *, char *, int)); +extern SHELL_VAR *bind_global_variable PARAMS((const char *, char *, int)); +extern SHELL_VAR *bind_function PARAMS((const char *, COMMAND *)); -extern void bind_function_def __P((const char *, FUNCTION_DEF *, int)); +extern void bind_function_def PARAMS((const char *, FUNCTION_DEF *, int)); -extern SHELL_VAR **map_over __P((sh_var_map_func_t *, VAR_CONTEXT *)); -SHELL_VAR **map_over_funcs __P((sh_var_map_func_t *)); +extern SHELL_VAR **map_over PARAMS((sh_var_map_func_t *, VAR_CONTEXT *)); +SHELL_VAR **map_over_funcs PARAMS((sh_var_map_func_t *)); -extern SHELL_VAR **all_shell_variables __P((void)); -extern SHELL_VAR **all_shell_functions __P((void)); -extern SHELL_VAR **all_visible_variables __P((void)); -extern SHELL_VAR **all_visible_functions __P((void)); -extern SHELL_VAR **all_exported_variables __P((void)); -extern SHELL_VAR **local_exported_variables __P((void)); -extern SHELL_VAR **all_local_variables __P((void)); +extern SHELL_VAR **all_shell_variables PARAMS((void)); +extern SHELL_VAR **all_shell_functions PARAMS((void)); +extern SHELL_VAR **all_visible_variables PARAMS((void)); +extern SHELL_VAR **all_visible_functions PARAMS((void)); +extern SHELL_VAR **all_exported_variables PARAMS((void)); +extern SHELL_VAR **local_exported_variables PARAMS((void)); +extern SHELL_VAR **all_local_variables PARAMS((void)); #if defined (ARRAY_VARS) -extern SHELL_VAR **all_array_variables __P((void)); +extern SHELL_VAR **all_array_variables PARAMS((void)); #endif -extern char **all_variables_matching_prefix __P((const char *)); +extern char **all_variables_matching_prefix PARAMS((const char *)); -extern char **make_var_array __P((HASH_TABLE *)); -extern char **add_or_supercede_exported_var __P((char *, int)); +extern char **make_var_array PARAMS((HASH_TABLE *)); +extern char **add_or_supercede_exported_var PARAMS((char *, int)); -extern char *get_variable_value __P((SHELL_VAR *)); -extern char *get_string_value __P((const char *)); -extern char *sh_get_env_value __P((const char *)); -extern char *make_variable_value __P((SHELL_VAR *, char *, int)); +extern char *get_variable_value PARAMS((SHELL_VAR *)); +extern char *get_string_value PARAMS((const char *)); +extern char *sh_get_env_value PARAMS((const char *)); +extern char *make_variable_value PARAMS((SHELL_VAR *, char *, int)); -extern SHELL_VAR *bind_variable_value __P((SHELL_VAR *, char *, int)); -extern SHELL_VAR *bind_int_variable __P((char *, char *, int)); -extern SHELL_VAR *bind_var_to_int __P((char *, intmax_t)); +extern SHELL_VAR *bind_variable_value PARAMS((SHELL_VAR *, char *, int)); +extern SHELL_VAR *bind_int_variable PARAMS((char *, char *, int)); +extern SHELL_VAR *bind_var_to_int PARAMS((char *, intmax_t)); -extern int assign_in_env __P((WORD_DESC *, int)); +extern int assign_in_env PARAMS((WORD_DESC *, int)); -extern int unbind_variable __P((const char *)); -extern int check_unbind_variable __P((const char *)); -extern int unbind_nameref __P((const char *)); -extern int unbind_variable_noref __P((const char *)); -extern int unbind_func __P((const char *)); -extern int unbind_function_def __P((const char *)); -extern int delete_var __P((const char *, VAR_CONTEXT *)); -extern int makunbound __P((const char *, VAR_CONTEXT *)); -extern int kill_local_variable __P((const char *)); -extern void delete_all_variables __P((HASH_TABLE *)); -extern void delete_all_contexts __P((VAR_CONTEXT *)); +extern int unbind_variable PARAMS((const char *)); +extern int check_unbind_variable PARAMS((const char *)); +extern int unbind_nameref PARAMS((const char *)); +extern int unbind_variable_noref PARAMS((const char *)); +extern int unbind_func PARAMS((const char *)); +extern int unbind_function_def PARAMS((const char *)); +extern int delete_var PARAMS((const char *, VAR_CONTEXT *)); +extern int makunbound PARAMS((const char *, VAR_CONTEXT *)); +extern int kill_local_variable PARAMS((const char *)); +extern void delete_all_variables PARAMS((HASH_TABLE *)); +extern void delete_all_contexts PARAMS((VAR_CONTEXT *)); -extern VAR_CONTEXT *new_var_context __P((char *, int)); -extern void dispose_var_context __P((VAR_CONTEXT *)); -extern VAR_CONTEXT *push_var_context __P((char *, int, HASH_TABLE *)); -extern void pop_var_context __P((void)); -extern VAR_CONTEXT *push_scope __P((int, HASH_TABLE *)); -extern void pop_scope __P((int)); +extern VAR_CONTEXT *new_var_context PARAMS((char *, int)); +extern void dispose_var_context PARAMS((VAR_CONTEXT *)); +extern VAR_CONTEXT *push_var_context PARAMS((char *, int, HASH_TABLE *)); +extern void pop_var_context PARAMS((void)); +extern VAR_CONTEXT *push_scope PARAMS((int, HASH_TABLE *)); +extern void pop_scope PARAMS((int)); -extern void push_context __P((char *, int, HASH_TABLE *)); -extern void pop_context __P((void)); -extern void push_dollar_vars __P((void)); -extern void pop_dollar_vars __P((void)); -extern void dispose_saved_dollar_vars __P((void)); +extern void clear_dollar_vars PARAMS((void)); -extern void init_bash_argv __P((void)); -extern void save_bash_argv __P((void)); -extern void push_args __P((WORD_LIST *)); -extern void pop_args __P((void)); +extern void push_context PARAMS((char *, int, HASH_TABLE *)); +extern void pop_context PARAMS((void)); +extern void push_dollar_vars PARAMS((void)); +extern void pop_dollar_vars PARAMS((void)); +extern void dispose_saved_dollar_vars PARAMS((void)); -extern void adjust_shell_level __P((int)); -extern void non_unsettable __P((char *)); -extern void dispose_variable __P((SHELL_VAR *)); -extern void dispose_used_env_vars __P((void)); -extern void dispose_function_env __P((void)); -extern void dispose_builtin_env __P((void)); -extern void merge_temporary_env __P((void)); -extern void flush_temporary_env __P((void)); -extern void merge_builtin_env __P((void)); -extern void kill_all_local_variables __P((void)); +extern void init_bash_argv PARAMS((void)); +extern void save_bash_argv PARAMS((void)); +extern void push_args PARAMS((WORD_LIST *)); +extern void pop_args PARAMS((void)); -extern void set_var_read_only __P((char *)); -extern void set_func_read_only __P((const char *)); -extern void set_var_auto_export __P((char *)); -extern void set_func_auto_export __P((const char *)); +extern void adjust_shell_level PARAMS((int)); +extern void non_unsettable PARAMS((char *)); +extern void dispose_variable PARAMS((SHELL_VAR *)); +extern void dispose_used_env_vars PARAMS((void)); +extern void dispose_function_env PARAMS((void)); +extern void dispose_builtin_env PARAMS((void)); +extern void merge_temporary_env PARAMS((void)); +extern void flush_temporary_env PARAMS((void)); +extern void merge_builtin_env PARAMS((void)); +extern void kill_all_local_variables PARAMS((void)); -extern void sort_variables __P((SHELL_VAR **)); +extern void set_var_read_only PARAMS((char *)); +extern void set_func_read_only PARAMS((const char *)); +extern void set_var_auto_export PARAMS((char *)); +extern void set_func_auto_export PARAMS((const char *)); -extern int chkexport __P((char *)); -extern void maybe_make_export_env __P((void)); -extern void update_export_env_inplace __P((char *, int, char *)); -extern void put_command_name_into_env __P((char *)); -extern void put_gnu_argv_flags_into_env __P((intmax_t, char *)); +extern void sort_variables PARAMS((SHELL_VAR **)); -extern void print_var_list __P((SHELL_VAR **)); -extern void print_func_list __P((SHELL_VAR **)); -extern void print_assignment __P((SHELL_VAR *)); -extern void print_var_value __P((SHELL_VAR *, int)); -extern void print_var_function __P((SHELL_VAR *)); +extern int chkexport PARAMS((char *)); +extern void maybe_make_export_env PARAMS((void)); +extern void update_export_env_inplace PARAMS((char *, int, char *)); +extern void put_command_name_into_env PARAMS((char *)); +extern void put_gnu_argv_flags_into_env PARAMS((intmax_t, char *)); + +extern void print_var_list PARAMS((SHELL_VAR **)); +extern void print_func_list PARAMS((SHELL_VAR **)); +extern void print_assignment PARAMS((SHELL_VAR *)); +extern void print_var_value PARAMS((SHELL_VAR *, int)); +extern void print_var_function PARAMS((SHELL_VAR *)); #if defined (ARRAY_VARS) -extern SHELL_VAR *make_new_array_variable __P((char *)); -extern SHELL_VAR *make_local_array_variable __P((char *, int)); +extern SHELL_VAR *make_new_array_variable PARAMS((char *)); +extern SHELL_VAR *make_local_array_variable PARAMS((char *, int)); -extern SHELL_VAR *make_new_assoc_variable __P((char *)); -extern SHELL_VAR *make_local_assoc_variable __P((char *, int)); +extern SHELL_VAR *make_new_assoc_variable PARAMS((char *)); +extern SHELL_VAR *make_local_assoc_variable PARAMS((char *, int)); -extern void set_pipestatus_array __P((int *, int)); -extern ARRAY *save_pipestatus_array __P((void)); -extern void restore_pipestatus_array __P((ARRAY *)); +extern void set_pipestatus_array PARAMS((int *, int)); +extern ARRAY *save_pipestatus_array PARAMS((void)); +extern void restore_pipestatus_array PARAMS((ARRAY *)); #endif -extern void set_pipestatus_from_exit __P((int)); +extern void set_pipestatus_from_exit PARAMS((int)); /* The variable in NAME has just had its state changed. Check to see if it is one of the special ones where something special happens. */ -extern void stupidly_hack_special_variables __P((char *)); +extern void stupidly_hack_special_variables PARAMS((char *)); /* Reinitialize some special variables that have external effects upon unset when the shell reinitializes itself. */ -extern void reinit_special_variables __P((void)); +extern void reinit_special_variables PARAMS((void)); -extern int get_random_number __P((void)); +extern int get_random_number PARAMS((void)); /* The `special variable' functions that get called when a particular variable is set. */ -extern void sv_ifs __P((char *)); -extern void sv_path __P((char *)); -extern void sv_mail __P((char *)); -extern void sv_funcnest __P((char *)); -extern void sv_execignore __P((char *)); -extern void sv_globignore __P((char *)); -extern void sv_ignoreeof __P((char *)); -extern void sv_strict_posix __P((char *)); -extern void sv_optind __P((char *)); -extern void sv_opterr __P((char *)); -extern void sv_locale __P((char *)); -extern void sv_xtracefd __P((char *)); -extern void sv_shcompat __P((char *)); +extern void sv_ifs PARAMS((char *)); +extern void sv_path PARAMS((char *)); +extern void sv_mail PARAMS((char *)); +extern void sv_funcnest PARAMS((char *)); +extern void sv_execignore PARAMS((char *)); +extern void sv_globignore PARAMS((char *)); +extern void sv_ignoreeof PARAMS((char *)); +extern void sv_strict_posix PARAMS((char *)); +extern void sv_optind PARAMS((char *)); +extern void sv_opterr PARAMS((char *)); +extern void sv_locale PARAMS((char *)); +extern void sv_xtracefd PARAMS((char *)); +extern void sv_shcompat PARAMS((char *)); #if defined (READLINE) -extern void sv_comp_wordbreaks __P((char *)); -extern void sv_terminal __P((char *)); -extern void sv_hostfile __P((char *)); -extern void sv_winsize __P((char *)); +extern void sv_comp_wordbreaks PARAMS((char *)); +extern void sv_terminal PARAMS((char *)); +extern void sv_hostfile PARAMS((char *)); +extern void sv_winsize PARAMS((char *)); #endif #if defined (__CYGWIN__) -extern void sv_home __P((char *)); +extern void sv_home PARAMS((char *)); #endif #if defined (HISTORY) -extern void sv_histsize __P((char *)); -extern void sv_histignore __P((char *)); -extern void sv_history_control __P((char *)); +extern void sv_histsize PARAMS((char *)); +extern void sv_histignore PARAMS((char *)); +extern void sv_history_control PARAMS((char *)); # if defined (BANG_HISTORY) -extern void sv_histchars __P((char *)); +extern void sv_histchars PARAMS((char *)); # endif -extern void sv_histtimefmt __P((char *)); +extern void sv_histtimefmt PARAMS((char *)); #endif /* HISTORY */ #if defined (HAVE_TZSET) -extern void sv_tz __P((char *)); +extern void sv_tz PARAMS((char *)); #endif #if defined (JOB_CONTROL) -extern void sv_childmax __P((char *)); +extern void sv_childmax PARAMS((char *)); #endif #endif /* !_VARIABLES_H_ */