commit bash-20200306 snapshot

This commit is contained in:
Chet Ramey
2020-03-09 16:35:44 -04:00
parent 47c7369e84
commit 8f576adedb
13 changed files with 317 additions and 274 deletions
+27
View File
@@ -7504,3 +7504,30 @@ locale.c
general.c
- interrupt_immediately: remove all references to this that are
already commented out
3/2
---
variables.c
- push_var_context,push_posix_tempvar_internal: assignment statements
preceding shell functions no longer persist after the function
completes in posix mode. POSIX interp #654, was in P1003.1-2017
- push_posix_temp_var: variable assignments preceding special builtins
now act as if an assignment statement had been executed in posix mode
(the Posix `current execution environment') instead of unconditionally
creating a global variable
trap.c
- clear_pending_traps: new function, just clears the pending traps flag
for all signals
3/6
---
execute_cmd.c
- execute_in_subshell: check for interrupts and terminating signals
before resetting the terminating signal handlers, and clear all
pending traps -- they're not pending for us and we should not run a
trap handler for them
- execute_in_subshell: enable bash-5.1 change from 11/29/2018 that
resets the signal-in-progress flag if we're running a command in
a subshell, since we're not running the trap command (we are the
trap command)
+9
View File
@@ -4657,6 +4657,15 @@ bash_dequote_text (text)
static int
bash_event_hook ()
{
/* XXX - see if we need to do anything here if sigterm_received == 1,
we probably don't want to reset the event hook since we will not be
jumping to the top level */
if (sigterm_received)
{
/* RESET_SIGTERM; */
return 0;
}
/* If we're going to longjmp to top_level, make sure we clean up readline.
check_signals will call QUIT, which will eventually longjmp to top_level,
calling run_interrupt_trap along the way. The check for sigalrm_seen is
+7 -4
View File
@@ -1,6 +1,6 @@
/* execute_cmd.c -- Execute a COMMAND structure. */
/* Copyright (C) 1987-2019 Free Software Foundation, Inc.
/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -1530,22 +1530,25 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
subshell_environment |= SUBSHELL_COPROC;
}
QUIT;
CHECK_TERMSIG;
reset_terminating_signals (); /* in sig.c */
/* Cancel traps, in trap.c. */
/* Reset the signal handlers in the child, but don't free the
trap strings. Set a flag noting that we have to free the
trap strings if we run trap to change a signal disposition. */
clear_pending_traps ();
reset_signal_handlers ();
subshell_environment |= SUBSHELL_RESETTRAP;
#if 0 /* TAG:bash-5.1 */
/* We are in a subshell, so forget that we are running a trap handler or
that the signal handler has changed (we haven't changed it!) */
if (running_trap > 0)
{
run_trap_cleanup (running_trap - 1);
running_trap = 0;
running_trap = 0; /* XXX - maybe leave this */
}
#endif
/* Make sure restore_original_signals doesn't undo the work done by
make_child to ensure that asynchronous children are immune to SIGINT
+35 -35
View File
@@ -69,55 +69,55 @@ extern SHELL_VAR *this_shell_function;
/* Functions declared in execute_cmd.c, used by many other files */
extern struct fd_bitmap *new_fd_bitmap __P((int));
extern void dispose_fd_bitmap __P((struct fd_bitmap *));
extern void close_fd_bitmap __P((struct fd_bitmap *));
extern int executing_line_number __P((void));
extern int execute_command __P((COMMAND *));
extern int execute_command_internal __P((COMMAND *, int, int, int, struct fd_bitmap *));
extern int shell_execve __P((char *, char **, char **));
extern void setup_async_signals __P((void));
extern void async_redirect_stdin __P((void));
extern struct fd_bitmap *new_fd_bitmap PARAMS((int));
extern void dispose_fd_bitmap PARAMS((struct fd_bitmap *));
extern void close_fd_bitmap PARAMS((struct fd_bitmap *));
extern int executing_line_number PARAMS((void));
extern int execute_command PARAMS((COMMAND *));
extern int execute_command_internal PARAMS((COMMAND *, int, int, int, struct fd_bitmap *));
extern int shell_execve PARAMS((char *, char **, char **));
extern void setup_async_signals PARAMS((void));
extern void async_redirect_stdin PARAMS((void));
extern void undo_partial_redirects __P((void));
extern void dispose_partial_redirects __P((void));
extern void dispose_exec_redirects __P((void));
extern void undo_partial_redirects PARAMS((void));
extern void dispose_partial_redirects PARAMS((void));
extern void dispose_exec_redirects PARAMS((void));
extern int execute_shell_function __P((SHELL_VAR *, WORD_LIST *));
extern int execute_shell_function PARAMS((SHELL_VAR *, WORD_LIST *));
extern struct coproc *getcoprocbypid __P((pid_t));
extern struct coproc *getcoprocbyname __P((const char *));
extern struct coproc *getcoprocbypid PARAMS((pid_t));
extern struct coproc *getcoprocbyname PARAMS((const char *));
extern void coproc_init __P((struct coproc *));
extern struct coproc *coproc_alloc __P((char *, pid_t));
extern void coproc_dispose __P((struct coproc *));
extern void coproc_flush __P((void));
extern void coproc_close __P((struct coproc *));
extern void coproc_closeall __P((void));
extern void coproc_reap __P((void));
extern pid_t coproc_active __P((void));
extern void coproc_init PARAMS((struct coproc *));
extern struct coproc *coproc_alloc PARAMS((char *, pid_t));
extern void coproc_dispose PARAMS((struct coproc *));
extern void coproc_flush PARAMS((void));
extern void coproc_close PARAMS((struct coproc *));
extern void coproc_closeall PARAMS((void));
extern void coproc_reap PARAMS((void));
extern pid_t coproc_active PARAMS((void));
extern void coproc_rclose __P((struct coproc *, int));
extern void coproc_wclose __P((struct coproc *, int));
extern void coproc_fdclose __P((struct coproc *, int));
extern void coproc_rclose PARAMS((struct coproc *, int));
extern void coproc_wclose PARAMS((struct coproc *, int));
extern void coproc_fdclose PARAMS((struct coproc *, int));
extern void coproc_checkfd __P((struct coproc *, int));
extern void coproc_fdchk __P((int));
extern void coproc_checkfd PARAMS((struct coproc *, int));
extern void coproc_fdchk PARAMS((int));
extern void coproc_pidchk __P((pid_t, int));
extern void coproc_pidchk PARAMS((pid_t, int));
extern void coproc_fdsave __P((struct coproc *));
extern void coproc_fdrestore __P((struct coproc *));
extern void coproc_fdsave PARAMS((struct coproc *));
extern void coproc_fdrestore PARAMS((struct coproc *));
extern void coproc_setvars __P((struct coproc *));
extern void coproc_unsetvars __P((struct coproc *));
extern void coproc_setvars PARAMS((struct coproc *));
extern void coproc_unsetvars PARAMS((struct coproc *));
#if defined (PROCESS_SUBSTITUTION)
extern void close_all_files __P((void));
extern void close_all_files PARAMS((void));
#endif
#if defined (ARRAY_VARS)
extern void restore_funcarray_state __P((struct func_array_state *));
extern void restore_funcarray_state PARAMS((struct func_array_state *));
#endif
#endif /* _EXECUTE_CMD_H_ */
+206 -206
View File
@@ -29,153 +29,153 @@
/* Functions from expr.c. */
#define EXP_EXPANDED 0x01
extern intmax_t evalexp __P((char *, int, int *));
extern intmax_t evalexp PARAMS((char *, int, int *));
/* Functions from print_cmd.c. */
#define FUNC_MULTILINE 0x01
#define FUNC_EXTERNAL 0x02
extern char *make_command_string __P((COMMAND *));
extern char *named_function_string __P((char *, COMMAND *, int));
extern char *make_command_string PARAMS((COMMAND *));
extern char *named_function_string PARAMS((char *, COMMAND *, int));
extern void print_command __P((COMMAND *));
extern void print_simple_command __P((SIMPLE_COM *));
extern void print_word_list __P((WORD_LIST *, char *));
extern void print_command PARAMS((COMMAND *));
extern void print_simple_command PARAMS((SIMPLE_COM *));
extern void print_word_list PARAMS((WORD_LIST *, char *));
/* debugger support */
extern void print_for_command_head __P((FOR_COM *));
extern void print_for_command_head PARAMS((FOR_COM *));
#if defined (SELECT_COMMAND)
extern void print_select_command_head __P((SELECT_COM *));
extern void print_select_command_head PARAMS((SELECT_COM *));
#endif
extern void print_case_command_head __P((CASE_COM *));
extern void print_case_command_head PARAMS((CASE_COM *));
#if defined (DPAREN_ARITHMETIC)
extern void print_arith_command __P((WORD_LIST *));
extern void print_arith_command PARAMS((WORD_LIST *));
#endif
#if defined (COND_COMMAND)
extern void print_cond_command __P((COND_COM *));
extern void print_cond_command PARAMS((COND_COM *));
#endif
/* set -x support */
extern void xtrace_init __P((void));
extern void xtrace_init PARAMS((void));
#ifdef NEED_XTRACE_SET_DECL
extern void xtrace_set __P((int, FILE *));
extern void xtrace_set PARAMS((int, FILE *));
#endif
extern void xtrace_fdchk __P((int));
extern void xtrace_reset __P((void));
extern char *indirection_level_string __P((void));
extern void xtrace_print_assignment __P((char *, char *, int, int));
extern void xtrace_print_word_list __P((WORD_LIST *, int));
extern void xtrace_print_for_command_head __P((FOR_COM *));
extern void xtrace_fdchk PARAMS((int));
extern void xtrace_reset PARAMS((void));
extern char *indirection_level_string PARAMS((void));
extern void xtrace_print_assignment PARAMS((char *, char *, int, int));
extern void xtrace_print_word_list PARAMS((WORD_LIST *, int));
extern void xtrace_print_for_command_head PARAMS((FOR_COM *));
#if defined (SELECT_COMMAND)
extern void xtrace_print_select_command_head __P((SELECT_COM *));
extern void xtrace_print_select_command_head PARAMS((SELECT_COM *));
#endif
extern void xtrace_print_case_command_head __P((CASE_COM *));
extern void xtrace_print_case_command_head PARAMS((CASE_COM *));
#if defined (DPAREN_ARITHMETIC)
extern void xtrace_print_arith_cmd __P((WORD_LIST *));
extern void xtrace_print_arith_cmd PARAMS((WORD_LIST *));
#endif
#if defined (COND_COMMAND)
extern void xtrace_print_cond_term __P((int, int, WORD_DESC *, char *, char *));
extern void xtrace_print_cond_term PARAMS((int, int, WORD_DESC *, char *, char *));
#endif
/* Functions from shell.c. */
extern void exit_shell __P((int)) __attribute__((__noreturn__));
extern void sh_exit __P((int)) __attribute__((__noreturn__));
extern void subshell_exit __P((int)) __attribute__((__noreturn__));
extern void set_exit_status __P((int));
extern void disable_priv_mode __P((void));
extern void unbind_args __P((void));
extern void exit_shell PARAMS((int)) __attribute__((__noreturn__));
extern void sh_exit PARAMS((int)) __attribute__((__noreturn__));
extern void subshell_exit PARAMS((int)) __attribute__((__noreturn__));
extern void set_exit_status PARAMS((int));
extern void disable_priv_mode PARAMS((void));
extern void unbind_args PARAMS((void));
#if defined (RESTRICTED_SHELL)
extern int shell_is_restricted __P((char *));
extern int maybe_make_restricted __P((char *));
extern int shell_is_restricted PARAMS((char *));
extern int maybe_make_restricted PARAMS((char *));
#endif
extern void unset_bash_input __P((int));
extern void get_current_user_info __P((void));
extern void unset_bash_input PARAMS((int));
extern void get_current_user_info PARAMS((void));
/* Functions from eval.c. */
extern int reader_loop __P((void));
extern int pretty_print_loop __P((void));
extern int parse_command __P((void));
extern int read_command __P((void));
extern int reader_loop PARAMS((void));
extern int pretty_print_loop PARAMS((void));
extern int parse_command PARAMS((void));
extern int read_command PARAMS((void));
/* Functions from braces.c. */
#if defined (BRACE_EXPANSION)
extern char **brace_expand __P((char *));
extern char **brace_expand PARAMS((char *));
#endif
/* Miscellaneous functions from parse.y */
extern int yyparse __P((void));
extern int return_EOF __P((void));
extern void push_token __P((int));
extern char *xparse_dolparen __P((char *, char *, int *, int));
extern void reset_parser __P((void));
extern void reset_readahead_token __P((void));
extern WORD_LIST *parse_string_to_word_list __P((char *, int, const char *));
extern int yyparse PARAMS((void));
extern int return_EOF PARAMS((void));
extern void push_token PARAMS((int));
extern char *xparse_dolparen PARAMS((char *, char *, int *, int));
extern void reset_parser PARAMS((void));
extern void reset_readahead_token PARAMS((void));
extern WORD_LIST *parse_string_to_word_list PARAMS((char *, int, const char *));
extern int parser_will_prompt __P((void));
extern int parser_in_command_position __P((void));
extern int parser_will_prompt PARAMS((void));
extern int parser_in_command_position PARAMS((void));
extern void free_pushed_string_input __P((void));
extern void free_pushed_string_input PARAMS((void));
extern int parser_expanding_alias __P((void));
extern void parser_save_alias __P((void));
extern void parser_restore_alias __P((void));
extern int parser_expanding_alias PARAMS((void));
extern void parser_save_alias PARAMS((void));
extern void parser_restore_alias PARAMS((void));
extern void clear_shell_input_line __P((void));
extern void clear_shell_input_line PARAMS((void));
extern char *decode_prompt_string __P((char *));
extern char *decode_prompt_string PARAMS((char *));
extern int get_current_prompt_level __P((void));
extern void set_current_prompt_level __P((int));
extern int get_current_prompt_level PARAMS((void));
extern void set_current_prompt_level PARAMS((int));
#if defined (HISTORY)
extern char *history_delimiting_chars __P((const char *));
extern char *history_delimiting_chars PARAMS((const char *));
#endif
/* Declarations for functions defined in locale.c */
extern void set_default_locale __P((void));
extern void set_default_locale_vars __P((void));
extern int set_locale_var __P((char *, char *));
extern int set_lang __P((char *, char *));
extern void set_default_lang __P((void));
extern char *get_locale_var __P((char *));
extern char *localetrans __P((char *, int, int *));
extern char *mk_msgstr __P((char *, int *));
extern char *localeexpand __P((char *, int, int, int, int *));
extern void set_default_locale PARAMS((void));
extern void set_default_locale_vars PARAMS((void));
extern int set_locale_var PARAMS((char *, char *));
extern int set_lang PARAMS((char *, char *));
extern void set_default_lang PARAMS((void));
extern char *get_locale_var PARAMS((char *));
extern char *localetrans PARAMS((char *, int, int *));
extern char *mk_msgstr PARAMS((char *, int *));
extern char *localeexpand PARAMS((char *, int, int, int, int *));
#ifndef locale_decpoint
extern int locale_decpoint __P((void));
extern int locale_decpoint PARAMS((void));
#endif
/* Declarations for functions defined in list.c. */
extern void list_walk __P((GENERIC_LIST *, sh_glist_func_t *));
extern void wlist_walk __P((WORD_LIST *, sh_icpfunc_t *));
extern void list_walk PARAMS((GENERIC_LIST *, sh_glist_func_t *));
extern void wlist_walk PARAMS((WORD_LIST *, sh_icpfunc_t *));
extern GENERIC_LIST *list_reverse ();
extern int list_length ();
extern GENERIC_LIST *list_append ();
extern GENERIC_LIST *list_remove ();
/* Declarations for functions defined in stringlib.c */
extern int find_string_in_alist __P((char *, STRING_INT_ALIST *, int));
extern char *find_token_in_alist __P((int, STRING_INT_ALIST *, int));
extern int find_index_in_alist __P((char *, STRING_INT_ALIST *, int));
extern int find_string_in_alist PARAMS((char *, STRING_INT_ALIST *, int));
extern char *find_token_in_alist PARAMS((int, STRING_INT_ALIST *, int));
extern int find_index_in_alist PARAMS((char *, STRING_INT_ALIST *, int));
extern char *substring __P((const char *, int, int));
extern char *strsub __P((char *, char *, char *, int));
extern char *strcreplace __P((char *, int, const char *, int));
extern void strip_leading __P((char *));
extern void strip_trailing __P((char *, int, int));
extern void xbcopy __P((char *, char *, int));
extern char *substring PARAMS((const char *, int, int));
extern char *strsub PARAMS((char *, char *, char *, int));
extern char *strcreplace PARAMS((char *, int, const char *, int));
extern void strip_leading PARAMS((char *));
extern void strip_trailing PARAMS((char *, int, int));
extern void xbcopy PARAMS((char *, char *, int));
/* Functions from version.c. */
extern char *shell_version_string __P((void));
extern void show_shell_version __P((int));
extern char *shell_version_string PARAMS((void));
extern void show_shell_version PARAMS((int));
/* Functions from the bash library, lib/sh/libsh.a. These should really
go into a separate include file. */
/* declarations for functions defined in lib/sh/casemod.c */
extern char *sh_modcase __P((const char *, char *, int));
extern char *sh_modcase PARAMS((const char *, char *, int));
/* Defines for flags argument to sh_modcase. These need to agree with what's
in lib/sh/casemode.c */
@@ -191,7 +191,7 @@ extern char *sh_modcase __P((const char *, char *, int));
#define CASE_USEWORDS 0x1000
/* declarations for functions defined in lib/sh/clktck.c */
extern long get_clk_tck __P((void));
extern long get_clk_tck PARAMS((void));
/* declarations for functions defined in lib/sh/clock.c */
extern void clock_t_to_secs ();
@@ -199,7 +199,7 @@ extern void print_clock_t ();
/* Declarations for functions defined in lib/sh/dprintf.c */
#if !defined (HAVE_DPRINTF)
extern void dprintf __P((int, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
extern void dprintf PARAMS((int, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
#endif
/* Declarations for functions defined in lib/sh/fmtulong.c */
@@ -208,19 +208,19 @@ extern void dprintf __P((int, const char *, ...)) __attribute__((__format__ (pr
#define FL_HEXUPPER 0x04 /* use uppercase when converting to hex */
#define FL_UNSIGNED 0x08 /* don't add any sign */
extern char *fmtulong __P((unsigned long int, int, char *, size_t, int));
extern char *fmtulong PARAMS((unsigned long int, int, char *, size_t, int));
/* Declarations for functions defined in lib/sh/fmtulong.c */
#if defined (HAVE_LONG_LONG)
extern char *fmtullong __P((unsigned long long int, int, char *, size_t, int));
extern char *fmtullong PARAMS((unsigned long long int, int, char *, size_t, int));
#endif
/* Declarations for functions defined in lib/sh/fmtumax.c */
extern char *fmtumax __P((uintmax_t, int, char *, size_t, int));
extern char *fmtumax PARAMS((uintmax_t, int, char *, size_t, int));
/* Declarations for functions defined in lib/sh/fnxform.c */
extern char *fnx_fromfs __P((char *, size_t));
extern char *fnx_tofs __P((char *, size_t));
extern char *fnx_fromfs PARAMS((char *, size_t));
extern char *fnx_tofs PARAMS((char *, size_t));
/* Declarations for functions defined in lib/sh/fpurge.c */
@@ -230,25 +230,25 @@ extern char *fnx_tofs __P((char *, size_t));
#if HAVE_FPURGE
# define fpurge _bash_fpurge
#endif
extern int fpurge __P((FILE *stream));
extern int fpurge PARAMS((FILE *stream));
#endif /* HAVE_DECL_FPURGE */
#endif /* NEED_FPURGE_DECL */
/* Declarations for functions defined in lib/sh/getcwd.c */
#if !defined (HAVE_GETCWD)
extern char *getcwd __P((char *, size_t));
extern char *getcwd PARAMS((char *, size_t));
#endif
/* Declarations for functions defined in lib/sh/input_avail.c */
extern int input_avail __P((int));
extern int input_avail PARAMS((int));
/* Declarations for functions defined in lib/sh/itos.c */
extern char *inttostr __P((intmax_t, char *, size_t));
extern char *itos __P((intmax_t));
extern char *mitos __P((intmax_t));
extern char *uinttostr __P((uintmax_t, char *, size_t));
extern char *uitos __P((uintmax_t));
extern char *inttostr PARAMS((intmax_t, char *, size_t));
extern char *itos PARAMS((intmax_t));
extern char *mitos PARAMS((intmax_t));
extern char *uinttostr PARAMS((uintmax_t, char *, size_t));
extern char *uitos PARAMS((uintmax_t));
/* declarations for functions defined in lib/sh/makepath.c */
#define MP_DOTILDE 0x01
@@ -256,45 +256,45 @@ extern char *uitos __P((uintmax_t));
#define MP_RMDOT 0x04
#define MP_IGNDOT 0x08
extern char *sh_makepath __P((const char *, const char *, int));
extern char *sh_makepath PARAMS((const char *, const char *, int));
/* declarations for functions defined in lib/sh/mbscasecmp.c */
#if !defined (HAVE_MBSCASECMP)
extern char *mbscasecmp __P((const char *, const char *));
extern char *mbscasecmp PARAMS((const char *, const char *));
#endif
/* declarations for functions defined in lib/sh/mbschr.c */
#if !defined (HAVE_MBSCHR)
extern char *mbschr __P((const char *, int));
extern char *mbschr PARAMS((const char *, int));
#endif
/* declarations for functions defined in lib/sh/mbscmp.c */
#if !defined (HAVE_MBSCMP)
extern char *mbscmp __P((const char *, const char *));
extern char *mbscmp PARAMS((const char *, const char *));
#endif
/* declarations for functions defined in lib/sh/netconn.c */
extern int isnetconn __P((int));
extern int isnetconn PARAMS((int));
/* declarations for functions defined in lib/sh/netopen.c */
extern int netopen __P((char *));
extern int netopen PARAMS((char *));
/* Declarations for functions defined in lib/sh/oslib.c */
#if !defined (HAVE_DUP2) || defined (DUP2_BROKEN)
extern int dup2 __P((int, int));
extern int dup2 PARAMS((int, int));
#endif
#if !defined (HAVE_GETDTABLESIZE)
extern int getdtablesize __P((void));
extern int getdtablesize PARAMS((void));
#endif /* !HAVE_GETDTABLESIZE */
#if !defined (HAVE_GETHOSTNAME)
extern int gethostname __P((char *, int));
extern int gethostname PARAMS((char *, int));
#endif /* !HAVE_GETHOSTNAME */
extern int getmaxgroups __P((void));
extern long getmaxchild __P((void));
extern int getmaxgroups PARAMS((void));
extern long getmaxchild PARAMS((void));
/* declarations for functions defined in lib/sh/pathcanon.c */
#define PATH_CHECKDOTDOT 0x0001
@@ -302,71 +302,71 @@ extern long getmaxchild __P((void));
#define PATH_HARDPATH 0x0004
#define PATH_NOALLOC 0x0008
extern char *sh_canonpath __P((char *, int));
extern char *sh_canonpath PARAMS((char *, int));
/* declarations for functions defined in lib/sh/pathphys.c */
extern char *sh_physpath __P((char *, int));
extern char *sh_realpath __P((const char *, char *));
extern char *sh_physpath PARAMS((char *, int));
extern char *sh_realpath PARAMS((const char *, char *));
/* declarations for functions defined in lib/sh/setlinebuf.c */
#ifdef NEED_SH_SETLINEBUF_DECL
extern int sh_setlinebuf __P((FILE *));
extern int sh_setlinebuf PARAMS((FILE *));
#endif
/* declarations for functions defined in lib/sh/shaccess.c */
extern int sh_eaccess __P((const char *, int));
extern int sh_eaccess PARAMS((const char *, int));
/* declarations for functions defined in lib/sh/shmatch.c */
extern int sh_regmatch __P((const char *, const char *, int));
extern int sh_regmatch PARAMS((const char *, const char *, int));
/* defines for flags argument to sh_regmatch. */
#define SHMAT_SUBEXP 0x001 /* save subexpressions in SH_REMATCH */
#define SHMAT_PWARN 0x002 /* print a warning message on invalid regexp */
/* declarations for functions defined in lib/sh/shmbchar.c */
extern size_t mbstrlen __P((const char *));
extern char *mbsmbchar __P((const char *));
extern int sh_mbsnlen __P((const char *, size_t, int));
extern size_t mbstrlen PARAMS((const char *));
extern char *mbsmbchar PARAMS((const char *));
extern int sh_mbsnlen PARAMS((const char *, size_t, int));
/* declarations for functions defined in lib/sh/shquote.c */
extern char *sh_single_quote __P((const char *));
extern char *sh_double_quote __P((const char *));
extern char *sh_mkdoublequoted __P((const char *, int, int));
extern char *sh_un_double_quote __P((char *));
extern char *sh_backslash_quote __P((char *, const char *, int));
extern char *sh_backslash_quote_for_double_quotes __P((char *));
extern char *sh_quote_reusable __P((char *, int));
extern int sh_contains_shell_metas __P((const char *));
extern int sh_contains_quotes __P((const char *));
extern char *sh_single_quote PARAMS((const char *));
extern char *sh_double_quote PARAMS((const char *));
extern char *sh_mkdoublequoted PARAMS((const char *, int, int));
extern char *sh_un_double_quote PARAMS((char *));
extern char *sh_backslash_quote PARAMS((char *, const char *, int));
extern char *sh_backslash_quote_for_double_quotes PARAMS((char *));
extern char *sh_quote_reusable PARAMS((char *, int));
extern int sh_contains_shell_metas PARAMS((const char *));
extern int sh_contains_quotes PARAMS((const char *));
/* declarations for functions defined in lib/sh/spell.c */
extern int spname __P((char *, char *));
extern char *dirspell __P((char *));
extern int spname PARAMS((char *, char *));
extern char *dirspell PARAMS((char *));
/* declarations for functions defined in lib/sh/strcasecmp.c */
#if !defined (HAVE_STRCASECMP)
extern int strncasecmp __P((const char *, const char *, size_t));
extern int strcasecmp __P((const char *, const char *));
extern int strncasecmp PARAMS((const char *, const char *, size_t));
extern int strcasecmp PARAMS((const char *, const char *));
#endif /* HAVE_STRCASECMP */
/* declarations for functions defined in lib/sh/strcasestr.c */
#if ! HAVE_STRCASESTR
extern char *strcasestr __P((const char *, const char *));
extern char *strcasestr PARAMS((const char *, const char *));
#endif
/* declarations for functions defined in lib/sh/strchrnul.c */
#if ! HAVE_STRCHRNUL
extern char *strchrnul __P((const char *, int));
extern char *strchrnul PARAMS((const char *, int));
#endif
/* declarations for functions defined in lib/sh/strerror.c */
#if !defined (HAVE_STRERROR) && !defined (strerror)
extern char *strerror __P((int));
extern char *strerror PARAMS((int));
#endif
/* declarations for functions defined in lib/sh/strftime.c */
#if !defined (HAVE_STRFTIME) && defined (NEED_STRFTIME_DECL)
extern size_t strftime __P((char *, size_t, const char *, const struct tm *));
extern size_t strftime PARAMS((char *, size_t, const char *, const struct tm *));
#endif
/* declarations for functions and structures defined in lib/sh/stringlist.c */
@@ -378,90 +378,90 @@ typedef struct _list_of_strings {
int list_len;
} STRINGLIST;
typedef int sh_strlist_map_func_t __P((char *));
typedef int sh_strlist_map_func_t PARAMS((char *));
extern STRINGLIST *strlist_create __P((int));
extern STRINGLIST *strlist_resize __P((STRINGLIST *, int));
extern void strlist_flush __P((STRINGLIST *));
extern void strlist_dispose __P((STRINGLIST *));
extern int strlist_remove __P((STRINGLIST *, char *));
extern STRINGLIST *strlist_copy __P((STRINGLIST *));
extern STRINGLIST *strlist_merge __P((STRINGLIST *, STRINGLIST *));
extern STRINGLIST *strlist_append __P((STRINGLIST *, STRINGLIST *));
extern STRINGLIST *strlist_prefix_suffix __P((STRINGLIST *, char *, char *));
extern void strlist_print __P((STRINGLIST *, char *));
extern void strlist_walk __P((STRINGLIST *, sh_strlist_map_func_t *));
extern void strlist_sort __P((STRINGLIST *));
extern STRINGLIST *strlist_create PARAMS((int));
extern STRINGLIST *strlist_resize PARAMS((STRINGLIST *, int));
extern void strlist_flush PARAMS((STRINGLIST *));
extern void strlist_dispose PARAMS((STRINGLIST *));
extern int strlist_remove PARAMS((STRINGLIST *, char *));
extern STRINGLIST *strlist_copy PARAMS((STRINGLIST *));
extern STRINGLIST *strlist_merge PARAMS((STRINGLIST *, STRINGLIST *));
extern STRINGLIST *strlist_append PARAMS((STRINGLIST *, STRINGLIST *));
extern STRINGLIST *strlist_prefix_suffix PARAMS((STRINGLIST *, char *, char *));
extern void strlist_print PARAMS((STRINGLIST *, char *));
extern void strlist_walk PARAMS((STRINGLIST *, sh_strlist_map_func_t *));
extern void strlist_sort PARAMS((STRINGLIST *));
/* declarations for functions defined in lib/sh/stringvec.c */
extern char **strvec_create __P((int));
extern char **strvec_resize __P((char **, int));
extern char **strvec_mcreate __P((int));
extern char **strvec_mresize __P((char **, int));
extern void strvec_flush __P((char **));
extern void strvec_dispose __P((char **));
extern int strvec_remove __P((char **, char *));
extern int strvec_len __P((char **));
extern int strvec_search __P((char **, char *));
extern char **strvec_copy __P((char **));
extern int strvec_posixcmp __P((char **, char **));
extern int strvec_strcmp __P((char **, char **));
extern void strvec_sort __P((char **, int));
extern char **strvec_create PARAMS((int));
extern char **strvec_resize PARAMS((char **, int));
extern char **strvec_mcreate PARAMS((int));
extern char **strvec_mresize PARAMS((char **, int));
extern void strvec_flush PARAMS((char **));
extern void strvec_dispose PARAMS((char **));
extern int strvec_remove PARAMS((char **, char *));
extern int strvec_len PARAMS((char **));
extern int strvec_search PARAMS((char **, char *));
extern char **strvec_copy PARAMS((char **));
extern int strvec_posixcmp PARAMS((char **, char **));
extern int strvec_strcmp PARAMS((char **, char **));
extern void strvec_sort PARAMS((char **, int));
extern char **strvec_from_word_list __P((WORD_LIST *, int, int, int *));
extern WORD_LIST *strvec_to_word_list __P((char **, int, int));
extern char **strvec_from_word_list PARAMS((WORD_LIST *, int, int, int *));
extern WORD_LIST *strvec_to_word_list PARAMS((char **, int, int));
/* declarations for functions defined in lib/sh/strnlen.c */
#if !defined (HAVE_STRNLEN)
extern size_t strnlen __P((const char *, size_t));
extern size_t strnlen PARAMS((const char *, size_t));
#endif
/* declarations for functions defined in lib/sh/strpbrk.c */
#if !defined (HAVE_STRPBRK)
extern char *strpbrk __P((const char *, const char *));
extern char *strpbrk PARAMS((const char *, const char *));
#endif
/* declarations for functions defined in lib/sh/strtod.c */
#if !defined (HAVE_STRTOD)
extern double strtod __P((const char *, char **));
extern double strtod PARAMS((const char *, char **));
#endif
/* declarations for functions defined in lib/sh/strtol.c */
#if !HAVE_DECL_STRTOL
extern long strtol __P((const char *, char **, int));
extern long strtol PARAMS((const char *, char **, int));
#endif
/* declarations for functions defined in lib/sh/strtoll.c */
#if defined (HAVE_LONG_LONG) && !HAVE_DECL_STRTOLL
extern long long strtoll __P((const char *, char **, int));
extern long long strtoll PARAMS((const char *, char **, int));
#endif
/* declarations for functions defined in lib/sh/strtoul.c */
#if !HAVE_DECL_STRTOUL
extern unsigned long strtoul __P((const char *, char **, int));
extern unsigned long strtoul PARAMS((const char *, char **, int));
#endif
/* declarations for functions defined in lib/sh/strtoull.c */
#if defined (HAVE_LONG_LONG) && !HAVE_DECL_STRTOULL
extern unsigned long long strtoull __P((const char *, char **, int));
extern unsigned long long strtoull PARAMS((const char *, char **, int));
#endif
/* declarations for functions defined in lib/sh/strimax.c */
#if !HAVE_DECL_STRTOIMAX
extern intmax_t strtoimax __P((const char *, char **, int));
extern intmax_t strtoimax PARAMS((const char *, char **, int));
#endif
/* declarations for functions defined in lib/sh/strumax.c */
#if !HAVE_DECL_STRTOUMAX
extern uintmax_t strtoumax __P((const char *, char **, int));
extern uintmax_t strtoumax PARAMS((const char *, char **, int));
#endif
/* declarations for functions defined in lib/sh/strtrans.c */
extern char *ansicstr __P((char *, int, int, int *, int *));
extern char *ansic_quote __P((char *, int, int *));
extern int ansic_shouldquote __P((const char *));
extern char *ansiexpand __P((char *, int, int, int *));
extern char *ansicstr PARAMS((char *, int, int, int *, int *));
extern char *ansic_quote PARAMS((char *, int, int *));
extern int ansic_shouldquote PARAMS((const char *));
extern char *ansiexpand PARAMS((char *, int, int, int *));
/* declarations for functions defined in lib/sh/timeval.c. No prototypes
so we don't have to count on having a definition of struct timeval in
@@ -475,67 +475,67 @@ extern void print_timeval ();
#define MT_USERANDOM 0x0004
#define MT_TEMPLATE 0x0008
extern char *sh_mktmpname __P((char *, int));
extern int sh_mktmpfd __P((char *, int, char **));
/* extern FILE *sh_mktmpfp __P((char *, int, char **)); */
extern char *sh_mktmpdir __P((char *, int));
extern char *sh_mktmpname PARAMS((char *, int));
extern int sh_mktmpfd PARAMS((char *, int, char **));
/* extern FILE *sh_mktmpfp PARAMS((char *, int, char **)); */
extern char *sh_mktmpdir PARAMS((char *, int));
/* declarations for functions defined in lib/sh/uconvert.c */
extern int uconvert __P((char *, long *, long *, char **));
extern int uconvert PARAMS((char *, long *, long *, char **));
/* declarations for functions defined in lib/sh/ufuncs.c */
extern unsigned int falarm __P((unsigned int, unsigned int));
extern unsigned int fsleep __P((unsigned int, unsigned int));
extern unsigned int falarm PARAMS((unsigned int, unsigned int));
extern unsigned int fsleep PARAMS((unsigned int, unsigned int));
/* declarations for functions defined in lib/sh/unicode.c */
extern int u32cconv __P((unsigned long, char *));
extern void u32reset __P((void));
extern int u32cconv PARAMS((unsigned long, char *));
extern void u32reset PARAMS((void));
/* declarations for functions defined in lib/sh/utf8.c */
extern char *utf8_mbschr __P((const char *, int));
extern int utf8_mbscmp __P((const char *, const char *));
extern char *utf8_mbsmbchar __P((const char *));
extern int utf8_mbsnlen __P((const char *, size_t, int));
extern int utf8_mblen __P((const char *, size_t));
extern size_t utf8_mbstrlen __P((const char *));
extern char *utf8_mbschr PARAMS((const char *, int));
extern int utf8_mbscmp PARAMS((const char *, const char *));
extern char *utf8_mbsmbchar PARAMS((const char *));
extern int utf8_mbsnlen PARAMS((const char *, size_t, int));
extern int utf8_mblen PARAMS((const char *, size_t));
extern size_t utf8_mbstrlen PARAMS((const char *));
/* declarations for functions defined in lib/sh/wcsnwidth.c */
#if defined (HANDLE_MULTIBYTE)
extern int wcsnwidth __P((const wchar_t *, size_t, int));
extern int wcsnwidth PARAMS((const wchar_t *, size_t, int));
#endif
/* declarations for functions defined in lib/sh/winsize.c */
extern void get_new_window_size __P((int, int *, int *));
extern void get_new_window_size PARAMS((int, int *, int *));
/* declarations for functions defined in lib/sh/zcatfd.c */
extern int zcatfd __P((int, int, char *));
extern int zcatfd PARAMS((int, int, char *));
/* declarations for functions defined in lib/sh/zgetline.c */
extern ssize_t zgetline __P((int, char **, size_t *, int, int));
extern ssize_t zgetline PARAMS((int, char **, size_t *, int, int));
/* declarations for functions defined in lib/sh/zmapfd.c */
extern int zmapfd __P((int, char **, char *));
extern int zmapfd PARAMS((int, char **, char *));
/* declarations for functions defined in lib/sh/zread.c */
extern ssize_t zread __P((int, char *, size_t));
extern ssize_t zreadretry __P((int, char *, size_t));
extern ssize_t zreadintr __P((int, char *, size_t));
extern ssize_t zreadc __P((int, char *));
extern ssize_t zreadcintr __P((int, char *));
extern ssize_t zreadn __P((int, char *, size_t));
extern void zreset __P((void));
extern void zsyncfd __P((int));
extern ssize_t zread PARAMS((int, char *, size_t));
extern ssize_t zreadretry PARAMS((int, char *, size_t));
extern ssize_t zreadintr PARAMS((int, char *, size_t));
extern ssize_t zreadc PARAMS((int, char *));
extern ssize_t zreadcintr PARAMS((int, char *));
extern ssize_t zreadn PARAMS((int, char *, size_t));
extern void zreset PARAMS((void));
extern void zsyncfd PARAMS((int));
/* declarations for functions defined in lib/sh/zwrite.c */
extern int zwrite __P((int, char *, size_t));
extern int zwrite PARAMS((int, char *, size_t));
/* declarations for functions defined in lib/glob/gmisc.c */
extern int match_pattern_char __P((char *, char *, int));
extern int umatchlen __P((char *, size_t));
extern int match_pattern_char PARAMS((char *, char *, int));
extern int umatchlen PARAMS((char *, size_t));
#if defined (HANDLE_MULTIBYTE)
extern int match_pattern_wchar __P((wchar_t *, wchar_t *, int));
extern int wmatchlen __P((wchar_t *, size_t));
extern int match_pattern_wchar PARAMS((wchar_t *, wchar_t *, int));
extern int wmatchlen PARAMS((wchar_t *, size_t));
#endif
#endif /* _EXTERNS_H_ */
+1 -1
View File
@@ -4,7 +4,7 @@
/* ``Have a little faith, there's magic in the night. You ain't a
beauty, but, hey, you're alright.'' */
/* Copyright (C) 1987-2019 Free Software Foundation, Inc.
/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+2 -2
View File
@@ -147,8 +147,8 @@ expect 20
20
expect 5 20
5 20
expect 5 30
5 30
expect 5 20
5 20
expect 2 40
2 40
expect 5 20
+1 -1
View File
@@ -36,7 +36,7 @@ echo expect 5 20
func
echo $? $var
echo expect 5 30
echo expect 5 20
var=30 func
echo $? $var
+2 -2
View File
@@ -465,10 +465,10 @@ declare -n ref="var"
declare -a var=([0]="Y")
declare -- ref="Y"
declare -- var="X"
ref=Y
declare -- ref="Y"
declare -- ref="Y"
./nameref20.sub: line 74: declare: var: not found
ref=Y
declare -- ref="Y"
declare -n ref="var"
declare -A var=([2]="" )
declare -n ref="var"
+7 -7
View File
@@ -153,17 +153,17 @@ outside: declare -- var="outside"
outside 1.0: var=one
outside 1.1: var=one
inside func: var=two
outside 2.0: var=two
outside 2.0: var=<unset>
inside func: var=two
outside 2.1: var=two
outside 2.1: var=global
inside func1: var=value
outside 3.0: var=value
inside func2: var=global
outside 4.0: var=outside
foo: hello world
after foo: var=outside
after foo: var=global
bar: hello world
after bar: var=bar: hello world
after bar: var=global
./varenv13.sub: line 16: `var[0]': not a valid identifier
./varenv13.sub: line 16: `var[@]': not a valid identifier
./varenv13.sub: line 14: declare: var: not found
@@ -231,12 +231,12 @@ foo=showfoo environment foo=showfoo
outside 1.0: foo=<unset>
foo=showfoo environment foo=showfoo
foo=showfoo environment foo=showfoo
outside 1.1: foo=foo
outside 1.1: foo=<unset>
foo=<unset> environment foo=
outside 2.0: foo=<unset>
foo=foo environment foo=foo
foo=foo environment foo=foo
outside 2.1: foo=foo
foo=<unset> environment foo=
outside 2.1: foo=<unset>
a=z
a=b
a=z
+9
View File
@@ -539,6 +539,15 @@ any_signals_trapped ()
return -1;
}
void
clear_pending_traps ()
{
register int i;
for (i = 1; i < NSIG; i++)
pending_traps[i] = 0;
}
void
check_signals ()
{
+1
View File
@@ -117,6 +117,7 @@ extern int signal_in_progress PARAMS((int));
extern int next_pending_trap PARAMS((int));
extern int first_pending_trap PARAMS((void));
extern void clear_pending_traps PARAMS((void));
extern int any_signals_trapped PARAMS((void));
extern void check_signals PARAMS((void));
extern void check_signals_and_traps PARAMS((void));
+10 -16
View File
@@ -4643,13 +4643,19 @@ push_posix_temp_var (data)
binding_table = v->context ? shell_variables->table : global_variables->table;
/* global variables are no longer temporary and don't need propagating. */
if (binding_table == global_variables->table)
if (v->context == 0)
var->attributes &= ~(att_tempvar|att_propagate);
if (v)
{
v->attributes |= var->attributes;
v->attributes &= ~att_tempvar; /* not a temp var now */
v->attributes |= var->attributes; /* preserve tempvar attribute if appropriate */
/* If we don't bind a local variable, propagate the value. If we bind a
local variable (the "current execution environment"), keep it as local
and don't propagate it to the calling environment. */
if (v->context > 0 && local_p (v) == 0)
v->attributes |= att_propagate;
else
v->attributes &= ~att_propagate;
}
if (find_special_var (var->name) >= 0)
@@ -5299,11 +5305,7 @@ push_var_context (name, flags, tempvars)
functions no longer behave like assignment statements preceding
special builtins, and do not persist in the current shell environment.
This is austin group interp #654, though nobody implements it yet. */
#if 0 /* XXX - TAG: bash-5.1 */
posix_func_behavior = 0;
#else
posix_func_behavior = posixly_correct;
#endif
vc = new_var_context (name, flags);
/* Posix interp 1009, temporary assignments preceding function calls modify
@@ -5349,17 +5351,11 @@ push_posix_tempvar_internal (var, isbltin)
functions no longer behave like assignment statements preceding
special builtins, and do not persist in the current shell environment.
This is austin group interp #654, though nobody implements it yet. */
#if 0 /* XXX - TAG: bash-5.1 */
posix_var_behavior = posixly_correct && isbltin;
#else
posix_var_behavior = posixly_correct;
#endif
v = 0;
if (local_p (var) && STREQ (var->name, "-"))
set_current_options (value_cell (var));
#if 0 /* TAG: bash-5.1 */
/* This takes variable assignments preceding special builtins that can execute
multiple commands (source, eval, etc.) and performs the equivalent of
an assignment statement to modify the closest enclosing variable (the
@@ -5375,12 +5371,10 @@ push_posix_tempvar_internal (var, isbltin)
v->attributes |= var->attributes;
if (v->context == 0)
v->attributes &= ~(att_tempvar|att_propagate);
/* XXX - set att_propagate here if v->context > 0? */
}
}
else if (tempvar_p (var) && propagate_p (var))
#else
else if (tempvar_p (var) && (posix_var_behavior || (var->attributes & att_propagate)))
#endif
{
/* Make sure we have a hash table to store the variable in while it is
being propagated down to the global variables table. Create one if