fix nofork comsub overwriting currently executing command; free readline undo list on signal in callback mode; avoid disabling readonly when assigning variables from the environment; fix bug with shell-expand-line and $'...' quoting inside command substitutions; add `bash-vi-complete' as bindable command name

This commit is contained in:
Chet Ramey
2024-02-09 10:30:02 -05:00
parent 35465406cd
commit dc97ded434
40 changed files with 201 additions and 88 deletions
+52
View File
@@ -8503,3 +8503,55 @@ builtins/printf.def
- PRETURN: clean up vbuf only if vflag is set, and clean it up on
error (it would get cleaned up on the next call, but...)
Fixes from Grisha Levit <grishalevit@gmail.com>
2/2
---
doc/bash.1,doc/bashref.texi
- word expansions: make it clearer that quote removal is one of the
shell word expansions
execute_cmd.c,execute_cmd.h
- currently_executing_command: no longer static, so other parts of
the shell can save and restore it if necessary
subst.c
- function_substitute: unwind-protect currently_executing_command,
since parse_and_execute can overwrite it in the current shell
execution context.
Report from Grisha Levit <grishalevit@gmail.com>
lib/readline/readline.c
- readline_common_teardown: new function from the guts of
readline_internal_teardown, manages and deallocates rl_undo_list.
lib/readline/callback.c
- rl_callback_handler_remove: if we're removing the line handler
while we still have an undo list, we didn't call
readline_internal_teardown. Call readline_common_teardown to manage
the undo list in case we are calling this from a signal handler
but not exiting the program.
Fixes leaks reported by sparrowhawk996@gmail.com.
variables.c
- initialize_shell_variables: use ASS_FORCE when binding SHELLOPTS or
BASHOPTS if we get them from the environment, in case they've
already been created as shell variables and set to readonly (like
changes from 1/30)
- set_ppid: use ASS_FORCE in the call to bind_variable instead of
temporarily turning off att_readonly
subst.c
- extract_delimited_string: pass FLAGS down to skip_single_quoted and
skip_double_quoted so we propagate SX_COMMAND and SX_COMPLETE
properly.
Fixes bug reported by A4-Tacks <wdsjxhno1001@163.com>
2/3
---
bashline.c
- initialize_readline: add `bash-vi-complete' as a bindable command
name so users can bind other key sequences to it
- vi_advance_point: function to advance point by one character even
in the presence of multibyte characters
- bash_vi_complete: call vi_advance_point instead of just incrementing
rl_point
+1 -1
View File
@@ -1,6 +1,6 @@
# Makefile for bash-5.2, version 5.1
#
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
# Copyright (C) 1996-2024 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/* arrayfunc.c -- High-level array functions used by other parts of the shell. */
/* Copyright (C) 2001-2023 Free Software Foundation, Inc.
/* Copyright (C) 2001-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+33 -4
View File
@@ -1,6 +1,6 @@
/* bashline.c -- Bash's interface to the readline library. */
/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -606,6 +606,7 @@ initialize_readline (void)
rl_bind_key_if_unbound_in_map ('@', posix_edit_macros, vi_movement_keymap);
# endif
rl_add_defun ("bash-vi-complete", bash_vi_complete, -1);
rl_bind_key_in_map ('\\', bash_vi_complete, vi_movement_keymap);
rl_bind_key_in_map ('*', bash_vi_complete, vi_movement_keymap);
rl_bind_key_in_map ('=', bash_vi_complete, vi_movement_keymap);
@@ -4012,10 +4013,38 @@ bash_specific_completion (int what_to_do, rl_compentry_func_t *generator)
#endif /* SPECIFIC_COMPLETION_FUNCTIONS */
#if defined (VI_MODE)
/* This does pretty much what _rl_vi_advance_point does. */
static inline int
vi_advance_point (void)
{
int point;
DECLARE_MBSTATE;
point = rl_point;
if (rl_point < rl_end)
#if defined (HANDLE_MULTIBYTE)
{
if (locale_mb_cur_max == 1)
rl_point++;
else
{
point = rl_point;
ADVANCE_CHAR (rl_line_buffer, rl_end, rl_point);
if (point == rl_point || rl_point > rl_end)
rl_point = rl_end;
}
}
#else
rl_point++:
#endif
return point;
}
/* Completion, from vi mode's point of view. This is a modified version of
rl_vi_complete which uses the bash globbing code to implement what POSIX
specifies, which is to append a `*' and attempt filename generation (which
has the side effect of expanding any globbing characters in the word). */
specifies, which is to optinally append a `*' and attempt filename
generation (which has the side effect of expanding any globbing characters
in the word). */
static int
bash_vi_complete (int count, int key)
{
@@ -4027,7 +4056,7 @@ bash_vi_complete (int count, int key)
{
if (!whitespace (rl_line_buffer[rl_point + 1]))
rl_vi_end_word (1, 'E');
rl_point++;
vi_advance_point ();
}
/* Find boundaries of current word, according to vi definition of a
+2 -2
View File
@@ -1,7 +1,7 @@
/* braces.c -- code for doing word expansion in curly braces. */
/* Copyright (C) 1987-2020,2022-2023 Free Software Foundation, Inc.
/* Copyright (C) 1987-2020,2022-2024 Free Software Foundation, Inc.
`
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software: you can redistribute it and/or modify
+1 -1
View File
@@ -1,7 +1,7 @@
This file is cd.def, from which is created cd.c. It implements the
builtins "cd" and "pwd" in Bash.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,7 +1,7 @@
This file is hash.def, from which is created hash.c.
It implements the builtin "hash" in Bash.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -175,7 +175,7 @@ extern int errno;
nw = vflag ? vbprintf (f, precision, func) : printf (f, precision, func); \
else \
nw = vflag ? vbprintf (f, func) : printf (f, func); \
if (nw < 0 || ferror (stdout)) \
if (nw < 0 || (vflag == 0 && ferror (stdout))) \
{ \
QUIT; \
if (vflag) \
+1 -1
View File
@@ -1,7 +1,7 @@
This file is set.def, from which is created set.c.
It implements the "set" and "unset" builtins in Bash.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,7 +1,7 @@
This file is shopt.def, from which is created shopt.c.
It implements the Bash `shopt' builtin.
Copyright (C) 1994-2023 Free Software Foundation, Inc.
Copyright (C) 1994-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,7 +1,7 @@
This file is ulimit.def, from which is created ulimit.c.
It implements the builtin "ulimit" in Bash.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,7 +1,7 @@
This file is wait.def, from which is created wait.c.
It implements the builtin "wait" in Bash.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+13 -8
View File
@@ -5,14 +5,14 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Thu Jan 18 11:41:18 EST 2024
.\" Last Change: Fri Feb 2 09:38:21 EST 2024
.\"
.\" bash_builtins, strip all but Built-Ins section
.\" avoid a warning about an undefined register
.\" .if !rzY .nr zY 0
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2024 January 18" "GNU Bash 5.3"
.TH BASH 1 "2024 February 2" "GNU Bash 5.3"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -2978,22 +2978,24 @@ builtins display array values in a way that allows them to be
reused as assignments.
.SH EXPANSION
Expansion is performed on the command line after it has been split into
words. There are seven kinds of expansion performed:
words. The shell performs these expansions:
.IR "brace expansion" ,
.IR "tilde expansion" ,
.IR "parameter and variable expansion" ,
.IR "command substitution" ,
.IR "arithmetic expansion" ,
.IR "word splitting" ,
.IR "pathname expansion" ,
and
.IR "pathname expansion" .
.IR "quote removal .
.PP
The order of expansions is:
brace expansion;
tilde expansion, parameter and variable expansion, arithmetic expansion,
and command substitution (done in a left-to-right fashion);
word splitting;
and pathname expansion.
pathname expansion;
and quote removal.
.PP
On systems that can support it, there is an additional expansion
available: \fIprocess substitution\fP.
@@ -3001,9 +3003,10 @@ This is performed at the
same time as tilde, parameter, variable, and arithmetic expansion and
command substitution.
.PP
After these expansions are performed, quote characters present in the
original word are removed unless they have been quoted themselves
(\fIquote removal\fP).
\fIQuote removal\fP is always performed last.
It removes quote characters present in the original word,
not ones resulting from one of the other expansions,
unless they have been quoted themselves.
.PP
Only brace expansion, word splitting, and pathname expansion
can increase the number of words of the expansion; other expansions
@@ -6825,7 +6828,9 @@ Expand the line by performing shell word expansions.
This performs alias and history expansion,
\fB$\fP\(aq\fIstring\fP\(aq and \fB$\fP\(dq\fIstring\fP\(dq quoting,
tilde expansion, parameter and variable expansion, arithmetic expansion,
command and process substitution,
word splitting, and quote removal.
An explicit argument suppresses command and process substitution.
See
.SM
.B HISTORY EXPANSION
+11 -6
View File
@@ -1911,7 +1911,8 @@ to the filename used to invoke Bash, as given by argument zero.
@cindex expansion
Expansion is performed on the command line after it has been split into
@code{token}s. There are seven kinds of expansion performed:
@code{token}s.
Bash performs these expansions:
@itemize @bullet
@item brace expansion
@@ -1921,6 +1922,7 @@ Expansion is performed on the command line after it has been split into
@item arithmetic expansion
@item word splitting
@item filename expansion
@item quote removal
@end itemize
@menu
@@ -1943,7 +1945,8 @@ brace expansion;
tilde expansion, parameter and variable expansion, arithmetic expansion,
and command substitution (done in a left-to-right fashion);
word splitting;
and filename expansion.
filename expansion;
and quote removal.
On systems that can support it, there is an additional expansion
available: @dfn{process substitution}.
@@ -1951,9 +1954,11 @@ This is performed at the
same time as tilde, parameter, variable, and arithmetic expansion and
command substitution.
After these expansions are performed, quote characters present in the
original word are removed unless they have been quoted themselves
(@dfn{quote removal}). @xref{Quote Removal} for more details.
@dfn{Quote removal} is always performed last.
It removes quote characters present in the original word,
not ones resulting from one of the other expansions,
unless they have been quoted themselves.
@xref{Quote Removal} for more details.
Only brace expansion, word splitting, and filename expansion
can increase the number of words of the expansion; other expansions
@@ -3900,7 +3905,7 @@ If @var{directory} is not supplied, the value of the @env{HOME}
shell variable is used.
If the shell variable
@env{CDPATH} exists, @code{cd} uses it as a search path:
{cd} searches each directory name in @env{CDPATH} for
@code{cd} searches each directory name in @env{CDPATH} for
@var{directory}, with alternative directory names in @env{CDPATH}
separated by a colon (@samp{:}).
If @var{directory} begins with a slash, @env{CDPATH} is not used.
+3 -3
View File
@@ -2,10 +2,10 @@
Copyright (C) 1988-2024 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Mon Jan 15 13:13:50 EST 2024
@set LASTCHANGE Fri Feb 2 09:37:55 EST 2024
@set EDITION 5.3
@set VERSION 5.3
@set UPDATED 15 January 2024
@set UPDATED-MONTH January 2024
@set UPDATED 2 February 2024
@set UPDATED-MONTH February 2024
+4 -3
View File
@@ -1,6 +1,6 @@
/* execute_cmd.c -- Execute a COMMAND structure. */
/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -207,6 +207,9 @@ char *this_command_name;
a debugger to know where exactly the program is currently executing. */
char *the_printed_command_except_trap;
/* Used to compute the correct line number. */
COMMAND *currently_executing_command;
/* For catching RETURN in a function. */
int return_catch_flag;
int return_catch_value;
@@ -267,8 +270,6 @@ struct stat SB; /* used for debugging */
static int special_builtin_failed;
static COMMAND *currently_executing_command;
/* The line number that the currently executing function starts on. */
static int function_line_number;
+1
View File
@@ -63,6 +63,7 @@ extern int stdin_redir;
extern int line_number_for_err_trap;
extern char *the_printed_command_except_trap;
extern COMMAND *currently_executing_command;
extern char *this_command_name;
extern SHELL_VAR *this_shell_function;
+1 -1
View File
@@ -1,7 +1,7 @@
/* externs.h -- extern function declarations which do not appear in their
own header file. */
/* Copyright (C) 1993-2023 Free Software Foundation, Inc.
/* Copyright (C) 1993-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,6 +1,6 @@
/* general.c -- Stuff that is used by all files. */
/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -3,7 +3,7 @@
/* This file works with both POSIX and BSD systems. It implements job
control. */
/* Copyright (C) 1989-2023 Free Software Foundation, Inc.
/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,6 +1,6 @@
/* jobs.h -- structures and definitions used by the jobs.c file. */
/* Copyright (C) 1993-2023 Free Software Foundation, Inc.
/* Copyright (C) 1993-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+10 -1
View File
@@ -1,6 +1,6 @@
/* callback.c -- functions to use readline as an X `callback' mechanism. */
/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -323,6 +323,15 @@ rl_callback_handler_remove (void)
rl_linefunc = NULL;
RL_UNSETSTATE (RL_STATE_CALLBACK);
RL_CHECK_SIGNALS ();
/* Do what we need to do to manage the undo list if we haven't already done
it in rl_callback_read_char(). If there's no undo list, we don't need to
do anything. It doesn't matter if we try to revert all previous lines a
second time; none of the history entries will have an undo list. */
if (rl_undo_list)
readline_common_teardown ();
/* At this point, rl_undo_list == NULL. */
if (in_handler)
{
in_handler = 0;
+1 -1
View File
@@ -1,6 +1,6 @@
/* complete.c -- filename completion for readline. */
/* Copyright (C) 1987-2022,2023 Free Software Foundation, Inc.
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
+5 -1
View File
@@ -1,5 +1,7 @@
@comment %**start of header (This is for running Texinfo on a region.)
@ifclear BashFeatures
@setfilename rluser.info
@end ifclear
@comment %**end of header (This is for running Texinfo on a region.)
@ignore
@@ -1874,8 +1876,10 @@ Display version information about the current instance of Bash.
Expand the line by performing shell word expansions.
This performs alias and history expansion,
$'@var{string}' and $"@var{string}" quoting,
tilde expansion, parameter and variable expansion, arithmetic expansion,
tilde expansion, parameter and variable expansion, arithmetic expansion,
command and proces substitution,
word splitting, and quote removal.
An explicit argument suppresses command and process substitution.
@item history-expand-line (M-^)
Perform history expansion on the current line.
+1 -1
View File
@@ -1,6 +1,6 @@
/* misc.c -- miscellaneous bindable readline functions. */
/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
+13 -7
View File
@@ -474,17 +474,12 @@ readline_internal_setup (void)
RL_CHECK_SIGNALS ();
}
STATIC_CALLBACK char *
readline_internal_teardown (int eof)
STATIC_CALLBACK void
readline_common_teardown (void)
{
char *temp;
HIST_ENTRY *entry;
RL_CHECK_SIGNALS ();
if (eof)
RL_SETSTATE (RL_STATE_EOF); /* XXX */
/* Restore the original of this history line, iff the line that we
are editing was originally in the history, AND the line has changed. */
entry = current_history ();
@@ -510,6 +505,17 @@ readline_internal_teardown (int eof)
rid of it now. */
if (rl_undo_list)
rl_free_undo_list ();
}
STATIC_CALLBACK char *
readline_internal_teardown (int eof)
{
RL_CHECK_SIGNALS ();
if (eof)
RL_SETSTATE (RL_STATE_EOF); /* XXX */
readline_common_teardown ();
/* Disable the meta key, if this terminal has one and we were told to use it.
The check whether or not we sent the enable string is in
+1 -1
View File
@@ -1,6 +1,6 @@
/* Readline.h -- the names of functions callable from within readline. */
/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
+3 -2
View File
@@ -1,7 +1,7 @@
/* rlprivate.h -- functions and variables global to the readline library,
but not intended for use by applications. */
/* Copyright (C) 1999-2023 Free Software Foundation, Inc.
/* Copyright (C) 1999-2024 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -270,10 +270,11 @@ extern char *_rl_savestring (const char *);
* Undocumented private functions *
*************************************************************************/
#if defined(READLINE_CALLBACKS)
#if defined (READLINE_CALLBACKS)
/* readline.c */
extern void readline_internal_setup (void);
extern void readline_common_teardown (void);
extern char *readline_internal_teardown (int);
extern int readline_internal_char (void);
+1 -1
View File
@@ -1,6 +1,6 @@
/* search.c - code for non-incremental searching in emacs and vi modes. */
/* Copyright (C) 1992-2023 Free Software Foundation, Inc.
/* Copyright (C) 1992-2024 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
+1 -1
View File
@@ -1,6 +1,6 @@
/* signals.c -- signal handling support for readline. */
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
+1 -1
View File
@@ -1,6 +1,6 @@
/* text.c -- text handling commands for readline. */
/* Copyright (C) 1987-2021,2023 Free Software Foundation, Inc.
/* Copyright (C) 1987-2021,2023-2024 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
+1 -1
View File
@@ -1,6 +1,6 @@
/* eaccess.c - eaccess replacement for the shell, plus other access functions. */
/* Copyright (C) 2006-2020,2022-2023 Free Software Foundation, Inc.
/* Copyright (C) 2006-2020,2022-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -2,7 +2,7 @@
* tmpfile.c - functions to create and safely open temp files for the shell.
*/
/* Copyright (C) 2000-2020,2022-2023 Free Software Foundation, Inc.
/* Copyright (C) 2000-2020,2022-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,6 +1,6 @@
/* parse.y - Yacc grammar for bash. */
/* Copyright (C) 1989-2023 Free Software Foundation, Inc.
/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,6 +1,6 @@
/* print_command -- A way to make readable commands from a command tree. */
/* Copyright (C) 1989-2023 Free Software Foundation, Inc.
/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,6 +1,6 @@
/* redir.c -- Functions to perform input and output redirection. */
/* Copyright (C) 1997-2023 Free Software Foundation, Inc.
/* Copyright (C) 1997-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,6 +1,6 @@
/* shell.c -- GNU's idea of the POSIX shell specification. */
/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+17 -10
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-2023 Free Software Foundation, Inc.
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -1299,15 +1299,20 @@ extract_arithmetic_subst (const char *string, size_t *sindex)
char *
extract_process_subst (const char *string, char *starter, size_t *sindex, int xflags)
{
char *ret;
char *xstr;
#if 0
/* XXX - check xflags&SX_COMPLETE here? */
return (extract_delimited_string (string, sindex, starter, "(", ")", SX_COMMAND));
if (flags & SX_COMPLETE)
return (extract_delimited_string (string, sindex, starter, "(", ")", SX_COMMAND));
else
#else
char *xstr;
xflags |= (no_longjmp_on_fatal_error ? SX_NOLONGJMP : 0);
xstr = (char *)string + *sindex;
return (xparse_dolparen (string, xstr, sindex, xflags));
{
xflags |= (no_longjmp_on_fatal_error ? SX_NOLONGJMP : 0);
xstr = (char *)string + *sindex;
ret = xparse_dolparen (string, xstr, sindex, xflags);
return ret;
}
#endif
}
#endif /* PROCESS_SUBSTITUTION */
@@ -1344,7 +1349,7 @@ extract_array_assignment_list (const char *string, size_t *sindex)
static char *
extract_delimited_string (const char *string, size_t *sindex, char *opener, char *alt_opener, char *closer, int flags)
{
int c;
int c, xflags;
size_t i, si, slen;
char *t, *result;
int pass_character, nesting_level, in_comment;
@@ -1472,8 +1477,8 @@ extract_delimited_string (const char *string, size_t *sindex, char *opener, char
if (c == '\'' || c == '"')
{
si = i + 1;
i = (c == '\'') ? skip_single_quoted (string, slen, si, 0)
: skip_double_quoted (string, slen, si, 0);
i = (c == '\'') ? skip_single_quoted (string, slen, si, flags)
: skip_double_quoted (string, slen, si, flags);
continue;
}
@@ -6917,6 +6922,7 @@ function_substitute (char *string, int quoted, int flags)
unwind_protect_pointer (this_shell_function);
unwind_protect_pointer (this_shell_builtin);
unwind_protect_pointer (current_builtin);
unwind_protect_pointer (currently_executing_command);
unwind_protect_int (eof_encountered);
add_unwind_protect (uw_pop_var_context, 0);
add_unwind_protect (uw_maybe_restore_getopt_state, gs);
@@ -6992,6 +6998,7 @@ function_substitute (char *string, int quoted, int flags)
remove_quoted_escapes (string);
currently_executing_command = NULL;
executing_funsub++;
if (expand_aliases)
expand_aliases = posixly_correct == 0;
+1 -1
View File
@@ -2,7 +2,7 @@
/* Modified to run with the GNU shell Apr 25, 1988 by bfox. */
/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+8 -15
View File
@@ -503,25 +503,18 @@ initialize_shell_variables (char **env, int privmode)
# endif /* ARRAY_EXPORT */
#endif
{
ro = 0;
/* If we processed a command-line option that caused SHELLOPTS to be
set, it may already be set (and read-only) by the time we process
the shell's environment. */
if (/* posixly_correct &&*/ STREQ (name, "SHELLOPTS"))
{
temp_var = find_variable ("SHELLOPTS");
ro = temp_var && readonly_p (temp_var);
if (temp_var)
VUNSETATTR (temp_var, att_readonly);
}
/* If we processed a command-line option that caused SHELLOPTS or
BASHOPTS to be set, it may already be set (and read-only) by the
time we process the shell's environment. */
ro = STREQ (name, "SHELLOPTS") || STREQ (name, "BASHOPTS");
if (valid_identifier (name))
{
temp_var = bind_variable (name, string, 0);
temp_var = bind_variable (name, string, ro ? ASS_FORCE : 0);
if (temp_var)
{
VSETATTR (temp_var, (att_exported | att_imported));
if (ro)
VSETATTR (temp_var, att_readonly);
VSETATTR (temp_var, att_readonly); /* just make sure */
}
}
else
@@ -981,8 +974,8 @@ set_ppid (void)
name = inttostr (getppid (), namebuf, sizeof(namebuf));
temp_var = find_variable ("PPID");
if (temp_var)
VUNSETATTR (temp_var, (att_readonly | att_exported));
temp_var = bind_variable ("PPID", name, 0);
VUNSETATTR (temp_var, att_exported);
temp_var = bind_variable ("PPID", name, ASS_FORCE);
VSETATTR (temp_var, (att_readonly | att_integer));
}