execute_cmd.c,shell.c,builtins/evalfile.c,unwind_prot.c
- change some translated error messages to make the text more uniform
and reduce the number of gettext() calls
+
+redir.c,parse.y,bashhist.c.locale.c
+builtins/common.c,builtins/bind.def,builtins/exec.def,builtins/fc.def
+builtins/help.def,builtins/mapfile.def,builtins/printf.def,builtins/read.def
+builtins/ulimit.def
+ - change some error messages to avoid having the format be the return
+ value from gettext() to avoid clang complaints; simplified
+ translatable strings and made them more uniform by removing printf
+ formatting directives
+
+execute_cmd.c
+ - notfound_str: cache the translated version of "command not found"
+ so we can call gettext early on and work around a macOS misfeature
+ From a MacPorts ticket https://trac.macports.org/ticket/68638
+ forwarded by Tom <tom@msbit.com.au>
+ - execute_disk_command: use notfound_str instead of calling gettext
+ every time a command isn't found
+
+execute_cmd.c,execute_cmd.h
+ - init_notfound_str: call gettext to initialize and translate
+ notfound_str
+ - execute_disk_command: call init_notfound_str before forking if it
+ hasn't been initialized
+
+locale.c
+ - set_default_locale_vars: after we set the appropriate values for the
+ locale shell variables, call init_notfound_str to force a call to
+ gettext()
+
+jobs.c
+ - wait_for: don't try to set the tty state if we're running a trap,
+ even if a process terminates due to a signal
+
+ 5/7
+ ---
+builtins/enable.def
+ - enable_builtin: don't try to turn enable f into enable -f f if the
+ shell is restricted
+
+ 5/11
+ ----
+
+doc/bash.1,lib/readline/doc/readline.3,lib/readline/doc/rltech.texi
+ - document some of the bindable commands bound to Home, End, Insert,
+ Page Up, and Page Down, if those keys exist
+ From a report by Xose Vazquez Perez <xose.vazquez@gmail.com> in 3/2024
+
+configure
+ - make sure to note in CHANGES that configure now supports
+ --enable-year-2038 for large time_t
fd = open (filename, O_WRONLY|O_CREAT, 0600);
if (fd < 0)
{
- builtin_error (_("%s: cannot create: %s"), filename, strerror (errno));
+ builtin_error ("%s: %s: %s", filename, _("cannot create"), strerror (errno));
return (EXECUTION_FAILURE);
}
close (fd);
if (rl_read_init_file (initfile) != 0)
{
t = printable_filename (initfile, 0);
- builtin_error (_("%s: cannot read: %s"), t, strerror (errno));
+ builtin_error ("%s: %s: %s", t, _("cannot read"), strerror (errno));
if (t != initfile)
free (t);
BIND_RETURN (EXECUTION_FAILURE);
#if defined (DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS) && defined (EPIPE)
if (errno != EPIPE)
#endif /* DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS && EPIPE */
- builtin_error (_("write error: %s"), strerror (errno));
+ builtin_error ("%s: %s", _("write error"), strerror (errno));
}
void
sh_ttyerror (int set)
{
if (set)
- builtin_error (_("error setting terminal attributes: %s"), strerror (errno));
+ builtin_error ("%s: %s", _("error setting terminal attributes"), strerror (errno));
else
- builtin_error (_("error getting terminal attributes: %s"), strerror (errno));
+ builtin_error ("%s: %s", _("error getting terminal attributes"), strerror (errno));
}
int
#endif
if (the_current_working_directory == 0)
{
- fprintf (stderr, _("%s: error retrieving current directory: %s: %s\n"),
- (for_whom && *for_whom) ? for_whom : get_name_for_error (),
- _(bash_getcwd_errstr), strerror (errno));
+ fprintf (stderr, "%s: %s: %s: %s\n",
+ (for_whom && *for_whom) ? for_whom : get_name_for_error (),
+ _("error retrieving current directory"),
+ _(bash_getcwd_errstr),
+ strerror (errno));
return (char *)NULL;
}
}
#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM)
/* If we try to enable a non-existent builtin, and we have dynamic
loading, try the equivalent of `enable -f name name'. */
+#if defined (RESTRICTED_SHELL)
+ if (*command && (flags & NFLAG) == 0 && opt == EX_NOTFOUND && restricted == 0)
+#else
if (*command && (flags & NFLAG) == 0 && opt == EX_NOTFOUND)
+#endif
{
int dflags, r;
This file is exec.def, from which is created exec.c.
It implements the builtin "exec" in Bash.
-Copyright (C) 1987-2021,2022 Free Software Foundation, Inc.
+Copyright (C) 1987-2021,2022,2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
if (file_isdir (args[0]))
{
#if defined (EISDIR)
- builtin_error (_("%s: cannot execute: %s"), args[0], strerror (EISDIR));
+ builtin_error ("%s: %s: %s", args[0], _("cannot execute"), strerror (EISDIR));
#else
- builtin_error (_("%s: cannot execute: %s"), args[0], strerror (errno));
+ builtin_error ("%s: %s: %s", args[0], _("cannot execute"), strerror (errno));
#endif
exit_value = EX_NOEXEC;
}
else if (executable_file (command) == 0)
{
errno = opt;
- builtin_error (_("%s: cannot execute: %s"), command, strerror (errno));
+ builtin_error ("%s: %s: %s", command, _("cannot execute"), strerror (errno));
exit_value = EX_NOEXEC; /* As per Posix.2, 3.14.6 */
}
else
stream = sh_mktmpfp ("bash-fc", MT_USERANDOM|MT_USETMPDIR, &fn);
if (stream == 0)
{
- builtin_error (_("%s: cannot open temp file: %s"), fn ? fn : "", strerror (errno));
+ builtin_error ("%s: %s: %s", fn ? fn : "", _("cannot open temp file"), strerror (errno));
FREE (fn);
return (EXECUTION_FAILURE);
}
fd = open (name, O_RDONLY);
if (fd == -1)
{
- builtin_error (_("%s: cannot open: %s"), name, strerror (errno));
+ builtin_error ("%s: %s: %s", name, _("cannot open"), strerror (errno));
return -1;
}
return fd;
It implements the builtin "mapfile" in Bash.
Copyright (C) 2005-2006 Rocky Bernstein for Free Software Foundation, Inc.
-Copyright (C) 2008-2023 Free Software Foundation, Inc.
+Copyright (C) 2008-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
if (sh_validfd (fd) == 0)
{
- builtin_error (_("%d: invalid file descriptor: %s"), fd, strerror (errno));
+ builtin_error ("%d: %s: %s", fd, _("invalid file descriptor"), strerror (errno));
return (EXECUTION_FAILURE);
}
break;
/* check for string length overflow when adjusting precision */
if (ckd_add (&precision, slen, 0))
{
- builtin_error (_("%%Q: string length: %s"), strerror (ERANGE));
+ builtin_error ("%%Q: %s %s", _("string length"), strerror (ERANGE));
precision = -1;
}
}
static inline void
printf_erange (char *s)
{
- builtin_error (_("%s: %s"), s, strerror(ERANGE));
+ builtin_error ("%s: %s", s, strerror(ERANGE));
conversion_error = 1;
}
fd = intval;
if (sh_validfd (fd) == 0)
{
- builtin_error (_("%d: invalid file descriptor: %s"), fd, strerror (errno));
+ builtin_error ("%d: %s: %s", fd, _("invalid file descriptor"), strerror (errno));
return (EXECUTION_FAILURE);
}
break;
{
t_errno = errno;
if (errno != EINTR)
- builtin_error (_("read error: %d: %s"), fd, strerror (errno));
+ builtin_error ("%d: %s: %s", fd, _("read error"), strerror (errno));
run_unwind_frame ("read_builtin");
return ((t_errno != EINTR) ? EXECUTION_FAILURE : 128+lastsig);
}
else if (absolute_pathname (list->word->word))
filename = savestring (list->word->word);
else if (source_uses_path)
- filename = find_path_file (list->word->word);
+ {
+#if 0
+ char *spath;
+#if defined (RESTRICTED_SHELL)
+ if (restricted == 0 && posixly_correct == 0 && (spath = path_value ("BASH_SOURCE_PATH", 1)))
+#else
+ if (posixly_correct == 0 && (spath = path_value ("BASH_SOURCE_PATH", 1)))
+#endif
+ filename = find_in_path (list->word->word, spath, FS_READABLE);
+ else
+#endif
+ filename = find_path_file (list->word->word);
+ }
if (filename == 0)
{
if (source_searches_cwd == 0)
opt = get_limit (limind, &soft_limit, &hard_limit);
if (opt < 0)
{
- builtin_error (_("%s: cannot get limit: %s"), limits[limind].description,
- strerror (errno));
+ builtin_error ("%s: %s: %s", limits[limind].description,
+ _("cannot get limit"),
+ strerror (errno));
return (EXECUTION_FAILURE);
}
if (set_limit (limind, real_limit, mode) < 0)
{
- builtin_error (_("%s: cannot modify limit: %s"), limits[limind].description,
- strerror (errno));
+ builtin_error ("%s: %s: %s", limits[limind].description,
+ _("cannot modify limit"),
+ strerror (errno));
return (EXECUTION_FAILURE);
}
if (get_limit (i, &softlim, &hardlim) == 0)
printone (i, (mode & LIMIT_SOFT) ? softlim : hardlim, 1);
else if (errno != EINVAL)
- builtin_error ("%s: cannot get limit: %s", limits[i].description,
- strerror (errno));
+ builtin_error ("%s: %s: %s", limits[i].description,
+ _("cannot get limit"),
+ strerror (errno));
}
}
for (retval = i = 0; limits[i].option > 0; i++)
if (set_limit (i, newlim, mode) < 0)
{
- builtin_error (_("%s: cannot modify limit: %s"), limits[i].description,
- strerror (errno));
+ builtin_error ("%s: %s: %s", limits[i].description,
+ _("cannot modify limit"),
+ strerror (errno));
retval = 1;
}
return retval;
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
-.\" Last Change: Tue Apr 23 15:08:01 EDT 2024
+.\" Last Change: Sat May 11 12:44:30 EDT 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 April 23" "GNU Bash 5.3"
+.TH BASH 1 "2024 May 11" "GNU Bash 5.3"
.\"
.ie \n(.g \{\
.ds ' \(aq
.TP
.B beginning\-of\-line (C\-a)
Move to the start of the current line.
+This may also be bound to the Home key on some keyboards.
.TP
.B end\-of\-line (C\-e)
Move to the end of the line.
+This may also be bound to the End key on some keyboards.
.TP
.B forward\-char (C\-f)
Move forward a character.
Search forward through the history using a non-incremental search for
a string supplied by the user.
.TP
-.B history\-search\-forward
-Search forward through the history for the string of characters
+.B history\-search\-backward
+Search backward through the history for the string of characters
between the start of the current line and the point.
This is a non-incremental search.
+This may be bound to the Page Up key on some keyboards.
.TP
-.B history\-search\-backward
-Search backward through the history for the string of characters
+.B history\-search\-forward
+Search forward through the history for the string of characters
between the start of the current line and the point.
This is a non-incremental search.
+This may be bound to the Page Down key on some keyboards.
.TP
.B history\-substring\-search\-backward
Search backward through the history for the string of characters
capitalize the previous word, but do not move point.
.TP
.B overwrite\-mode
-Toggle overwrite mode. With an explicit positive numeric argument,
-switches to overwrite mode. With an explicit non-positive numeric
-argument, switches to insert mode. This command affects only
-\fBemacs\fP mode; \fBvi\fP mode does overwrite differently.
+Toggle overwrite mode.
+With an explicit positive numeric argument, switches to overwrite mode.
+With an explicit non-positive numeric argument, switches to insert mode.
+This command affects only \fBemacs\fP mode;
+\fBvi\fP mode does overwrite differently.
Each call to \fIreadline()\fP starts in insert mode.
In overwrite mode, characters bound to \fBself\-insert\fP replace
the text at point rather than pushing the text to the right.
Characters bound to \fBbackward\-delete\-char\fP replace the character
-before point with a space. By default, this command is unbound.
+before point with a space.
+By default, this command is unbound,
+but may be bound to the Insert key on some keyboards.
.PD
.SS Killing and Yanking
.PD 0
/* Currently-executing shell function. */
SHELL_VAR *this_shell_function;
+/* Translated message printed when a command is not found. We declare it here
+ and initialize it in locale.c to work around a macOS bug that forces a
+ crash if bash calls setlocale(3) but does not call gettext(3) before
+ forking, then calls gettext() after forking. */
+char *notfound_str = 0;
+
/* If non-zero, matches in case and [[ ... ]] are case-insensitive */
int match_ignore_case = 0;
close (fd);
}
else if (fd < 0)
- internal_error (_("cannot redirect standard input from /dev/null: %s"), strerror (errno));
+ internal_error ("%s: %s", _("cannot redirect standard input from /dev/null"), strerror (errno));
}
#define DESCRIBE_PID(pid) do { if (interactive) describe_pid (pid); } while (0)
NOTE: callers expect this to fork or exit(). */
+/* See comment above where notfound_str is declared. */
+void
+init_notfound_str (void)
+{
+ if (notfound_str == 0)
+ notfound_str = _("command not found");
+}
+
/* Name of a shell function to call when a command name is not found. */
#ifndef NOTFOUND_HOOK
# define NOTFOUND_HOOK "command_not_found_handle"
maybe_make_export_env ();
put_command_name_into_env (command);
}
+ else if (command == 0 && notfound_str == 0) /* make sure */
+ init_notfound_str ();
/* We have to make the child before we check for the non-existence
of COMMAND, since we want the error messages to be redirected. */
{
/* Make sure filenames are displayed using printable characters */
pathname = printable_filename (pathname, 0);
- internal_error (_("%s: command not found"), pathname);
+ internal_error ("%s: %s", pathname, notfound_str);
exit (EX_NOTFOUND); /* Posix.2 says the exit status is 127 */
}
extern void uw_dispose_fd_bitmap (void *);
extern void uw_close (void *);
+extern void init_notfound_str (void);
+
#endif /* _EXECUTE_CMD_H_ */
if (WIFSIGNALED (s) || WIFSTOPPED (s))
{
- set_tty_state ();
+ if (running_trap == 0 /* || WIFSTOPPED (s) */)
+ set_tty_state ();
/* If the current job was stopped or killed by a signal, and
the user has requested it, get a possibly new window size */
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
-.\" Last Change: Fri Mar 29 11:54:44 EDT 2024
+.\" Last Change: Sat May 11 12:44:56 EDT 2024
.\"
-.TH READLINE 3 "2024 March 29" "GNU Readline 8.3"
+.TH READLINE 3 "2024 May 11" "GNU Readline 8.3"
.\"
.ie \n(.g \{\
.ds ' \(aq
.TP
.B beginning\-of\-line (C\-a)
Move to the start of the current line.
+This may also be bound to the Home key on some keyboards.
.TP
.B end\-of\-line (C\-e)
Move to the end of the line.
+This may also be bound to the End key on some keyboards.
.TP
.B forward\-char (C\-f)
Move forward a character.
position (the \fIpoint\fP).
The search string must match at the beginning of a history line.
This is a non-incremental search.
+This may be bound to the Page Up key on some keyboards.
.TP
.B history\-search\-forward
Search forward through the history for the string of characters
between the start of the current line and the point.
The search string must match at the beginning of a history line.
This is a non-incremental search.
+This may be bound to the Page Down key on some keyboards.
.TP
.B history\-substring\-search\-backward
Search backward through the history for the string of characters
capitalize the previous word, but do not move point.
.TP
.B overwrite\-mode
-Toggle overwrite mode. With an explicit positive numeric argument,
-switches to overwrite mode. With an explicit non-positive numeric
-argument, switches to insert mode. This command affects only
-\fBemacs\fP mode; \fBvi\fP mode does overwrite differently.
+Toggle overwrite mode.
+With an explicit positive numeric argument, switches to overwrite mode.
+With an explicit non-positive numeric argument, switches to insert mode.
+This command affects only \fBemacs\fP mode;
+\fBvi\fP mode does overwrite differently.
Each call to \fIreadline()\fP starts in insert mode.
In overwrite mode, characters bound to \fBself\-insert\fP replace
the text at point rather than pushing the text to the right.
Characters bound to \fBbackward\-delete\-char\fP replace the character
-before point with a space. By default, this command is unbound.
+before point with a space.
+By default, this command is unbound,
+but may be bound to the Insert key on some keyboards.
.PD
.SS Killing and Yanking
.PD 0
@ftable @code
@item beginning-of-line (C-a)
Move to the start of the current line.
+This may also be bound to the Home key on some keyboards.
@item end-of-line (C-e)
Move to the end of the line.
+This may also be bound to the End key on some keyboards.
@item forward-char (C-f)
Move forward a character.
for a string supplied by the user.
The search string may match anywhere in a history line.
-@item history-search-forward ()
-Search forward through the history for the string of characters
+@item history-search-backward ()
+Search backward through the history for the string of characters
between the start of the current line and the point.
The search string must match at the beginning of a history line.
This is a non-incremental search.
-By default, this command is unbound.
+By default, this command is unbound, but may be bound to the Page Down
+key on some keyboards.
-@item history-search-backward ()
-Search backward through the history for the string of characters
+@item history-search-forward ()
+Search forward through the history for the string of characters
between the start of the current line and the point.
The search string must match at the beginning of a history line.
This is a non-incremental search.
-By default, this command is unbound.
+By default, this command is unbound, but may be bound to the Page Up
+key on some keyboards.
-@item history-substring-search-forward ()
-Search forward through the history for the string of characters
+@item history-substring-search-backward ()
+Search backward through the history for the string of characters
between the start of the current line and the point.
The search string may match anywhere in a history line.
This is a non-incremental search.
By default, this command is unbound.
-@item history-substring-search-backward ()
-Search backward through the history for the string of characters
+@item history-substring-search-forward ()
+Search forward through the history for the string of characters
between the start of the current line and the point.
The search string may match anywhere in a history line.
This is a non-incremental search.
Characters bound to @code{backward-delete-char} replace the character
before point with a space.
-By default, this command is unbound.
+By default, this command is unbound, but may be bound to the Insert
+key on some keyboards.
@end ftable
@set EDITION 8.3
@set VERSION 8.3
-@set UPDATED 19 January 2024
-@set UPDATED-MONTH January 2024
+@set UPDATED 11 May 2024
+@set UPDATED-MONTH May 2024
-@set LASTCHANGE Fri Jan 19 11:01:44 EST 2024
+@set LASTCHANGE Sat May 11 12:41:28 EDT 2024
/* locale.c - Miscellaneous internationalization functions. */
-/* Copyright (C) 1996-2009,2012,2016-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2009,2012,2016-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
extern const char *locale_charset (void);
#endif
+extern void init_notfound_str (void); /* from execute_cmd.c */
+
extern int dump_translatable_strings, dump_po_strings;
int locale_utf8locale;
if (default_domain && *default_domain)
bindtextdomain (default_domain, default_dir);
}
+
+ init_notfound_str (); /* force a gettext call early on */
}
/* Set one of the locale categories (specified by VAR) to VALUE. Returns 1
if (x == 0)
{
if (errno == 0)
- internal_warning(_("setlocale: LC_ALL: cannot change locale (%s)"), lc_all);
+ internal_warning ("setlocale: LC_ALL: %s (%s)", _("cannot change locale"), lc_all);
else
- internal_warning(_("setlocale: LC_ALL: cannot change locale (%s): %s"), lc_all, strerror (errno));
+ internal_warning ("setlocale: LC_ALL: %s (%s): %s", _("cannot change locale"), lc_all, strerror (errno));
}
locale_mb_cur_max = MB_CUR_MAX;
/* if LC_ALL == "", reset_locale_vars has already called this */
if (x == 0)
{
if (errno == 0)
- internal_warning(_("setlocale: %s: cannot change locale (%s)"), var, get_locale_var (var));
+ internal_warning("setlocale: %s: %s (%s)", var, _("cannot change locale"), get_locale_var (var));
else
- internal_warning(_("setlocale: %s: cannot change locale (%s): %s"), var, get_locale_var (var), strerror (errno));
+ internal_warning("setlocale: %s: %s (%s): %s", var, _("cannot change locale"), get_locale_var (var), strerror (errno));
}
return (x != 0);
else if (uc == 0 && shell_input_line_terminator == READERR)
{
#if defined (FATAL_READERROR)
- report_error (_("script file read error: %s"), strerror (errno));
+ report_error ("%s: %s", _("script file read error"), strerror (errno));
exit_shell (128); /* POSIX mandated error status */
#else
/* Treat read errors like EOF here. */
switch (error)
{
case AMBIGUOUS_REDIRECT:
- internal_error (_("%s: ambiguous redirect"), filename);
+ internal_error ("%s: %s", filename, _("ambiguous redirect"));
break;
case NOCLOBBER_REDIRECT:
- internal_error (_("%s: cannot overwrite existing file"), filename);
+ internal_error ("%s: %s", filename, _("cannot overwrite existing file"));
break;
#if defined (RESTRICTED_SHELL)
case RESTRICTED_REDIRECT:
- internal_error (_("%s: restricted: cannot redirect output"), filename);
+ internal_error ("%s: %s", filename, _("restricted: cannot redirect output"));
break;
#endif /* RESTRICTED_SHELL */
case HEREDOC_REDIRECT:
- internal_error (_("cannot create temp file for here-document: %s"), strerror (heredoc_errno));
+ internal_error ("%s: %s", _("cannot create temp file for here-document"), strerror (heredoc_errno));
break;
case BADVAR_REDIRECT:
- internal_error (_("%s: cannot assign fd to variable"), filename);
+ internal_error ("%s: %s", filename, _("cannot assign fd to variable"));
break;
default:
declare -a a=([0]="1" [1]="2" [2]="3" [3]="4")
declare -- int="2"
after here-doc: 1
-[1]- Running sleep 1 &
-[2]+ Running sleep 1 &
-[1]- Running sleep 1 &
-[2]+ Running sleep 1 &
+[1]- Running sleep 1 &
+[2]+ Running sleep 1 &
+[1]- Running sleep 1 &
+[2]+ Running sleep 1 &
17772 26794
17772 26794
we should try rhs
[[ x =~ \\x ]] ; echo $?
bs='\'
-[[ x =~ ${bs}x ]] ; echo $?
+[[ '\[' =~ ${bs}[ ]] ; echo $?
[[ x =~ $'\\'x ]] ; echo $?
[[ x =~ '\'x ]] ; echo $?
:
else
echo "glob2.sub: warning: you do not have the zh_TW.big5 locale installed;" >&2
- echo "glob2.sub: warning: that will cause some of these tests to fail." >&2
+ echo "glob2.sub: warning: that may cause some of these tests to fail." >&2
fi
var='ab\'