- read_builtin: check whether `delim' is not a newline before calling
check_read_input
Report from pourko2@tutamail.com
+
+builtins/read.def
+ - read_builtin: CHERI systems require that we update the unwind-protect
+ after every xrealloc, not just if the pointer changes
+ From https://savannah.gnu.org/bugs/?67586
+
+ 10/7
+ ----
+doc/bash.1,lib/readline/doc/readline.3,lib/readline/doc/history.3
+ - remove mention of Usenet and gnu.bash.bug. End of an era.
+
+lib/sh/gettimeofday.c
+ - gettimeofday: if we're replacing this function on a non-Windows
+ system, prefer clock_gettime (CLOCK_REALTIME, ...) if it's available
+ instead of just filling in the seconds from time(3)
+
+ 10/9
+ ----
+lib/readline/text.c
+ - rl_insert: don't try to optimize runs of typeahead characters if we
+ are defining a keyboard macro
+ Report and patch from Grisha Levit <grishalevit@gmail.com>
+
+ 10/12
+ -----
+variables.c
+ - make_variable_value: make sure to check whether VALUE is non-NULL
+ before trying to strdup it; not all callers check
+ Report from Александр Ушаков <anushakov@edu.hse.ru>
+
+ 10/13riable`
+ -----
+builtins/declare.def
+ - declare_internal: if we are trying to set the attributes or value
+ for an unset nameref variable (attributes but no value), allow
+ the attribute or value setting to happen on the nameref, and don't
+ destroy the nameref variable on an assignment error
+ Report from Александр Ушаков <anushakov@edu.hse.ru>
+
+execute_cmd.c
+ - execute_for_command,eval_arith_for_expr,execute_select_command,
+ execute_case_command,execute_arith_command,execute_cond_command,
+ execute_simple_command: save and restore currently_executing_command
+ around calls to run_debug_trap the same way we do it for
+ run_return_trap
+ Report from Александр Ушаков <anushakov@edu.hse.ru>
*/
if (var == 0 && (mkglobal || flags_on || flags_off || offset))
{
- refvar = mkglobal ? find_global_variable_last_nameref (name, 0) : find_variable_last_nameref (name, 0);
+ refvar = mkglobal ? find_global_variable_last_nameref (name, 1) : find_variable_last_nameref (name, 1);
if (refvar && nameref_p (refvar) == 0)
refvar = 0;
- if (refvar)
+ /* If we are trying to set attributes for an unset nameref variable,
+ we have a couple of choices: we can set the attributes on the
+ nameref itself, or we can remove the nameref attribute from the
+ variable and treat it as an unset variable with the new
+ attribute(s). The former is what bash has traditionally done; the
+ latter is what ksh93 does. */
+ if (refvar && nameref_cell (refvar) == 0)
+ {
+ var = refvar;
+ refvar = 0;
+ }
+ if (refvar && nameref_cell (refvar))
var = declare_find_variable (nameref_cell (refvar), mkglobal, 0);
if (refvar && var == 0)
{
if (stat (filename, &finfo) == -1)
file_error (filename);
- fd = open (filename, O_RDONLY, 0666);
+ fd = open (filename, O_RDONLY);
if (fd == -1)
file_error (filename);
x = (char *)xrealloc (input_string, size += 128);
/* Only need to change unwind-protect if input_string changes */
+#ifndef __CHERI_PURE_CAPABILITY__
if (x != input_string)
+#endif
{
input_string = x;
remove_unwind_protect ();
Once you have determined that a bug actually exists, use the _\bb_\ba_\bs_\bh_\bb_\bu_\bg
command to submit a bug report. If you have a fix, you are encouraged
to mail that as well! You may send suggestions and "philosophical" bug
- reports to <bug-bash@gnu.org> or post them to the Usenet newsgroup g\bgn\bnu\bu
- .\b.b\bba\bas\bsh\bh.\b.b\bbu\bug\bg.
+ reports, as well as comments and bug reports concerning this manual
+ page, to to <bug-bash@gnu.org>.
_\bA_\bl_\bl bug reports should include:
_\bb_\ba_\bs_\bh_\bb_\bu_\bg inserts the first three items automatically into the template
it provides for filing a bug report.
- Please send comments and bug reports concerning this manual page to
- <bug-bash@gnu.org>.
-
B\bBU\bUG\bGS\bS
It's too big and too slow.
- There are some subtle differences between b\bba\bas\bsh\bh and historical versions
- of s\bsh\bh, due mostly to b\bba\bas\bsh\bh's independent implementation and the evolu-
+ There are some subtle differences between b\bba\bas\bsh\bh and historical versions
+ of s\bsh\bh, due mostly to b\bba\bas\bsh\bh's independent implementation and the evolu-
tion of the POSIX specification.
Aliases are confusing in some uses.
Shell builtin commands and functions are not stoppable/restartable.
- Compound commands and command lists of the form "a ; b ; c" are not
- handled gracefully when combined with process suspension. When a
- process is stopped, the shell immediately executes the next command in
- the list or breaks out of any existing loops. It suffices to enclose
- the command in parentheses to force it into a subshell, which may be
- stopped as a unit, or to start the command in the background and imme-
+ Compound commands and command lists of the form "a ; b ; c" are not
+ handled gracefully when combined with process suspension. When a
+ process is stopped, the shell immediately executes the next command in
+ the list or breaks out of any existing loops. It suffices to enclose
+ the command in parentheses to force it into a subshell, which may be
+ stopped as a unit, or to start the command in the background and imme-
diately bring it into the foreground.
Array variables may not (yet) be exported.
If you have a fix, you are encouraged to mail that as well!
You may send suggestions and
.Q philosophical
-bug reports to
+bug reports,
+as well as comments and bug reports concerning this manual page,
+to
+to
.MT bug\-bash@\*:gnu\*:.org
-.ME
-or post them to the
-Usenet
-newsgroup
-.BR gnu\*:.bash\*:.bug .
+.ME .
.PP
.I All
bug reports should include:
.I bashbug
inserts the first three items automatically into the template
it provides for filing a bug report.
-.PP
-Please send comments and bug reports concerning
-this manual page to
-.MT bug\-bash@\*:gnu\*:.org
-.ME .
.SH BUGS
It's too big and too slow.
.PP
<!-- Creator : groff version 1.23.0 -->
-<!-- CreationDate: Mon Oct 6 15:30:30 2025 -->
+<!-- CreationDate: Tue Oct 7 10:14:01 2025 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
determined that a bug actually exists, use the
<i>bashbug</i> command to submit a bug report. If you have a
fix, you are encouraged to mail that as well! You may send
-suggestions and “philosophical” bug reports to
-<a href="mailto:bug-bash@gnu.org">bug-bash@gnu.org</a> or
-post them to the Usenet newsgroup <b>gnu.bash.bug</b>.</p>
+suggestions and “philosophical” bug reports, as
+well as comments and bug reports concerning this manual
+page, to to
+<a href="mailto:bug-bash@gnu.org">bug-bash@gnu.org</a>.</p>
<p style="margin-left:9%; margin-top: 1em"><i>All</i> bug
reports should include:</p>
inserts the first three items automatically into the
template it provides for filing a bug report.</p>
-<p style="margin-left:9%; margin-top: 1em">Please send
-comments and bug reports concerning this manual page to
-<a href="mailto:bug-bash@gnu.org">bug-bash@gnu.org</a>.</p>
-
<h2>BUGS
<a name="BUGS"></a>
</h2>
fd = 0;
closefd = 0;
} else {
- fd = open(argv[i], O_RDONLY, 0666);
+ fd = open(argv[i], O_RDONLY);
if (fd < 0) {
s = strerror(errno);
write(2, "cat: cannot open ", 17);
{
WORD_LIST *releaser, *list;
SHELL_VAR *v;
+ COMMAND *save_current;
char *identifier;
int retval, save_line_number;
#if 0
the_printed_command_except_trap = savestring (the_printed_command);
}
+ save_current = currently_executing_command;
retval = run_debug_trap ();
+ currently_executing_command = save_current;
+
#if defined (DEBUGGER)
/* In debugging mode, if the DEBUG trap returns a non-zero status, we
skip the command. */
intmax_t expresult;
int r, eflag;
char *expr, *temp;
+ COMMAND *save_current;
expr = l->next ? string_list (l) : l->word->word;
temp = expand_arith_string (expr, Q_DOUBLE_QUOTES|Q_ARITH);
the_printed_command_except_trap = savestring (the_printed_command);
}
+ save_current = currently_executing_command;
r = run_debug_trap ();
+ currently_executing_command = save_current;
+
#if defined (DEBUGGER)
/* In debugging mode, if the DEBUG trap returns a non-zero status, we
skip the command. */
SHELL_VAR *v;
char *identifier, *ps3_prompt, *selection;
int retval, list_len, show_menu, save_line_number;
+ COMMAND *save_current;
if (check_identifier (select_command->name, 1) == 0)
{
the_printed_command_except_trap = savestring (the_printed_command);
}
+ save_current = currently_executing_command;
retval = run_debug_trap ();
+ currently_executing_command = save_current;
+
#if defined (DEBUGGER)
/* In debugging mode, if the DEBUG trap returns a non-zero status, we
skip the command. */
PATTERN_LIST *clauses;
char *word, *pattern;
int retval, match, ignore_return, save_line_number, qflags;
+ COMMAND *save_current;
save_line_number = line_number;
line_number = case_command->line;
the_printed_command_except_trap = savestring (the_printed_command);
}
+ save_current = currently_executing_command;
retval = run_debug_trap();
+ currently_executing_command = save_current;
+
#if defined (DEBUGGER)
/* In debugging mode, if the DEBUG trap returns a non-zero status, we
skip the command. */
intmax_t expresult;
WORD_LIST *new;
char *exp, *t;
+ COMMAND *save_current;
expresult = 0;
/* Run the debug trap before each arithmetic command, but do it after we
update the line number information and before we expand the various
words in the expression. */
+ save_current = currently_executing_command;
retval = run_debug_trap ();
+ currently_executing_command = save_current;
+
#if defined (DEBUGGER)
/* In debugging mode, if the DEBUG trap returns a non-zero status, we
skip the command. */
execute_cond_command (COND_COM *cond_command)
{
int retval, save_line_number;
+ COMMAND *save_current;
save_line_number = line_number;
/* Run the debug trap before each conditional command, but do it after we
update the line number information. */
+ save_current = currently_executing_command;
retval = run_debug_trap ();
+ currently_executing_command = save_current;
+
#if defined (DEBUGGER)
/* In debugging mode, if the DEBUG trap returns a non-zero status, we
skip the command. */
pid_t old_last_async_pid;
sh_builtin_func_t *builtin;
SHELL_VAR *func;
+ COMMAND *save_current;
volatile int old_builtin, old_command_builtin;
result = EXECUTION_SUCCESS;
/* Run the debug trap before each simple command, but do it after we
update the line number information. */
+ save_current = currently_executing_command;
result = run_debug_trap ();
+ currently_executing_command = save_current;
+
#if defined (DEBUGGER)
/* In debugging mode, if the DEBUG trap returns a non-zero status, we
skip the command. */
showing_function_line = 1;
save_current = currently_executing_command;
result = run_debug_trap ();
+ currently_executing_command = save_current;
#if defined (DEBUGGER)
/* In debugging mode, if the DEBUG trap returns a non-zero status, we
skip the command. */
if (debugging_mode == 0 || result == EXECUTION_SUCCESS)
{
showing_function_line = 0;
- currently_executing_command = save_current;
result = execute_command_internal (fc, 0, NO_PIPE, NO_PIPE, fds_to_close);
/* Run the RETURN trap in the function's context */
currently_executing_command = save_current;
}
#else
- currently_executing_command = save_current;
result = execute_command_internal (fc, 0, NO_PIPE, NO_PIPE, fds_to_close);
save_current = currently_executing_command;
char *buffer;
int i, file;
- file = open (filename, O_RDONLY, 0666);
+ file = open (filename, O_RDONLY);
/* If the open is interrupted, retry once */
if (file < 0 && errno == EINTR)
{
RL_CHECK_SIGNALS ();
- file = open (filename, O_RDONLY, 0666);
+ file = open (filename, O_RDONLY);
}
if ((file < 0) || (fstat (file, &finfo) < 0))
If you have a fix, you are welcome to mail that as well!
Please send suggestions and
.Q philosophical
-bug reports to
-.MT bug\-readline@\*:gnu\*:.org
-.ME
-or post them to the
-Usenet
-newsgroup
-.BR gnu\*:.bash\*:.bug .
-.PP
-Please send comments and bug reports concerning
-this manual page to
+bug reports,
+as well as comments and bug reports concerning this manual page,
+to
.MT bug\-readline@\*:gnu\*:.org
.ME .
If you have a fix, you are welcome to mail that as well!
Please send suggestions and
.Q philosophical
-bug reports
+bug reports,
+as well as comments and bug reports concerning this manual page,
to
.MT bug\-readline@\*:gnu\*:.org
-.ME
-or post them to the
-Usenet
-newsgroup
-.BR gnu\*:.bash\*:.bug .
-.PP
-Please send comments and bug reports concerning
-this manual page to
-.MT bug\-readline@\*:gnu\*:.org
.ME .
if (input == 0)
return 0;
errno = 0;
- file = open (input, O_RDONLY|O_BINARY, 0666);
+ file = open (input, O_RDONLY|O_BINARY);
if ((file < 0) || (fstat (file, &finfo) == -1))
goto error_and_exit;
if (filename == 0)
return 0;
tempname = 0;
- file = open (filename, O_RDONLY|O_BINARY, 0666);
+ file = open (filename, O_RDONLY|O_BINARY);
rv = exists = 0;
orig_lines = lines;
n = (unsigned short)-2;
while (_rl_optimize_typeahead &&
rl_num_chars_to_read == 0 &&
- (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) &&
+ (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT|RL_STATE_MACRODEF) == 0) &&
_rl_pushed_input_available () == 0 &&
_rl_input_queued (0) &&
(n = rl_read_key ()) > 0 &&
return 0;
#else /* !WINDOWS_NATIVE */
+# if defined (HAVE_CLOCK_GETTIME) && defined (CLOCK_REALTIME)
+ struct timespec ts;
+ int r;
+
+ r = clock_gettime (CLOCK_REALTIME, &ts);
+ if (r == 0)
+ {
+ TIMESPEC_TO_TIMEVAL(tv, &ts);
+ return 0;
+ }
+# endif /* !CLOCK_GETTIME */
tv->tv_sec = (time_t) time ((time_t *)0);
tv->tv_usec = 0;
/* In an attempt to avoid races, we close the first fd only after opening
the second. */
/* Make the document really temporary. Also make it the input. */
- fd2 = open (filename, O_RDONLY|O_BINARY, 0600);
+ fd2 = open (filename, O_RDONLY|O_BINARY);
if (fd2 < 0)
{
errno = e;
}
while (fd < 0 && errno == EINTR);
-
-#if 0 /* reportedly no longer needed */
-#if defined (AFS)
- if ((fd < 0) && (errno == EACCES))
- {
- fd = open (filename, flags & ~O_CREAT, mode);
- errno = EACCES; /* restore errno */
- }
-#endif /* AFS */
-#endif
}
return fd;
. ./test-aux-functions
# this locale causes problems all over the place
-if locale -a | grep -i '^zh_TW\.big5' >/dev/null ; then
- :
-else
+if [ -z "$ZH_LOCALE" ]; then
echo "glob2.sub: warning: you do not have the zh_TW.big5 locale installed;" >&2
echo "glob2.sub: warning: that may cause some of these tests to fail." >&2
+ ZH_LOCALE=$ZH_DEFAULT
fi
var='ab\'
[[ $var = $var ]] && echo ok 4
[[ $var = $'ab\134' ]] && echo ok 5
-LC_ALL=zh_TW.big5
+LC_ALL=$ZH_LOCALE
read a b c <<< $'\u3b1 b c\n'
echo $b
a=$'\u3b1'
[[ $a = $a ]] && echo ok 6
-LC_ALL=zh_TW.big5 ${THIS_SH} -c $'[[ \u3b1 = \u3b1 ]]' && echo ok 7
+LC_ALL=${ZH_LOCALE} ${THIS_SH} -c $'[[ \u3b1 = \u3b1 ]]' && echo ok 7
./nameref11.sub: line 14: declare: `/': invalid variable name for name reference
./nameref11.sub: line 15: declare: `/': invalid variable name for name reference
./nameref11.sub: line 16: `/': not a valid identifier
-./nameref11.sub: line 17: declare: `/': not a valid identifier
+./nameref11.sub: line 17: declare: `/': invalid variable name for name reference
./nameref11.sub: line 18: `/': not a valid identifier
1) /
#? ./nameref11.sub: line 19: `/': not a valid identifier
declare -n r
declare -a foo
declare -a foo=([0]="7")
-./nameref12.sub: line 39: declare: `42': not a valid identifier
-./nameref12.sub: line 40: declare: x: not found
+./nameref12.sub: line 39: declare: `42': invalid variable name for name reference
+declare -n x
declare -nr RO="foo"
/
-./nameref12.sub: line 58: declare: `7*6': not a valid identifier
-./nameref12.sub: line 58: declare: foo: not found
+./nameref12.sub: line 58: declare: `7*6': invalid variable name for name reference
+declare -n foo
./nameref12.sub: line 60: `7*6': not a valid identifier
declare -n ref="var"
declare -n ref="var"
./nameref17.sub: line 28: declare: foo0: readonly variable
declare -nr foo1
./nameref17.sub: line 37: typeset: foo1: readonly variable
+./nameref17.sub: line 38: typeset: foo1: readonly variable
declare -nr foo1
declare -n foo2="bar"
declare -r bar
${THIS_SH} "$1"
}
+
+# some useful locale variables
+ZH_LOCALE=$(locale -a | grep -i '^zh_TW\.big5' | sed 1q)
+ZH_DEFAULT=$(locale | grep ^LC_CTYPE | sed 's:^.*=::' | tr -d '"')
+
+US_LOCALE=$(locale -a | grep -i '^en_US\.utf-8' | sed 1q)
+if [ -z "$US_LOCALE" ]; then
+ US_LOCALE=$(locale -a | grep -i '^en_US\.utf8' | sed 1q)
+fi
+CTYPE_DEFAULT=$ZH_DEFAULT
+
+# figure out default locale; use LC_CTYPE value since that is what we use it for
+if [ -n "$LC_ALL" ]; then
+ DEFAULT_LOCALE=${LC_ALL}
+elif [ -n "$LC_CTYPE" ]; then
+ DEFAULT_LOCALE=${LC_CTYPE}
+elif [ -n "$LANG" ]; then
+ DEFAULT_LOCALE=${LANG}
+else
+ DEFAULT_LOCALE="C"
+fi
ErrorCnt=0
TestCnt=0
+. ./test-aux-functions
+
localewarn()
{
echo "unicode1.sub: warning: you do not have the $1 locale installed;" >&2
)
# this locale causes problems all over the place
-if locale -a | grep -i '^fr_FR\.ISO8859.*1$' >/dev/null ; then
- TestCodePage fr_FR.ISO8859-1 fr_FR_ISO_8859_1
+FR_LOCALE=$(locale -a | grep -i '^fr_FR\.ISO8859-1' | sed 1q)
+if [ -n "$FR_LOCALE" ]; then
+ TestCodePage ${FR_LOCALE} fr_FR_ISO_8859_1
else
localewarn fr_FR.ISO8859-1
)
# this locale causes problems all over the place
-if locale -a | grep -i '^zh_TW\.big5' >/dev/null ; then
- TestCodePage zh_TW.BIG5 zh_TW_BIG5
+if [ -n "$ZH_LOCALE" ]; then
+ TestCodePage $ZH_LOCALE zh_TW_BIG5
else
localewarn zh_TW.BIG5
fi
if (value)
strcpy (retval+olen, value);
}
- else if (*value)
+ else if (value && *value)
retval = savestring (value);
else
{