experimental change to use groff instead of man2html for HTML man pages; man page updates for reserved words; fix for pattern matching bracket expression ranges; readline changes to disallow defining some recursive keyboard macros

This commit is contained in:
Chet Ramey
2025-09-18 17:26:51 -04:00
parent a451bfc3f5
commit b88cd1c366
24 changed files with 18920 additions and 19320 deletions
+51
View File
@@ -11683,3 +11683,54 @@ lib/readline/signals.c
call rl_message. That takes care of the case where redisplay gets a
SIGINT while `blocking' it.
Report from Grisha Levit <grishalevit@gmail.com>
jobs.c
- print_pipeline: make sure we separate the fatal signal description
from the pipeline command by at least one space
9/6
---
doc/Makefile.in
- MAN2HTML: experimental change to use `groff -Thtml -man' to
generate HTML versions of man pages instead of man2html
doc/bash.1,doc/bashref.texi
- reserved words: add clarifying language about when reserved words
are recognized
- lists: modify description to define lists as sequences of and-or
lists; clarify list terminators
- select: update synopsis to indicate a word list and optional
semicolon like `for'
- case: rearrange description to introduce pattern lists and expand
the definition of a case clause to include the terminator, which
is optional for the last clause
From a report by Martin D Kealey <martin@kurahaupo.gen.nz>
9/8
---
lib/glob/smatch.c
- charcmp_wc: don't restrict codepoints to 0..UCHAR_MAX; this will
eventually break with multibyte character codepoints
From a report from Duncan Roe <duncan_roe@optusnet.com.au>; fix
suggested by Grisha Levit <grishalevit@gmail.com>
9/11
----
[prayers for the victims of 9/11/2001]
lib/readline/macro.c
- rl_start_kbd_macro: don't allow keyboard macro definitions while
reading input from a bound macro.
Suggested by Grisha Levit <grishalevit@gmail.com>
lib/readline/readline.c,lib/readline/text.c
- _rl_dispatch_subseq,_rl_insert_next,_rl_char_search: if we're
defining a keyboard macro, don't insert the expanded value of a
macro that is bound to a key sequence added to the keyboard macro
Report and patch from Grisha Levit <grishalevit@gmail.com>
9/12
----
builtins/mkbuiltins.c
- some minor code cleanups
Patch from Martin D Kealey <martin@kurahaupo.gen.nz>
+1 -1
View File
@@ -35,7 +35,7 @@
#define ISOPT(s) (((*(s) == '-') || (plus && *(s) == '+')) && (s)[1])
#define NOTOPT(s) (((*(s) != '-') && (!plus || *(s) != '+')) || (s)[1] == '\0')
static int sp;
char *list_optarg;
+11 -9
View File
@@ -1,7 +1,7 @@
This file is declare.def, from which is created declare.c.
It implements the builtins "declare" and "local" in Bash.
Copyright (C) 1987-2024 Free Software Foundation, Inc.
Copyright (C) 1987-2025 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -39,8 +39,10 @@ Options:
-p display the attributes and value of each NAME
Options which set attributes:
#ifdef ARRAY_VARS
-a to make NAMEs indexed arrays (if supported)
-A to make NAMEs associative arrays (if supported)
#endif
-i to make NAMEs have the `integer' attribute
-l to convert the value of each NAME to lower case on assignment
-n make NAME a reference to the variable named by its value
@@ -131,7 +133,7 @@ local_builtin (WORD_LIST *list)
builtin_help ();
return (EX_USAGE);
}
if (variable_context)
return (declare_internal (list, 1));
else
@@ -199,7 +201,7 @@ declare_transform_name (char *name, int flags_on, int flags_off)
{
SHELL_VAR *var, *v;
char *newname;
var = find_variable (name);
if (var == 0)
newname = nameref_transform_name (name, ASS_MKLOCAL);
@@ -234,7 +236,7 @@ declare_invalid_opts (int flags_on, int flags_off)
else if (flags_on & att_array)
optchar = "-a";
sh_invalidopt (optchar);
sh_invalidopt (optchar);
return (EXECUTION_FAILURE);
}
else if ((flags_on & att_assoc) && (flags_off & att_assoc))
@@ -255,7 +257,7 @@ declare_invalid_opts (int flags_on, int flags_off)
/* Ineffective, since you can't have namerefs referencing positional parameters */
else if ((flags_on & att_nameref) && (flags_on & att_integer))
{
builtin_error ("cannot use -n with -i");
builtin_error (_("cannot use -n with -i"));
return (EX_BADUSAGE);
}
@@ -415,7 +417,7 @@ declare_internal (WORD_LIST *list, int local_var)
opt = declare_invalid_opts (flags_on, flags_off);
if (opt != 0)
return (opt);
#define NEXT_VARIABLE() free (name); list = list->next; continue
/* There are arguments left, so we are making variables. */
@@ -520,7 +522,7 @@ declare_internal (WORD_LIST *list, int local_var)
}
else
#endif /* DEBUGGER */
{
{
t = nodefs ? name_cell (var) : named_function_string (name, function_cell (var), FUNC_MULTILINE|FUNC_EXTERNAL);
printf ("%s\n", t);
any_failed = sh_chkwrite (any_failed);
@@ -876,7 +878,7 @@ restart_new_var_name:
/* Readonly variable error checking. */
/* Cannot use declare +r to turn off readonly attribute. */
/* Cannot use declare +r to turn off readonly attribute. */
if (readonly_p (var) && (flags_off & att_readonly))
{
sh_readonly (name_cell (var));
@@ -1040,7 +1042,7 @@ restart_new_var_name:
sh_invalidid (value);
/* what else can cause this to fail? */
else if (flags_on & att_integer)
builtin_error ("%s: expands to invalid variable name for name reference", value);
builtin_error (_("%s: expands to invalid variable name for name reference"), value);
assign_error++;
/* XXX - unset this variable? or leave it as normal var? */
if (created_var)
+1 -1
View File
@@ -183,7 +183,7 @@ file_error_and_exit:
free (string);
return ((flags & FEVAL_BUILTIN) ? EXECUTION_SUCCESS : 1);
}
if ((flags & FEVAL_CHECKBINARY) &&
check_binary_file (string, (nr > 80) ? 80 : nr))
{
+5 -5
View File
@@ -341,10 +341,10 @@ parse_and_execute (char *string, const char *from_file, int flags)
if (parser_expanding_alias ())
/* push current shell_input_line */
parser_save_alias ();
if (lreset == 0)
line_number--;
indirection_level++;
code = should_jump_to_top_level = 0;
@@ -425,7 +425,7 @@ parse_and_execute (char *string, const char *from_file, int flags)
run_unwind_frame ("pe_dispose");
last_result = last_command_exit_value = EXECUTION_FAILURE; /* XXX */
set_pipestatus_from_exit (last_command_exit_value);
if (subshell_environment)
{
should_jump_to_top_level = 1;
@@ -698,7 +698,7 @@ parse_string (char *string, const char *from_file, int flags, COMMAND **cmdp, ch
break;
}
}
if (parse_command () == 0)
{
if (cmdp)
@@ -861,6 +861,6 @@ evalstring (char *string, const char *from_file, int flags)
sh_longjmp (return_catch, 1);
}
}
return (r);
}
+41 -51
View File
@@ -183,7 +183,7 @@ char *arrayvar_builtins[] =
"typeset", "unset", "wait", /*]*/
(char *)NULL
};
/* Forward declarations. */
static int is_special_builtin (char *);
static int is_assignment_builtin (char *);
@@ -288,6 +288,8 @@ main (int argc, char **argv)
if (include_filename == 0)
include_filename = extern_filename;
if (include_filename == 0)
include_filename = "builtext.h";
/* If there are no files to process, just quit now. */
if (arg_index == argc)
@@ -328,7 +330,7 @@ main (int argc, char **argv)
/* Process the .def files. */
while (arg_index < argc)
{
register char *arg;
char *arg;
arg = argv[arg_index++];
@@ -399,7 +401,7 @@ array_create (int width)
ARRAY *
copy_string_array (ARRAY *array)
{
register int i;
int i;
ARRAY *copy;
if (!array)
@@ -412,7 +414,7 @@ copy_string_array (ARRAY *array)
copy->width = array->width;
copy->array = (char **)xmalloc ((1 + array->sindex) * sizeof (char *));
for (i = 0; i < array->sindex; i++)
copy->array[i] = savestring (array->array[i]);
@@ -484,7 +486,7 @@ HANDLER_ENTRY handlers[] = {
HANDLER_ENTRY *
find_directive (char *directive)
{
register int i;
int i;
for (i = 0; handlers[i].directive; i++)
if (strcmp (handlers[i].directive, directive) == 0)
@@ -513,7 +515,7 @@ int output_cpp_line_info = 0;
void
extract_info (char *filename, FILE *structfile, FILE *externfile)
{
register int i;
int i;
DEF_FILE *defs;
struct stat finfo;
size_t file_size;
@@ -578,7 +580,7 @@ extract_info (char *filename, FILE *structfile, FILE *externfile)
if (*line == '$')
{
register int j;
int j;
char *directive;
HANDLER_ENTRY *handler;
@@ -653,7 +655,7 @@ extract_info (char *filename, FILE *structfile, FILE *externfile)
static void
free_builtin (BUILTIN_DESC *builtin)
{
register int i;
int i;
free_safely (builtin->name);
free_safely (builtin->function);
@@ -675,8 +677,8 @@ free_builtin (BUILTIN_DESC *builtin)
void
free_defs (DEF_FILE *defs)
{
register int i;
register BUILTIN_DESC *builtin;
int i;
BUILTIN_DESC *builtin;
if (defs->production)
free (defs->production);
@@ -718,7 +720,7 @@ strip_whitespace (char *string)
void
remove_trailing_whitespace (char *string)
{
register int i;
int i;
i = strlen (string) - 1;
@@ -769,7 +771,7 @@ current_builtin (char *directive, DEF_FILE *defs)
void
add_documentation (DEF_FILE *defs, char *line)
{
register BUILTIN_DESC *builtin;
BUILTIN_DESC *builtin;
builtin = current_builtin ("(implied LONGDOC)", defs);
@@ -837,7 +839,7 @@ builtin_handler (char *self, DEF_FILE *defs, char *arg)
int
function_handler (char *self, DEF_FILE *defs, char *arg)
{
register BUILTIN_DESC *builtin;
BUILTIN_DESC *builtin;
builtin = current_builtin (self, defs);
@@ -859,7 +861,7 @@ function_handler (char *self, DEF_FILE *defs, char *arg)
int
docname_handler (char *self, DEF_FILE *defs, char *arg)
{
register BUILTIN_DESC *builtin;
BUILTIN_DESC *builtin;
builtin = current_builtin (self, defs);
@@ -876,7 +878,7 @@ docname_handler (char *self, DEF_FILE *defs, char *arg)
int
short_doc_handler (char *self, DEF_FILE *defs, char *arg)
{
register BUILTIN_DESC *builtin;
BUILTIN_DESC *builtin;
builtin = current_builtin (self, defs);
@@ -900,7 +902,7 @@ comment_handler (char *self, DEF_FILE *defs, char *arg)
int
depends_on_handler (char *self, DEF_FILE *defs, char *arg)
{
register BUILTIN_DESC *builtin;
BUILTIN_DESC *builtin;
char *dependent;
builtin = current_builtin (self, defs);
@@ -1077,7 +1079,7 @@ char *structfile_header[] = {
"/* This file is manufactured by ./mkbuiltins, and should not be",
" edited by hand. See the source to mkbuiltins for details. */",
"",
"/* Copyright (C) 1987-2022 Free Software Foundation, Inc.",
"/* Copyright (C) 1987-2025 Free Software Foundation, Inc.",
"",
" This file is part of GNU Bash, the Bourne Again SHell.",
"",
@@ -1130,16 +1132,14 @@ char *structfile_footer[] = {
void
write_file_headers (FILE *structfile, FILE *externfile)
{
register int i;
int i;
if (structfile)
{
for (i = 0; structfile_header[i]; i++)
fprintf (structfile, "%s\n", structfile_header[i]);
fprintf (structfile, "#include \"%s\"\n",
include_filename ? include_filename : "builtext.h");
fprintf (structfile, "#include \"%s\"\n", include_filename);
fprintf (structfile, "#include \"bashintl.h\"\n");
fprintf (structfile, "\nstruct builtin static_shell_builtins[] = {\n");
@@ -1147,8 +1147,7 @@ write_file_headers (FILE *structfile, FILE *externfile)
if (externfile)
fprintf (externfile,
"/* %s - The list of builtins found in libbuiltins.a. */\n",
include_filename ? include_filename : "builtext.h");
"/* %s - The list of builtins found in libbuiltins.a. */\n", include_filename);
}
/* Write out any necessary closing information for
@@ -1156,7 +1155,7 @@ write_file_headers (FILE *structfile, FILE *externfile)
void
write_file_footers (FILE *structfile, FILE *externfile)
{
register int i;
int i;
/* Write out the footers. */
if (structfile)
@@ -1171,12 +1170,12 @@ write_file_footers (FILE *structfile, FILE *externfile)
void
write_builtins (DEF_FILE *defs, FILE *structfile, FILE *externfile)
{
register int i;
int i;
/* Write out the information. */
if (defs->builtins)
{
register BUILTIN_DESC *builtin;
BUILTIN_DESC *builtin;
for (i = 0; i < defs->builtins->sindex; i++)
{
@@ -1275,8 +1274,8 @@ write_builtins (DEF_FILE *defs, FILE *structfile, FILE *externfile)
void
write_longdocs (FILE *stream, ARRAY *builtins)
{
register int i;
register BUILTIN_DESC *builtin;
int i;
BUILTIN_DESC *builtin;
char *dname;
char *sarray[2];
@@ -1312,7 +1311,7 @@ write_longdocs (FILE *stream, ARRAY *builtins)
void
write_dummy_declarations (FILE *stream, ARRAY *builtins)
{
register int i;
int i;
BUILTIN_DESC *builtin;
for (i = 0; structfile_header[i]; i++)
@@ -1336,7 +1335,7 @@ write_dummy_declarations (FILE *stream, ARRAY *builtins)
void
write_ifdefs (FILE *stream, char **defines)
{
register int i;
int i;
if (!stream)
return;
@@ -1365,7 +1364,7 @@ write_ifdefs (FILE *stream, char **defines)
void
write_endifs (FILE *stream, char **defines)
{
register int i;
int i;
if (!stream)
return;
@@ -1390,8 +1389,8 @@ write_endifs (FILE *stream, char **defines)
void
write_documentation (FILE *stream, char **documentation, int indentation, int flags)
{
register int i, j;
register char *line;
int i, j;
char *line;
int string_array, texinfo, base_indent, filename_p;
if (stream == 0)
@@ -1456,16 +1455,9 @@ write_documentation (FILE *stream, char **documentation, int indentation, int fl
{
for (j = 0; line[j]; j++)
{
switch (line[j])
{
case '\\':
case '"':
fprintf (stream, "\\%c", line[j]);
break;
default:
fprintf (stream, "%c", line[j]);
}
if (line[j] == '\\' || line[j] == '"')
fputc ('\\', stream);
fputc (line[j], stream);
}
/* closing right paren for gettext */
@@ -1489,14 +1481,12 @@ write_documentation (FILE *stream, char **documentation, int indentation, int fl
case '@':
case '{':
case '}':
fprintf (stream, "@%c", line[j]);
fputc ('@', stream);
break;
default:
fprintf (stream, "%c", line[j]);
}
fputc (line[j], stream);
}
fprintf (stream, "\n");
fputc ('\n', stream);
}
else
fprintf (stream, "%s\n", line);
@@ -1554,12 +1544,12 @@ write_helpfiles (ARRAY *builtins)
free (helpfile);
}
return 0;
}
}
static int
_find_in_table (char *name, char **name_table)
{
register int i;
int i;
for (i = 0; name_table[i]; i++)
if (strcmp (name, name_table[i]) == 0)
+3 -2
View File
@@ -68,7 +68,8 @@ RL_LIBDIR = $(topdir)/lib/readline
MAKEINFO = makeinfo
TEXI2DVI = ${SUPPORT_SRCDIR}/texi2dvi
TEXI2HTML = ${SUPPORT_SRCDIR}/texi2html
MAN2HTML = ${BUILD_DIR}/support/man2html
#MAN2HTML = ${BUILD_DIR}/support/man2html
MAN2HTML = ${GROFF} -Thtml -man
HTMLPOST = ${srcdir}/htmlpost.sh
QUIETPS = #set this to -q to shut up dvips
PAPERSIZE = letter # change to a4 for A4-size paper
@@ -153,7 +154,7 @@ BASHREF_FILES = $(srcdir)/bashref.texi $(srcdir)/fdl.texi $(srcdir)/version.texi
# $(RM) $@
# -${TEXI2PDF} $<
all: info dvi text html pdf $(MAN2HTML)
all: info dvi text html pdf # $(MAN2HTML)
nodvi: ps info text html
everything: all ps
+3219 -3196
View File
File diff suppressed because it is too large Load Diff
+75 -54
View File
@@ -5,7 +5,7 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Mon Aug 25 11:35:58 EDT 2025
.\" Last Change: Sat Sep 6 15:27:27 EDT 2025
.\"
.\" For bash_builtins, strip all but "SHELL BUILTIN COMMANDS" section
.\" For rbash, strip all but "RESTRICTED SHELL" section
@@ -21,7 +21,7 @@
.ds zY \" empty
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2025 August 25" "GNU Bash 5.3"
.TH BASH 1 "2025 September 6" "GNU Bash 5.3"
.\"
.ie \n(.g \{\
.ds ' \(aq
@@ -552,17 +552,32 @@ It is one of the following symbols:
.SH "RESERVED WORDS"
\fIReserved words\fP are words that have a special meaning to the shell.
The following words are recognized as reserved when unquoted and either
.IP \(bu
the first word of a command (see
.SM
.B "SHELL GRAMMAR"
below), the third word of a
below);
.IP \(bu
the first word following a reserved word
other than \fBcase\fP, \fBfor\fP, \fBselect\fP, or \fBin\fP;
.IP \(bu
the third word of a
.B case
command
(only \fBin\fP is valid);
.IP \(bu
the third word of a
.B for
or
.B select
command
(only \fBin\fP is valid), or the third word of a
.B for
command (only \fBin\fP and \fBdo\fP are valid):
command (only \fBin\fP and \fBdo\fP are valid);
.IP \(bu
following a control operator.
.PP
The shell will also recognize reserved words where the syntax of a command
specifically requires the reserved word as the only correct token.
.PP
The following are reserved words:
.if t .RS
.PP
.B
@@ -667,48 +682,18 @@ If the \fBlastpipe\fP option is enabled using the \fBshopt\fP builtin
and job control is not active,
the last element of a pipeline may be run by the shell process.
.SS Lists
A \fIlist\fP is a sequence of one or more pipelines separated by one
of the operators
.BR ; ,
.BR & ,
.BR && ,
or
.BR || ,
and optionally terminated by one of
A \fIlist\fP is a sequence of one or more AND or OR lists
separated by one of the operators
.BR ; ,
.BR & ,
or
.BR <newline> .
.PP
Of these list operators,
.B &&
and
.B ||
have equal precedence, followed by
.B ;
and
.BR & ,
which have equal precedence.
.PP
A sequence of one or more newlines may appear in a \fIlist\fP instead
of a semicolon to delimit commands.
.PP
If a command is terminated by the control operator
.BR & ,
the shell executes the command in the \fIbackground\fP
in a subshell.
The shell does not wait for the command to
finish, and the return status is 0.
These are referred to as \fIasynchronous\fP commands.
Commands separated by a
.B ;
are executed sequentially; the shell waits for each
command to terminate in turn.
The return status is the exit status of the last command executed.
.BR <newline> ,
and optionally terminated by one of those three characters.
.PP
AND and OR lists are sequences of one or more pipelines separated by the
\fB&&\fP and \fB||\fP control operators, respectively.
AND and OR lists are executed with left associativity.
.PP
An AND list has the form
.RS
.PP
@@ -733,6 +718,35 @@ returns a non-zero exit status.
The return status of
AND and OR lists is the exit status of the last command
executed in the list.
.PP
Of these list operators,
.B &&
and
.B ||
have equal precedence, followed by
.B ;
and
.BR & ,
which have equal precedence.
.PP
A sequence of one or more newlines may appear in a \fIlist\fP instead
of a semicolon to delimit commands.
.PP
If a command is terminated by the control operator
.BR & ,
the shell executes the command in the \fIbackground\fP
in a subshell.
The shell does not wait for the command to
finish, and the return status is 0.
These are referred to as \fIasynchronous\fP commands.
Commands separated or terminated by
.B ;
(or an equivalent
.BR <newline> )
are executed sequentially; the shell waits for each
command to terminate in turn.
.PP
The return status of a list is the exit status of the last command executed.
.SS Compound Commands
A \fIcompound command\fP is one of the following.
In most cases a \fIlist\fP in a command's description may be separated from
@@ -904,7 +918,7 @@ the entire conditional expression.
.RE
.TP
\fBfor\fP \fIname\fP [ [ \fBin\fP \fIword .\|.\|.\&\fP ] ; ] \fBdo\fP \fIlist\fP ; \fBdone\fP
First, expand The list of words following \fBin\fP, generating a list
First, expand the list of words following \fBin\fP, generating a list
of items.
Then, the variable \fIname\fP is set to each element of this list
in turn, and \fIlist\fP is executed each time.
@@ -938,7 +952,7 @@ Use the \fBbreak\fP and \fPcontinue\fP builtins
below)
to control loop execution.
.TP
\fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
\fBselect\fP \fIname\fP [ [ \fBin\fP \fIword .\|.\|.\&\fP ] ; ] \fBdo\fP \fIlist\fP ; \fBdone\fP
First, expand the list of words following \fBin\fP,
generating a list of items, and print the set of expanded words
the standard error, each preceded by a number.
@@ -985,8 +999,6 @@ using the matching rules
described under
.B "Pattern Matching"
below.
A pattern list is a set of one or more patterns separated by \|,
and the ) operator terminates the pattern list.
The \fIword\fP is expanded using tilde
expansion, parameter and variable expansion, arithmetic expansion,
command substitution, process substitution and quote removal.
@@ -997,19 +1009,28 @@ If the
.B nocasematch
shell option is enabled, the match is performed without regard to the case
of alphabetic characters.
A \fIclause\fP is a pattern list and an associated \fIlist\fP.
.IP
A \fIpattern list\fP is a set of one or more patterns separated by
.BR | ,
and terminated by the \fB)\fP operator.
A case \fIclause\fP is a pattern list and an associated \fIlist\fP,
terminated by \fB;;\fP, \fB;&\fP, or \fB;;&\fP.
The terminator is optional for the last clause preceding \fBesac\fP.
There may be an arbitrary number of case clauses.
The first pattern that matches determines the
\fIlist\fP that is executed.
.IP
When a match is found, \fBcase\fP executes the corresponding \fIlist\fP.
If the \fB;;\fP operator terminates the case clause, the \fBcase\fP
command completes after the first match.
Using \fB;&\fP in place of \fB;;\fP causes execution to continue with
the \fIlist\fP associated with the next pattern list.
Using \fB;;&\fP in place of \fB;;\fP causes the shell to test the next
pattern list in the statement, if any, and execute any associated \fIlist\fP
If the \fB;;\fP operator terminates the case clause,
the \fBcase\fP command completes after the first match.
Using the \fB;&\fP terminator continues execution with
the \fIlist\fP associated with the next clause, if any.
Using the \fB;;&\fP terminator causes the shell to test the pattern list
in the next clause, if any, and execute any associated \fIlist\fP
if the match succeeds,
continuing the case statement execution as if the pattern list had not matched.
The exit status is zero if no pattern matches.
.IP
The exit status is zero if no pattern matches.
Otherwise, it is the exit status of the
last command executed in the last \fIlist\fP executed.
.TP
+14787 -15344
View File
File diff suppressed because it is too large Load Diff
+249 -233
View File
@@ -1,9 +1,9 @@
This is bash.info, produced by makeinfo version 7.2 from bashref.texi.
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 7 August 2025).
Bash shell (version 5.3, 6 September 2025).
This is Edition 5.3, last updated 7 August 2025, of The GNU Bash
This is Edition 5.3, last updated 6 September 2025, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Copyright © 1988-2025 Free Software Foundation, Inc.
@@ -26,10 +26,10 @@ Bash Features
*************
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 7 August 2025). The Bash home page is
Bash shell (version 5.3, 6 September 2025). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.3, last updated 7 August 2025, of The GNU Bash
This is Edition 5.3, last updated 6 September 2025, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Bash contains features that appear in other popular shells, and some
@@ -259,9 +259,9 @@ Bash is an acronym for Bourne-Again SHell. The Bourne shell is the
traditional Unix shell originally written by Stephen Bourne. All of the
Bourne shell builtin commands are available in Bash, and the rules for
evaluation and quoting are taken from the POSIX specification for the
'standard' Unix shell.
"standard" Unix shell.
This chapter briefly summarizes the shell's 'building blocks':
This chapter briefly summarizes the shell's "building blocks":
commands, control structures, shell functions, shell parameters, shell
expansions, redirections, which are a way to direct input and output
from and to named files, and how the shell executes commands.
@@ -642,18 +642,27 @@ File: bash.info, Node: Reserved Words, Next: Simple Commands, Up: Shell Comma
Reserved words are words that have special meaning to the shell. They
are used to begin and end the shell's compound commands.
The following words are recognized as reserved when unquoted and the
first word of a command (see below for exceptions):
Reserved words are recognized as reserved when unquoted and either
• the first word of a command;
• the first word following a reserved word other than case, for,
select, or in;
• the third word of a case command (only in is valid);
• the third word of a for or select command (only in and do
are valid);
• following a control operator.
The shell will also recognize reserved words where the syntax of a
command specifically requires the reserved word as the only correct
token.
The following are reserved words:
if then elif else fi time
for in until while do done
case esac coproc’‘select’‘function
‘{’ ‘}’ ‘[[’ ‘]]’ ‘!’
in is recognized as a reserved word if it is the third word of a
case or select command. in and do are recognized as reserved
words if they are the third word in a for command.

File: bash.info, Node: Simple Commands, Next: Pipelines, Prev: Reserved Words, Up: Shell Commands
@@ -740,9 +749,30 @@ File: bash.info, Node: Lists, Next: Compound Commands, Prev: Pipelines, Up:
3.2.4 Lists of Commands
-----------------------
A list is a sequence of one or more pipelines separated by one of the
operators ;, &, &&, or ||, and optionally terminated by one of
;, &, or a newline.
A list is a sequence of one or more AND or OR lists separated by one
of the operators ; or &, or a newline, and optionally terminated
by one of those three characters.
AND and OR lists are sequences of one or more pipelines separated by
the control operators && and ||, respectively. AND and OR lists are
executed with left associativity.
An AND list has the form
COMMAND1 && COMMAND2
COMMAND2 is executed if, and only if, COMMAND1 returns an exit status of
zero (success).
An OR list has the form
COMMAND1 || COMMAND2
COMMAND2 is executed if, and only if, COMMAND1 returns a non-zero exit
status.
The return status of AND and OR lists is the exit status of the last
command executed in the list.
Of these list operators, && and || have equal precedence,
followed by ; and &, which have equal precedence.
@@ -759,28 +789,12 @@ active (*note Job Control::), the standard input for asynchronous
commands, in the absence of any explicit redirections, is redirected
from /dev/null.
Commands separated by a ; are executed sequentially; the shell
waits for each command to terminate in turn. The return status is the
exit status of the last command executed.
Commands separated or terminated by ; (or equivalent newline) are
executed sequentially; the shell waits for each command to terminate in
turn.
AND and OR lists are sequences of one or more pipelines separated by
the control operators && and ||, respectively. AND and OR lists are
executed with left associativity.
An AND list has the form
COMMAND1 && COMMAND2
COMMAND2 is executed if, and only if, COMMAND1 returns an exit status of
zero (success).
An OR list has the form
COMMAND1 || COMMAND2
COMMAND2 is executed if, and only if, COMMAND1 returns a non-zero exit
status.
The return status of AND and OR lists is the exit status of the last
command executed in the list.
The return status of a list is the exit status of the last command
executed.

File: bash.info, Node: Compound Commands, Next: Coprocesses, Prev: Lists, Up: Shell Commands
@@ -909,27 +923,25 @@ File: bash.info, Node: Conditional Constructs, Next: Command Grouping, Prev:
case will selectively execute the COMMAND-LIST corresponding to
the first PATTERN that matches WORD, proceeding from the first
pattern to the last. The match is performed according to the rules
described below in *note Pattern Matching::. If the nocasematch
described below in *note Pattern Matching::. The WORD undergoes
tilde expansion, parameter expansion, command substitution, process
substitution, arithmetic expansion, and quote removal (*note Shell
Parameter Expansion::) before the shell attempts to match the
pattern. Each PATTERN examined undergoes tilde expansion,
parameter expansion, command substitution, arithmetic expansion,
process substitution, and quote removal. If the nocasematch
shell option (see the description of shopt in *note The Shopt
Builtin::) is enabled, the match is performed without regard to the
case of alphabetic characters. The | is used to separate
multiple patterns in a pattern list, and the ) operator
terminates the pattern list. A pattern list and an associated
COMMAND-LIST is known as a CLAUSE.
case of alphabetic characters.
Each clause must be terminated with ;;, ;&, or ;;&. The WORD
undergoes tilde expansion, parameter expansion, command
substitution, process substitution, arithmetic expansion, and quote
removal (*note Shell Parameter Expansion::) before the shell
attempts to match the pattern. Each PATTERN undergoes tilde
expansion, parameter expansion, command substitution, arithmetic
expansion, process substitution, and quote removal.
There may be an arbitrary number of case clauses, each terminated
by a ;;, ;&, or ;;&. The first pattern that matches
determines the command-list that is executed. It's a common idiom
to use * as the final pattern to define the default case, since
that pattern will always match.
A pattern list is a set of one or more patterns separated by |,
and terminated by the ) operator. A case CLAUSE is a pattern
list and an associated COMMAND-LIST, terminated by ;;, ;&, or
;;&. The terminator is optional for the last clause preceding
esac. There may be an arbitrary number of case clauses. The
first pattern that matches determines the command-list that is
executed. It's a common idiom to use * as the final pattern to
define the default case, since that pattern will always match.
Here is an example using case in a script that could be used to
describe one interesting feature of an animal:
@@ -944,13 +956,15 @@ File: bash.info, Node: Conditional Constructs, Next: Command Grouping, Prev:
esac
echo " legs."
If the ;; operator is used, the case command completes after
the first pattern match. Using ;& in place of ;; causes
execution to continue with the COMMAND-LIST associated with the
next clause, if any. Using ;;& in place of ;; causes the shell
to test the patterns in the next clause, if any, and execute any
associated COMMAND-LIST if the match succeeds, continuing the case
statement execution as if the pattern list had not matched.
When a match is found, case executes the corresponding
COMMAND-LIST. If the ;; operator terminates the case clause, the
case command completes after the first pattern match. Using the
;& terminator continues execution with the COMMAND-LIST
associated with the next clause, if any. Using the ;;&
terminator causes the shell to test the pattern list in the next
clause, if any, and execute any associated COMMAND-LIST if the
match succeeds, continuing the case statement execution as if the
pattern list had not matched.
The return status is zero if no PATTERN matches. Otherwise, the
return status is the exit status of the last COMMAND-LIST executed.
@@ -2890,12 +2904,12 @@ characters \, $, and `; however, double quote characters have
special meaning.
If the redirection operator is <<-, the shell strips leading tab
characters are stripped from input lines and the line containing
DELIMITER. This allows here-documents within shell scripts to be
indented in a natural fashion.
characters from input lines and the line containing DELIMITER. This
allows here-documents within shell scripts to be indented in a natural
fashion.
If the delimiter is not quoted, the \<newline> sequence is treated
as a line continuation: the two lines are joined and the
If the delimiter is not quoted, the shell treats the \<newline>
sequence as a line continuation: the two lines are joined and the
backslash-newline is removed. This happens while reading the
here-document, before the check for the ending delimiter, so joined
lines can form the end delimiter.
@@ -7770,10 +7784,10 @@ startup files.
result from a $PATH search.
22. The message printed by the job control code and builtins when a
job exits with a non-zero status is 'Done(status)'.
job exits with a non-zero status is "Done(status)".
23. The message printed by the job control code and builtins when a
job is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for
job is stopped is "Stopped(SIGNAME)", where SIGNAME is, for
example, SIGTSTP.
24. If the shell is interactive, Bash does not perform job
@@ -8527,10 +8541,10 @@ File: bash.info, Node: Introduction and Notation, Next: Readline Interaction,
The following paragraphs use Emacs style to describe the notation used
to represent keystrokes.
The text C-k is read as 'Control-K' and describes the character
The text C-k is read as "Control-K" and describes the character
produced when the <k> key is pressed while the Control key is depressed.
The text M-k is read as 'Meta-K' and describes the character
The text M-k is read as "Meta-K" and describes the character
produced when the Meta key (if you have one) is depressed, and the <k>
key is pressed (a “meta character”), then both are released. The Meta
key is labeled <ALT> or <Option> on many keyboards. On keyboards with
@@ -8557,7 +8571,7 @@ you can make M-key key bindings you specify (see Key Bindings in
*note Readline Init File Syntax::) do the same thing by setting the
force-meta-prefix variable.
The text M-C-k is read as 'Meta-Control-k' and describes the
The text M-C-k is read as "Meta-Control-k" and describes the
character produced by metafying C-k.
In addition, several keys have their own names. Specifically, <DEL>,
@@ -8609,9 +8623,9 @@ you have typed several other characters. In that case, you can type
Afterwards, you can move the cursor to the right with C-f.
When you add text in the middle of a line, you will notice that
characters to the right of the cursor are 'pushed over' to make room for
characters to the right of the cursor are "pushed over" to make room for
the text that you have inserted. Likewise, when you delete text behind
the cursor, characters to the right of the cursor are 'pulled back' to
the cursor, characters to the right of the cursor are "pulled back" to
fill in the blank space created by the removal of the text. These are
the bare essentials for editing the text of an input line:
@@ -8669,9 +8683,9 @@ File: bash.info, Node: Readline Killing Commands, Next: Readline Arguments, P
“Killing” text means to delete the text from the line, but to save it
away for later use, usually by “yanking” (re-inserting) it back into the
line. ('Cut' and 'paste' are more recent jargon for 'kill' and 'yank'.)
line. ("Cut" and "paste" are more recent jargon for "kill" and "yank".)
If the description for a command says that it 'kills' text, then you
If the description for a command says that it "kills" text, then you
can be sure that you can get the text back in a different (or the same)
place later.
@@ -8726,13 +8740,14 @@ command which normally acts in a forward direction, that command will
act in a backward direction. For example, to kill text back to the
start of the line, you might type M-- C-k.
The general way to pass numeric arguments to a command is to type
meta digits before the command. If the first 'digit' typed is a minus
sign (-), then the sign of the argument will be negative. Once you
have typed one meta digit to get the argument started, you can type the
remainder of the digits, and then the command. For example, to give the
C-d command an argument of 10, you could type M-1 0 C-d, which will
delete the next ten characters on the input line.
The general way to pass numeric arguments to a command is to type the
Meta key and then digits ("meta digits") before the command. If the
first "digit" typed is a minus sign (-), then the sign of the argument
will be negative. Once you have typed one meta digit to get the
argument started, you can type the remainder of the digits, and then the
command. For example, to give the C-d command an argument of 10, you
could type M-1 0 C-d, which will delete the next ten characters on the
input line.

File: bash.info, Node: Searching, Prev: Readline Arguments, Up: Readline Interaction
@@ -9650,12 +9665,12 @@ File: bash.info, Node: Commands For History, Next: Commands For Text, Prev: C
original state.
previous-history (C-p)
Move 'back' through the history list, fetching the previous
Move "back" through the history list, fetching the previous
command. This may also be bound to the up arrow key on some
keyboards.
next-history (C-n)
Move 'forward' through the history list, fetching the next command.
Move "forward" through the history list, fetching the next command.
This may also be bound to the down arrow key on some keyboards.
beginning-of-history (M-<)
@@ -9666,25 +9681,26 @@ File: bash.info, Node: Commands For History, Next: Commands For Text, Prev: C
being entered.
reverse-search-history (C-r)
Search backward starting at the current line and moving 'up'
Search backward starting at the current line and moving "up"
through the history as necessary. This is an incremental search.
This command sets the region to the matched text and activates the
region.
forward-search-history (C-s)
Search forward starting at the current line and moving 'down'
Search forward starting at the current line and moving "down"
through the history as necessary. This is an incremental search.
This command sets the region to the matched text and activates the
region.
non-incremental-reverse-search-history (M-p)
Search backward starting at the current line and moving 'up'
Search backward starting at the current line and moving "up"
through the history as necessary using a non-incremental search for
a string supplied by the user. The search string may match
anywhere in a history line.
non-incremental-forward-search-history (M-n)
Search forward starting at the current line and moving 'down'
Search forward starting at the current line and moving "down"
through the history as necessary using a non-incremental search for
a string supplied by the user. The search string may match
anywhere in a history line.
@@ -10260,8 +10276,8 @@ Set Builtin::) to switch interactively between emacs and vi editing
modes, The Readline default is emacs mode.
When you enter a line in vi mode, you are already placed in
'insertion' mode, as if you had typed an i. Pressing <ESC> switches
you into 'command' mode, where you can edit the text of the line with
"insertion" mode, as if you had typed an i. Pressing <ESC> switches
you into "command" mode, where you can edit the text of the line with
the standard vi movement keys, move to previous history lines with k
and subsequent lines with j, and so forth.
@@ -11901,7 +11917,7 @@ FTP from <ftp://ftp.gnu.org/pub/gnu/bash/> and from
bashbug command to submit a bug report or use the form at the Bash
project page (https://savannah.gnu.org/projects/bash/). If you have a
fix, you are encouraged to submit that as well! Suggestions and
'philosophical' bug reports may be mailed to <bug-bash@gnu.org> or
"philosophical" bug reports may be mailed to <bug-bash@gnu.org> or
<help-bash@gnu.org>.
All bug reports should include:
@@ -11909,7 +11925,7 @@ fix, you are encouraged to submit that as well! Suggestions and
• The hardware and operating system.
• The compiler used to compile Bash.
• A description of the bug behavior.
• A short script or 'recipe' which exercises the bug and may be used
• A short script or "recipe" which exercises the bug and may be used
to reproduce it.
bashbug inserts the first three items automatically into the template
@@ -13338,7 +13354,7 @@ D.4 Function Index
* export-completions (): Commands For Completion.
(line 44)
* fetch-history (): Commands For History.
(line 108)
(line 109)
* forward-backward-delete-char (): Commands For Text. (line 23)
* forward-char (C-f): Commands For Moving. (line 14)
* forward-search-history (C-s): Commands For History.
@@ -13355,13 +13371,13 @@ D.4 Function Index
* history-expand-line (M-^): Miscellaneous Commands.
(line 127)
* history-search-backward (): Commands For History.
(line 53)
(line 54)
* history-search-forward (): Commands For History.
(line 60)
(line 61)
* history-substring-search-backward (): Commands For History.
(line 67)
(line 68)
* history-substring-search-forward (): Commands For History.
(line 73)
(line 74)
* insert-comment (M-#): Miscellaneous Commands.
(line 59)
* insert-completions (M-*): Commands For Completion.
@@ -13386,11 +13402,11 @@ D.4 Function Index
(line 18)
* next-screen-line (): Commands For Moving. (line 45)
* non-incremental-forward-search-history (M-n): Commands For History.
(line 47)
(line 48)
* non-incremental-reverse-search-history (M-p): Commands For History.
(line 41)
* operate-and-get-next (C-o): Commands For History.
(line 101)
(line 102)
* overwrite-mode (): Commands For Text. (line 77)
* possible-command-completions (C-x !): Commands For Completion.
(line 111)
@@ -13452,9 +13468,9 @@ D.4 Function Index
* yank (C-y): Commands For Killing.
(line 72)
* yank-last-arg (M-. or M-_): Commands For History.
(line 89)
(line 90)
* yank-nth-arg (M-C-y): Commands For History.
(line 79)
(line 80)
* yank-pop (M-y): Commands For Killing.
(line 75)
@@ -13635,138 +13651,138 @@ D.5 Concept Index

Tag Table:
Node: Top895
Node: Introduction2830
Node: What is Bash?3043
Node: What is a shell?4176
Node: Definitions6786
Node: Basic Shell Features10113
Node: Shell Syntax11337
Node: Shell Operation12364
Node: Quoting13655
Node: Escape Character14993
Node: Single Quotes15528
Node: Double Quotes15877
Node: ANSI-C Quoting17222
Node: Locale Translation18616
Node: Creating Internationalized Scripts20019
Node: Comments24217
Node: Shell Commands24984
Node: Reserved Words25923
Node: Simple Commands26788
Node: Pipelines27450
Node: Lists30706
Node: Compound Commands32578
Node: Looping Constructs33587
Node: Conditional Constructs36136
Node: Command Grouping51206
Node: Coprocesses52698
Node: GNU Parallel55384
Node: Shell Functions56302
Node: Shell Parameters64750
Node: Positional Parameters69651
Node: Special Parameters70741
Node: Shell Expansions74202
Node: Brace Expansion76391
Node: Tilde Expansion79727
Node: Shell Parameter Expansion82682
Node: Command Substitution103325
Node: Arithmetic Expansion106854
Node: Process Substitution108030
Node: Word Splitting109138
Node: Filename Expansion111582
Node: Pattern Matching114806
Node: Quote Removal120529
Node: Redirections120833
Node: Executing Commands131096
Node: Simple Command Expansion131763
Node: Command Search and Execution133871
Node: Command Execution Environment136315
Node: Environment139763
Node: Exit Status141666
Node: Signals143725
Node: Shell Scripts148655
Node: Shell Builtin Commands151953
Node: Bourne Shell Builtins154064
Node: Bash Builtins180783
Node: Modifying Shell Behavior217707
Node: The Set Builtin218049
Node: The Shopt Builtin230043
Node: Special Builtins247096
Node: Shell Variables248085
Node: Bourne Shell Variables248519
Node: Bash Variables251027
Node: Bash Features290152
Node: Invoking Bash291166
Node: Bash Startup Files297750
Node: Interactive Shells302992
Node: What is an Interactive Shell?303400
Node: Is this Shell Interactive?304062
Node: Interactive Shell Behavior304886
Node: Bash Conditional Expressions308647
Node: Shell Arithmetic314064
Node: Aliases317391
Node: Arrays320525
Node: The Directory Stack328113
Node: Directory Stack Builtins328910
Node: Controlling the Prompt333355
Node: The Restricted Shell336240
Node: Bash POSIX Mode339122
Node: Shell Compatibility Mode358069
Node: Job Control367076
Node: Job Control Basics367533
Node: Job Control Builtins373901
Node: Job Control Variables380583
Node: Command Line Editing381814
Node: Introduction and Notation383517
Node: Readline Interaction385869
Node: Readline Bare Essentials387057
Node: Readline Movement Commands388865
Node: Readline Killing Commands389861
Node: Readline Arguments391884
Node: Searching392941
Node: Readline Init File395184
Node: Readline Init File Syntax396487
Node: Conditional Init Constructs423438
Node: Sample Init File427823
Node: Bindable Readline Commands430943
Node: Commands For Moving432481
Node: Commands For History434945
Node: Commands For Text440335
Node: Commands For Killing444460
Node: Numeric Arguments447248
Node: Commands For Completion448400
Node: Keyboard Macros454096
Node: Miscellaneous Commands454797
Node: Readline vi Mode461364
Node: Programmable Completion462341
Node: Programmable Completion Builtins472077
Node: A Programmable Completion Example483814
Node: Using History Interactively489159
Node: Bash History Facilities489840
Node: Bash History Builtins493575
Node: History Interaction500046
Node: Event Designators504996
Node: Word Designators506574
Node: Modifiers508966
Node: Installing Bash510903
Node: Basic Installation512019
Node: Compilers and Options515895
Node: Compiling For Multiple Architectures516645
Node: Installation Names518398
Node: Specifying the System Type520632
Node: Sharing Defaults521378
Node: Operation Controls522092
Node: Optional Features523111
Node: Reporting Bugs535834
Node: Major Differences From The Bourne Shell537191
Node: GNU Free Documentation License558618
Node: Indexes583795
Node: Builtin Index584246
Node: Reserved Word Index591344
Node: Variable Index593789
Node: Function Index611202
Node: Concept Index625197
Node: Top901
Node: Introduction2842
Node: What is Bash?3055
Node: What is a shell?4188
Node: Definitions6798
Node: Basic Shell Features10125
Node: Shell Syntax11349
Node: Shell Operation12376
Node: Quoting13667
Node: Escape Character15005
Node: Single Quotes15540
Node: Double Quotes15889
Node: ANSI-C Quoting17234
Node: Locale Translation18628
Node: Creating Internationalized Scripts20031
Node: Comments24229
Node: Shell Commands24996
Node: Reserved Words25935
Node: Simple Commands27078
Node: Pipelines27740
Node: Lists30996
Node: Compound Commands32916
Node: Looping Constructs33925
Node: Conditional Constructs36474
Node: Command Grouping51611
Node: Coprocesses53103
Node: GNU Parallel55789
Node: Shell Functions56707
Node: Shell Parameters65155
Node: Positional Parameters70056
Node: Special Parameters71146
Node: Shell Expansions74607
Node: Brace Expansion76796
Node: Tilde Expansion80132
Node: Shell Parameter Expansion83087
Node: Command Substitution103730
Node: Arithmetic Expansion107259
Node: Process Substitution108435
Node: Word Splitting109543
Node: Filename Expansion111987
Node: Pattern Matching115211
Node: Quote Removal120934
Node: Redirections121238
Node: Executing Commands131494
Node: Simple Command Expansion132161
Node: Command Search and Execution134269
Node: Command Execution Environment136713
Node: Environment140161
Node: Exit Status142064
Node: Signals144123
Node: Shell Scripts149053
Node: Shell Builtin Commands152351
Node: Bourne Shell Builtins154462
Node: Bash Builtins181181
Node: Modifying Shell Behavior218105
Node: The Set Builtin218447
Node: The Shopt Builtin230441
Node: Special Builtins247494
Node: Shell Variables248483
Node: Bourne Shell Variables248917
Node: Bash Variables251425
Node: Bash Features290550
Node: Invoking Bash291564
Node: Bash Startup Files298148
Node: Interactive Shells303390
Node: What is an Interactive Shell?303798
Node: Is this Shell Interactive?304460
Node: Interactive Shell Behavior305284
Node: Bash Conditional Expressions309045
Node: Shell Arithmetic314462
Node: Aliases317789
Node: Arrays320923
Node: The Directory Stack328511
Node: Directory Stack Builtins329308
Node: Controlling the Prompt333753
Node: The Restricted Shell336638
Node: Bash POSIX Mode339520
Node: Shell Compatibility Mode358467
Node: Job Control367474
Node: Job Control Basics367931
Node: Job Control Builtins374299
Node: Job Control Variables380981
Node: Command Line Editing382212
Node: Introduction and Notation383915
Node: Readline Interaction386267
Node: Readline Bare Essentials387455
Node: Readline Movement Commands389263
Node: Readline Killing Commands390259
Node: Readline Arguments392282
Node: Searching393372
Node: Readline Init File395615
Node: Readline Init File Syntax396918
Node: Conditional Init Constructs423869
Node: Sample Init File428254
Node: Bindable Readline Commands431374
Node: Commands For Moving432912
Node: Commands For History435376
Node: Commands For Text440767
Node: Commands For Killing444892
Node: Numeric Arguments447680
Node: Commands For Completion448832
Node: Keyboard Macros454528
Node: Miscellaneous Commands455229
Node: Readline vi Mode461796
Node: Programmable Completion462773
Node: Programmable Completion Builtins472509
Node: A Programmable Completion Example484246
Node: Using History Interactively489591
Node: Bash History Facilities490272
Node: Bash History Builtins494007
Node: History Interaction500478
Node: Event Designators505428
Node: Word Designators507006
Node: Modifiers509398
Node: Installing Bash511335
Node: Basic Installation512451
Node: Compilers and Options516327
Node: Compiling For Multiple Architectures517077
Node: Installation Names518830
Node: Specifying the System Type521064
Node: Sharing Defaults521810
Node: Operation Controls522524
Node: Optional Features523543
Node: Reporting Bugs536266
Node: Major Differences From The Bourne Shell537623
Node: GNU Free Documentation License559050
Node: Indexes584227
Node: Builtin Index584678
Node: Reserved Word Index591776
Node: Variable Index594221
Node: Function Index611634
Node: Concept Index625629

End Tag Table
+104 -87
View File
@@ -4,9 +4,9 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This text is a brief description of the features that are present in
the Bash shell (version 5.3, 7 August 2025).
the Bash shell (version 5.3, 6 September 2025).
This is Edition 5.3, last updated 7 August 2025,
This is Edition 5.3, last updated 6 September 2025,
of The GNU Bash Reference Manual,
for Bash, Version 5.3.
@@ -77,10 +77,10 @@ Next: <a href="#Introduction" accesskey="n" rel="next">Introduction</a>, Previou
<h1 class="top" id="Bash-Features-1"><span>Bash Features<a class="copiable-link" href="#Bash-Features-1"> &para;</a></span></h1>
<p>This text is a brief description of the features that are present in
the Bash shell (version 5.3, 7 August 2025).
the Bash shell (version 5.3, 6 September 2025).
The Bash home page is <a class="url" href="http://www.gnu.org/software/bash/">http://www.gnu.org/software/bash/</a>.
</p>
<p>This is Edition 5.3, last updated 7 August 2025,
<p>This is Edition 5.3, last updated 6 September 2025,
of <cite class="cite">The GNU Bash Reference Manual</cite>,
for <code class="code">Bash</code>, Version 5.3.
</p>
@@ -552,9 +552,9 @@ The Bourne shell is
the traditional Unix shell originally written by Stephen Bourne.
All of the Bourne shell builtin commands are available in Bash, and
the rules for evaluation and quoting are taken from the <small class="sc">POSIX</small>
specification for the &lsquo;standard&rsquo; Unix shell.
specification for the &ldquo;standard&rdquo; Unix shell.
</p>
<p>This chapter briefly summarizes the shell&rsquo;s &lsquo;building blocks&rsquo;:
<p>This chapter briefly summarizes the shell&rsquo;s &ldquo;building blocks&rdquo;:
commands, control structures, shell functions, shell <i class="i">parameters</i>,
shell expansions,
<i class="i">redirections</i>, which are a way to direct input and output from
@@ -1033,8 +1033,23 @@ Next: <a href="#Simple-Commands" accesskey="n" rel="next">Simple Commands</a>, U
<p>Reserved words are words that have special meaning to the shell.
They are used to begin and end the shell&rsquo;s compound commands.
</p>
<p>The following words are recognized as reserved when unquoted and
the first word of a command (see below for exceptions):
<p>Reserved words are recognized as reserved when unquoted and either
</p>
<ul class="itemize mark-bullet">
<li>the first word of a command;
</li><li>the first word following a reserved word
other than <code class="code">case</code>, <code class="code">for</code>, <code class="code">select</code>, or <code class="code">in</code>;
</li><li>the third word of a <code class="code">case</code> command
(only <code class="code">in</code> is valid);
</li><li>the third word of a <code class="code">for</code> or <code class="code">select</code>
command (only <code class="code">in</code> and <code class="code">do</code> are valid);
</li><li>following a control operator.
</li></ul>
<p>The shell will also recognize reserved words where the syntax of a command
specifically requires the reserved word as the only correct token.
</p>
<p>The following are reserved words:
</p>
<table class="multitable">
<tbody><tr><td width="10%"><code class="code">if</code></td><td width="10%"><code class="code">then</code></td><td width="10%"><code class="code">elif</code></td><td width="10%"><code class="code">else</code></td><td width="12%"><code class="code">fi</code></td><td width="10%"><code class="code">time</code></td></tr>
@@ -1044,11 +1059,6 @@ the first word of a command (see below for exceptions):
</tbody>
</table>
<p><code class="code">in</code> is recognized as a reserved word if it is the third word of a
<code class="code">case</code> or <code class="code">select</code> command.
<code class="code">in</code> and <code class="code">do</code> are recognized as reserved
words if they are the third word in a <code class="code">for</code> command.
</p>
<hr>
</div>
<div class="subsection-level-extent" id="Simple-Commands">
@@ -1166,10 +1176,37 @@ Next: <a href="#Compound-Commands" accesskey="n" rel="next">Compound Commands</a
<h4 class="subsection" id="Lists-of-Commands"><span>3.2.4 Lists of Commands<a class="copiable-link" href="#Lists-of-Commands"> &para;</a></span></h4>
<a class="index-entry-id" id="index-commands_002c-lists"></a>
<p>A <code class="code">list</code> is a sequence of one or more pipelines separated by one
of the operators &lsquo;<samp class="samp">;</samp>&rsquo;, &lsquo;<samp class="samp">&amp;</samp>&rsquo;, &lsquo;<samp class="samp">&amp;&amp;</samp>&rsquo;, or &lsquo;<samp class="samp">||</samp>&rsquo;,
and optionally terminated by one of &lsquo;<samp class="samp">;</samp>&rsquo;, &lsquo;<samp class="samp">&amp;</samp>&rsquo;, or a
<code class="code">newline</code>.
<p>A <code class="code">list</code> is a sequence of one or more <small class="sc">AND</small> or <small class="sc">OR</small> lists
separated by one of the operators
&lsquo;<samp class="samp">;</samp>&rsquo; or &lsquo;<samp class="samp">&amp;</samp>&rsquo;, or a <code class="code">newline</code>,
and optionally terminated by one of those three characters.
</p>
<p><small class="sc">AND</small> and <small class="sc">OR</small> lists are sequences of one or more pipelines
separated by the control operators &lsquo;<samp class="samp">&amp;&amp;</samp>&rsquo; and &lsquo;<samp class="samp">||</samp>&rsquo;,
respectively.
<small class="sc">AND</small> and <small class="sc">OR</small> lists are executed with left associativity.
</p>
<p>An <small class="sc">AND</small> list has the form
</p>
<div class="example">
<pre class="example-preformatted"><var class="var">command1</var> &amp;&amp; <var class="var">command2</var>
</pre></div>
<p><var class="var">command2</var> is executed if, and only if, <var class="var">command1</var>
returns an exit status of zero (success).
</p>
<p>An <small class="sc">OR</small> list has the form
</p>
<div class="example">
<pre class="example-preformatted"><var class="var">command1</var> || <var class="var">command2</var>
</pre></div>
<p><var class="var">command2</var> is executed if, and only if, <var class="var">command1</var>
returns a non-zero exit status.
</p>
<p>The return status of
<small class="sc">AND</small> and <small class="sc">OR</small> lists is the exit status of the last command
executed in the list.
</p>
<p>Of these list operators, &lsquo;<samp class="samp">&amp;&amp;</samp>&rsquo; and &lsquo;<samp class="samp">||</samp>&rsquo;
have equal precedence, followed by &lsquo;<samp class="samp">;</samp>&rsquo; and &lsquo;<samp class="samp">&amp;</samp>&rsquo;,
@@ -1188,34 +1225,12 @@ When job control is not active (see <a class="pxref" href="#Job-Control">Job Con
the standard input for asynchronous commands, in the absence of any
explicit redirections, is redirected from <code class="code">/dev/null</code>.
</p>
<p>Commands separated by a &lsquo;<samp class="samp">;</samp>&rsquo; are executed sequentially; the shell
waits for each command to terminate in turn.
The return status is the exit status of the last command executed.
<p>Commands separated or terminated by
&lsquo;<samp class="samp">;</samp>&rsquo; (or equivalent <code class="code">newline</code>)
are executed sequentially; the shell waits for each
command to terminate in turn.
</p>
<p><small class="sc">AND</small> and <small class="sc">OR</small> lists are sequences of one or more pipelines
separated by the control operators &lsquo;<samp class="samp">&amp;&amp;</samp>&rsquo; and &lsquo;<samp class="samp">||</samp>&rsquo;,
respectively.
<small class="sc">AND</small> and <small class="sc">OR</small> lists are executed with left associativity.
</p>
<p>An <small class="sc">AND</small> list has the form
</p><div class="example">
<pre class="example-preformatted"><var class="var">command1</var> &amp;&amp; <var class="var">command2</var>
</pre></div>
<p><var class="var">command2</var> is executed if, and only if, <var class="var">command1</var>
returns an exit status of zero (success).
</p>
<p>An <small class="sc">OR</small> list has the form
</p><div class="example">
<pre class="example-preformatted"><var class="var">command1</var> || <var class="var">command2</var>
</pre></div>
<p><var class="var">command2</var> is executed if, and only if, <var class="var">command1</var>
returns a non-zero exit status.
</p>
<p>The return status of
<small class="sc">AND</small> and <small class="sc">OR</small> lists is the exit status of the last command
executed in the list.
<p>The return status of a list is the exit status of the last command executed.
</p>
<hr>
</div>
@@ -1387,26 +1402,24 @@ the first <var class="var">pattern</var> that matches <var class="var">word</var
proceeding from the first pattern to the last.
The match is performed according
to the rules described below in <a class="ref" href="#Pattern-Matching">Pattern Matching</a>.
If the <code class="code">nocasematch</code> shell option
(see the description of <code class="code">shopt</code> in <a class="ref" href="#The-Shopt-Builtin">The Shopt Builtin</a>)
is enabled, the match is performed without regard to the case
of alphabetic characters.
The &lsquo;<samp class="samp">|</samp>&rsquo; is used to separate multiple patterns in a pattern list,
and the &lsquo;<samp class="samp">)</samp>&rsquo; operator terminates the pattern list.
A pattern list and an associated <var class="var">command-list</var> is known
as a <var class="var">clause</var>.
</p>
<p>Each clause must be terminated with &lsquo;<samp class="samp">;;</samp>&rsquo;, &lsquo;<samp class="samp">;&amp;</samp>&rsquo;, or &lsquo;<samp class="samp">;;&amp;</samp>&rsquo;.
The <var class="var">word</var> undergoes tilde expansion, parameter expansion, command
substitution, process substitution, arithmetic expansion, and quote removal
(see <a class="pxref" href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>)
before the shell attempts to match the pattern.
Each <var class="var">pattern</var> undergoes tilde expansion, parameter expansion,
Each <var class="var">pattern</var> examined undergoes tilde expansion, parameter expansion,
command substitution, arithmetic expansion, process substitution, and
quote removal.
If the <code class="code">nocasematch</code> shell option
(see the description of <code class="code">shopt</code> in <a class="ref" href="#The-Shopt-Builtin">The Shopt Builtin</a>)
is enabled, the match is performed without regard to the case
of alphabetic characters.
</p>
<p>There may be an arbitrary number of <code class="code">case</code> clauses, each terminated
by a &lsquo;<samp class="samp">;;</samp>&rsquo;, &lsquo;<samp class="samp">;&amp;</samp>&rsquo;, or &lsquo;<samp class="samp">;;&amp;</samp>&rsquo;.
<p>A pattern list is a set of one or more patterns separated by &lsquo;<samp class="samp">|</samp>&rsquo;,
and terminated by the &lsquo;<samp class="samp">)</samp>&rsquo; operator.
A case <var class="var">clause</var> is a pattern list and an associated <var class="var">command-list</var>,
terminated by &lsquo;<samp class="samp">;;</samp>&rsquo;, &lsquo;<samp class="samp">;&amp;</samp>&rsquo;, or &lsquo;<samp class="samp">;;&amp;</samp>&rsquo;.
The terminator is optional for the last clause preceding <code class="code">esac</code>.
There may be an arbitrary number of <code class="code">case</code> clauses.
The first pattern that matches determines the
command-list that is executed.
It&rsquo;s a common idiom to use &lsquo;<samp class="samp">*</samp>&rsquo; as the final pattern to define the
@@ -1428,11 +1441,13 @@ echo &quot; legs.&quot;
</pre></div>
<p>If the &lsquo;<samp class="samp">;;</samp>&rsquo; operator is used, the <code class="code">case</code> command completes
after the first pattern match.
Using &lsquo;<samp class="samp">;&amp;</samp>&rsquo; in place of &lsquo;<samp class="samp">;;</samp>&rsquo; causes execution to continue with
<p>When a match is found, <code class="code">case</code> executes
the corresponding <var class="var">command-list</var>.
If the &lsquo;<samp class="samp">;;</samp>&rsquo; operator terminates the case clause,
the <code class="code">case</code> command completes after the first pattern match.
Using the &lsquo;<samp class="samp">;&amp;</samp>&rsquo; terminator continues execution with
the <var class="var">command-list</var> associated with the next clause, if any.
Using &lsquo;<samp class="samp">;;&amp;</samp>&rsquo; in place of &lsquo;<samp class="samp">;;</samp>&rsquo; causes the shell to test the patterns
Using the &lsquo;<samp class="samp">;;&amp;</samp>&rsquo; terminator causes the shell to test the pattern list
in the next clause, if any, and execute any associated <var class="var">command-list</var>
if the match succeeds,
continuing the case statement execution as if the pattern list had not matched.
@@ -4011,14 +4026,14 @@ and &lsquo;<samp class="samp">\</samp>&rsquo; must be used to quote the characte
however, double quote characters have no special meaning.
</p>
<p>If the redirection operator is &lsquo;<samp class="samp">&lt;&lt;-</samp>&rsquo;,
the shell strips leading tab characters are stripped from input lines
the shell strips leading tab characters from input lines
and the line containing <var class="var">delimiter</var>.
This allows here-documents within shell scripts to be indented in a
natural fashion.
</p>
<p>If the delimiter is not quoted, the
<p>If the delimiter is not quoted, the shell treats the
<code class="code">\&lt;newline&gt;</code>
sequence is treated as a line continuation: the two lines are joined
sequence as a line continuation: the two lines are joined
and the backslash-newline is removed.
This happens while reading the here-document, before the check for
the ending delimiter, so joined lines can form the end delimiter.
@@ -10302,10 +10317,10 @@ command hash table, even if it returns it as a (last-ditch) result
from a <code class="env">$PATH</code> search.
</li><li> The message printed by the job control code and builtins when a job
exits with a non-zero status is &lsquo;Done(status)&rsquo;.
exits with a non-zero status is &ldquo;Done(status)&rdquo;.
</li><li> The message printed by the job control code and builtins when a job
is stopped is &lsquo;Stopped(<var class="var">signame</var>)&rsquo;, where <var class="var">signame</var> is, for
is stopped is &ldquo;Stopped(<var class="var">signame</var>)&rdquo;, where <var class="var">signame</var> is, for
example, <code class="code">SIGTSTP</code>.
</li><li> If the shell is interactive, Bash does not perform job notifications
@@ -11266,11 +11281,11 @@ Next: <a href="#Readline-Interaction" accesskey="n" rel="next">Readline Interact
<p>The following paragraphs use Emacs style to
describe the notation used to represent keystrokes.
</p>
<p>The text <kbd class="kbd">C-k</kbd> is read as &lsquo;Control-K&rsquo; and describes the character
<p>The text <kbd class="kbd">C-k</kbd> is read as &ldquo;Control-K&rdquo; and describes the character
produced when the <kbd class="key">k</kbd> key is pressed while the Control key
is depressed.
</p>
<p>The text <kbd class="kbd">M-k</kbd> is read as &lsquo;Meta-K&rsquo; and describes the character
<p>The text <kbd class="kbd">M-k</kbd> is read as &ldquo;Meta-K&rdquo; and describes the character
produced when the Meta key (if you have one) is depressed, and the <kbd class="key">k</kbd>
key is pressed (a <em class="dfn">meta character</em>), then both are released.
The Meta key is labeled <kbd class="key">ALT</kbd> or <kbd class="key">Option</kbd> on many keyboards.
@@ -11301,7 +11316,7 @@ you can make <kbd class="kbd">M-key</kbd> key bindings you specify
(see <code class="code">Key Bindings</code> in <a class="ref" href="#Readline-Init-File-Syntax">Readline Init File Syntax</a>)
do the same thing by setting the <code class="code">force-meta-prefix</code> variable.
</p>
<p>The text <kbd class="kbd">M-C-k</kbd> is read as &lsquo;Meta-Control-k&rsquo; and describes the
<p>The text <kbd class="kbd">M-C-k</kbd> is read as &ldquo;Meta-Control-k&rdquo; and describes the
character produced by metafying <kbd class="kbd">C-k</kbd>.
</p>
<p>In addition, several keys have their own names.
@@ -11370,10 +11385,10 @@ and then correct your mistake.
Afterwards, you can move the cursor to the right with <kbd class="kbd">C-f</kbd>.
</p>
<p>When you add text in the middle of a line, you will notice that characters
to the right of the cursor are &lsquo;pushed over&rsquo; to make room for the text
to the right of the cursor are &ldquo;pushed over&rdquo; to make room for the text
that you have inserted.
Likewise, when you delete text behind the cursor,
characters to the right of the cursor are &lsquo;pulled back&rsquo; to fill in the
characters to the right of the cursor are &ldquo;pulled back&rdquo; to fill in the
blank space created by the removal of the text.
These are the bare
essentials for editing the text of an input line:
@@ -11458,9 +11473,9 @@ Next: <a href="#Readline-Arguments" accesskey="n" rel="next">Readline Arguments<
<p><em class="dfn">Killing</em> text means to delete the text from the line, but to save
it away for later use, usually by <em class="dfn">yanking</em> (re-inserting)
it back into the line.
(&lsquo;Cut&rsquo; and &lsquo;paste&rsquo; are more recent jargon for &lsquo;kill&rsquo; and &lsquo;yank&rsquo;.)
(&ldquo;Cut&rdquo; and &ldquo;paste&rdquo; are more recent jargon for &ldquo;kill&rdquo; and &ldquo;yank&rdquo;.)
</p>
<p>If the description for a command says that it &lsquo;kills&rsquo; text, then you can
<p>If the description for a command says that it &ldquo;kills&rdquo; text, then you can
be sure that you can get the text back in a different (or the same)
place later.
</p>
@@ -11533,9 +11548,10 @@ act in a backward direction.
For example, to kill text back to the
start of the line, you might type &lsquo;<samp class="samp">M-- C-k</samp>&rsquo;.
</p>
<p>The general way to pass numeric arguments to a command is to type meta
digits before the command.
If the first &lsquo;digit&rsquo; typed is a minus
<p>The general way to pass numeric arguments to a command is to type
the Meta key and then digits (&ldquo;meta digits&rdquo;)
before the command.
If the first &ldquo;digit&rdquo; typed is a minus
sign (&lsquo;<samp class="samp">-</samp>&rsquo;), then the sign of the argument will be negative.
Once you have typed one meta digit to get the argument started, you can
type the remainder of the digits, and then the command.
@@ -12709,12 +12725,12 @@ to its original state.
</p>
</dd>
<dt><a id="index-previous_002dhistory-_0028C_002dp_0029"></a><span><code class="code">previous-history (C-p)</code><a class="copiable-link" href="#index-previous_002dhistory-_0028C_002dp_0029"> &para;</a></span></dt>
<dd><p>Move &lsquo;back&rsquo; through the history list, fetching the previous command.
<dd><p>Move &ldquo;back&rdquo; through the history list, fetching the previous command.
This may also be bound to the up arrow key on some keyboards.
</p>
</dd>
<dt><a id="index-next_002dhistory-_0028C_002dn_0029"></a><span><code class="code">next-history (C-n)</code><a class="copiable-link" href="#index-next_002dhistory-_0028C_002dn_0029"> &para;</a></span></dt>
<dd><p>Move &lsquo;forward&rsquo; through the history list, fetching the next command.
<dd><p>Move &ldquo;forward&rdquo; through the history list, fetching the next command.
This may also be bound to the down arrow key on some keyboards.
</p>
</dd>
@@ -12728,28 +12744,29 @@ being entered.
</p>
</dd>
<dt><a id="index-reverse_002dsearch_002dhistory-_0028C_002dr_0029"></a><span><code class="code">reverse-search-history (C-r)</code><a class="copiable-link" href="#index-reverse_002dsearch_002dhistory-_0028C_002dr_0029"> &para;</a></span></dt>
<dd><p>Search backward starting at the current line and moving &lsquo;up&rsquo; through
<dd><p>Search backward starting at the current line and moving &ldquo;up&rdquo; through
the history as necessary.
This is an incremental search.
This command sets the region to the matched text and activates the region.
</p>
</dd>
<dt><a id="index-forward_002dsearch_002dhistory-_0028C_002ds_0029"></a><span><code class="code">forward-search-history (C-s)</code><a class="copiable-link" href="#index-forward_002dsearch_002dhistory-_0028C_002ds_0029"> &para;</a></span></dt>
<dd><p>Search forward starting at the current line and moving &lsquo;down&rsquo; through
<dd><p>Search forward starting at the current line and moving &ldquo;down&rdquo; through
the history as necessary.
This is an incremental search.
This command sets the region to the matched text and activates the region.
</p>
</dd>
<dt><a id="index-non_002dincremental_002dreverse_002dsearch_002dhistory-_0028M_002dp_0029"></a><span><code class="code">non-incremental-reverse-search-history (M-p)</code><a class="copiable-link" href="#index-non_002dincremental_002dreverse_002dsearch_002dhistory-_0028M_002dp_0029"> &para;</a></span></dt>
<dd><p>Search backward starting at the current line and moving &lsquo;up&rsquo;
through the history as necessary using a non-incremental search
<dd><p>Search backward starting at the current line and moving &ldquo;up&rdquo;
</p>
<p>through the history as necessary using a non-incremental search
for a string supplied by the user.
The search string may match anywhere in a history line.
</p>
</dd>
<dt><a id="index-non_002dincremental_002dforward_002dsearch_002dhistory-_0028M_002dn_0029"></a><span><code class="code">non-incremental-forward-search-history (M-n)</code><a class="copiable-link" href="#index-non_002dincremental_002dforward_002dsearch_002dhistory-_0028M_002dn_0029"> &para;</a></span></dt>
<dd><p>Search forward starting at the current line and moving &lsquo;down&rsquo;
<dd><p>Search forward starting at the current line and moving &ldquo;down&rdquo;
through the history as necessary using a non-incremental search
for a string supplied by the user.
The search string may match anywhere in a history line.
@@ -13519,8 +13536,8 @@ editing modes,
The Readline default is <code class="code">emacs</code> mode.
</p>
<p>When you enter a line in <code class="code">vi</code> mode, you are already placed in
&lsquo;insertion&rsquo; mode, as if you had typed an &lsquo;<samp class="samp">i</samp>&rsquo;. Pressing <kbd class="key">ESC</kbd>
switches you into &lsquo;command&rsquo; mode, where you can edit the text of the
&ldquo;insertion&rdquo; mode, as if you had typed an &lsquo;<samp class="samp">i</samp>&rsquo;. Pressing <kbd class="key">ESC</kbd>
switches you into &ldquo;command&rdquo; mode, where you can edit the text of the
line with the standard <code class="code">vi</code> movement keys, move to previous
history lines with &lsquo;<samp class="samp">k</samp>&rsquo; and subsequent lines with &lsquo;<samp class="samp">j</samp>&rsquo;, and
so forth.
@@ -15645,7 +15662,7 @@ The latest released version of Bash is always available for FTP from
<code class="code">bashbug</code> command to submit a bug report or use the form at the
<a class="uref" href="https://savannah.gnu.org/projects/bash/">Bash project page</a>.
If you have a fix, you are encouraged to submit that as well!
Suggestions and &lsquo;philosophical&rsquo; bug reports may be mailed
Suggestions and &ldquo;philosophical&rdquo; bug reports may be mailed
to <a class="email" href="mailto:bug-bash@gnu.org">bug-bash@gnu.org</a> or <a class="email" href="mailto:help-bash@gnu.org">help-bash@gnu.org</a>.
</p>
<p>All bug reports should include:
@@ -15654,7 +15671,7 @@ to <a class="email" href="mailto:bug-bash@gnu.org">bug-bash@gnu.org</a> or <a cl
</li><li>The hardware and operating system.
</li><li>The compiler used to compile Bash.
</li><li>A description of the bug behavior.
</li><li>A short script or &lsquo;recipe&rsquo; which exercises the bug and may be used
</li><li>A short script or &ldquo;recipe&rdquo; which exercises the bug and may be used
to reproduce it.
</li></ul>
+249 -233
View File
@@ -2,9 +2,9 @@ This is bashref.info, produced by makeinfo version 7.2 from
bashref.texi.
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 7 August 2025).
Bash shell (version 5.3, 6 September 2025).
This is Edition 5.3, last updated 7 August 2025, of The GNU Bash
This is Edition 5.3, last updated 6 September 2025, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Copyright © 1988-2025 Free Software Foundation, Inc.
@@ -27,10 +27,10 @@ Bash Features
*************
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 7 August 2025). The Bash home page is
Bash shell (version 5.3, 6 September 2025). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.3, last updated 7 August 2025, of The GNU Bash
This is Edition 5.3, last updated 6 September 2025, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Bash contains features that appear in other popular shells, and some
@@ -260,9 +260,9 @@ Bash is an acronym for Bourne-Again SHell. The Bourne shell is the
traditional Unix shell originally written by Stephen Bourne. All of the
Bourne shell builtin commands are available in Bash, and the rules for
evaluation and quoting are taken from the POSIX specification for the
'standard' Unix shell.
"standard" Unix shell.
This chapter briefly summarizes the shell's 'building blocks':
This chapter briefly summarizes the shell's "building blocks":
commands, control structures, shell functions, shell parameters, shell
expansions, redirections, which are a way to direct input and output
from and to named files, and how the shell executes commands.
@@ -643,18 +643,27 @@ File: bashref.info, Node: Reserved Words, Next: Simple Commands, Up: Shell Co
Reserved words are words that have special meaning to the shell. They
are used to begin and end the shell's compound commands.
The following words are recognized as reserved when unquoted and the
first word of a command (see below for exceptions):
Reserved words are recognized as reserved when unquoted and either
• the first word of a command;
• the first word following a reserved word other than case, for,
select, or in;
• the third word of a case command (only in is valid);
• the third word of a for or select command (only in and do
are valid);
• following a control operator.
The shell will also recognize reserved words where the syntax of a
command specifically requires the reserved word as the only correct
token.
The following are reserved words:
if then elif else fi time
for in until while do done
case esac coproc’‘select’‘function
‘{’ ‘}’ ‘[[’ ‘]]’ ‘!’
in is recognized as a reserved word if it is the third word of a
case or select command. in and do are recognized as reserved
words if they are the third word in a for command.

File: bashref.info, Node: Simple Commands, Next: Pipelines, Prev: Reserved Words, Up: Shell Commands
@@ -741,9 +750,30 @@ File: bashref.info, Node: Lists, Next: Compound Commands, Prev: Pipelines, U
3.2.4 Lists of Commands
-----------------------
A list is a sequence of one or more pipelines separated by one of the
operators ;, &, &&, or ||, and optionally terminated by one of
;, &, or a newline.
A list is a sequence of one or more AND or OR lists separated by one
of the operators ; or &, or a newline, and optionally terminated
by one of those three characters.
AND and OR lists are sequences of one or more pipelines separated by
the control operators && and ||, respectively. AND and OR lists are
executed with left associativity.
An AND list has the form
COMMAND1 && COMMAND2
COMMAND2 is executed if, and only if, COMMAND1 returns an exit status of
zero (success).
An OR list has the form
COMMAND1 || COMMAND2
COMMAND2 is executed if, and only if, COMMAND1 returns a non-zero exit
status.
The return status of AND and OR lists is the exit status of the last
command executed in the list.
Of these list operators, && and || have equal precedence,
followed by ; and &, which have equal precedence.
@@ -760,28 +790,12 @@ active (*note Job Control::), the standard input for asynchronous
commands, in the absence of any explicit redirections, is redirected
from /dev/null.
Commands separated by a ; are executed sequentially; the shell
waits for each command to terminate in turn. The return status is the
exit status of the last command executed.
Commands separated or terminated by ; (or equivalent newline) are
executed sequentially; the shell waits for each command to terminate in
turn.
AND and OR lists are sequences of one or more pipelines separated by
the control operators && and ||, respectively. AND and OR lists are
executed with left associativity.
An AND list has the form
COMMAND1 && COMMAND2
COMMAND2 is executed if, and only if, COMMAND1 returns an exit status of
zero (success).
An OR list has the form
COMMAND1 || COMMAND2
COMMAND2 is executed if, and only if, COMMAND1 returns a non-zero exit
status.
The return status of AND and OR lists is the exit status of the last
command executed in the list.
The return status of a list is the exit status of the last command
executed.

File: bashref.info, Node: Compound Commands, Next: Coprocesses, Prev: Lists, Up: Shell Commands
@@ -910,27 +924,25 @@ File: bashref.info, Node: Conditional Constructs, Next: Command Grouping, Pre
case will selectively execute the COMMAND-LIST corresponding to
the first PATTERN that matches WORD, proceeding from the first
pattern to the last. The match is performed according to the rules
described below in *note Pattern Matching::. If the nocasematch
described below in *note Pattern Matching::. The WORD undergoes
tilde expansion, parameter expansion, command substitution, process
substitution, arithmetic expansion, and quote removal (*note Shell
Parameter Expansion::) before the shell attempts to match the
pattern. Each PATTERN examined undergoes tilde expansion,
parameter expansion, command substitution, arithmetic expansion,
process substitution, and quote removal. If the nocasematch
shell option (see the description of shopt in *note The Shopt
Builtin::) is enabled, the match is performed without regard to the
case of alphabetic characters. The | is used to separate
multiple patterns in a pattern list, and the ) operator
terminates the pattern list. A pattern list and an associated
COMMAND-LIST is known as a CLAUSE.
case of alphabetic characters.
Each clause must be terminated with ;;, ;&, or ;;&. The WORD
undergoes tilde expansion, parameter expansion, command
substitution, process substitution, arithmetic expansion, and quote
removal (*note Shell Parameter Expansion::) before the shell
attempts to match the pattern. Each PATTERN undergoes tilde
expansion, parameter expansion, command substitution, arithmetic
expansion, process substitution, and quote removal.
There may be an arbitrary number of case clauses, each terminated
by a ;;, ;&, or ;;&. The first pattern that matches
determines the command-list that is executed. It's a common idiom
to use * as the final pattern to define the default case, since
that pattern will always match.
A pattern list is a set of one or more patterns separated by |,
and terminated by the ) operator. A case CLAUSE is a pattern
list and an associated COMMAND-LIST, terminated by ;;, ;&, or
;;&. The terminator is optional for the last clause preceding
esac. There may be an arbitrary number of case clauses. The
first pattern that matches determines the command-list that is
executed. It's a common idiom to use * as the final pattern to
define the default case, since that pattern will always match.
Here is an example using case in a script that could be used to
describe one interesting feature of an animal:
@@ -945,13 +957,15 @@ File: bashref.info, Node: Conditional Constructs, Next: Command Grouping, Pre
esac
echo " legs."
If the ;; operator is used, the case command completes after
the first pattern match. Using ;& in place of ;; causes
execution to continue with the COMMAND-LIST associated with the
next clause, if any. Using ;;& in place of ;; causes the shell
to test the patterns in the next clause, if any, and execute any
associated COMMAND-LIST if the match succeeds, continuing the case
statement execution as if the pattern list had not matched.
When a match is found, case executes the corresponding
COMMAND-LIST. If the ;; operator terminates the case clause, the
case command completes after the first pattern match. Using the
;& terminator continues execution with the COMMAND-LIST
associated with the next clause, if any. Using the ;;&
terminator causes the shell to test the pattern list in the next
clause, if any, and execute any associated COMMAND-LIST if the
match succeeds, continuing the case statement execution as if the
pattern list had not matched.
The return status is zero if no PATTERN matches. Otherwise, the
return status is the exit status of the last COMMAND-LIST executed.
@@ -2891,12 +2905,12 @@ characters \, $, and `; however, double quote characters have
special meaning.
If the redirection operator is <<-, the shell strips leading tab
characters are stripped from input lines and the line containing
DELIMITER. This allows here-documents within shell scripts to be
indented in a natural fashion.
characters from input lines and the line containing DELIMITER. This
allows here-documents within shell scripts to be indented in a natural
fashion.
If the delimiter is not quoted, the \<newline> sequence is treated
as a line continuation: the two lines are joined and the
If the delimiter is not quoted, the shell treats the \<newline>
sequence as a line continuation: the two lines are joined and the
backslash-newline is removed. This happens while reading the
here-document, before the check for the ending delimiter, so joined
lines can form the end delimiter.
@@ -7771,10 +7785,10 @@ startup files.
result from a $PATH search.
22. The message printed by the job control code and builtins when a
job exits with a non-zero status is 'Done(status)'.
job exits with a non-zero status is "Done(status)".
23. The message printed by the job control code and builtins when a
job is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for
job is stopped is "Stopped(SIGNAME)", where SIGNAME is, for
example, SIGTSTP.
24. If the shell is interactive, Bash does not perform job
@@ -8528,10 +8542,10 @@ File: bashref.info, Node: Introduction and Notation, Next: Readline Interactio
The following paragraphs use Emacs style to describe the notation used
to represent keystrokes.
The text C-k is read as 'Control-K' and describes the character
The text C-k is read as "Control-K" and describes the character
produced when the <k> key is pressed while the Control key is depressed.
The text M-k is read as 'Meta-K' and describes the character
The text M-k is read as "Meta-K" and describes the character
produced when the Meta key (if you have one) is depressed, and the <k>
key is pressed (a “meta character”), then both are released. The Meta
key is labeled <ALT> or <Option> on many keyboards. On keyboards with
@@ -8558,7 +8572,7 @@ you can make M-key key bindings you specify (see Key Bindings in
*note Readline Init File Syntax::) do the same thing by setting the
force-meta-prefix variable.
The text M-C-k is read as 'Meta-Control-k' and describes the
The text M-C-k is read as "Meta-Control-k" and describes the
character produced by metafying C-k.
In addition, several keys have their own names. Specifically, <DEL>,
@@ -8610,9 +8624,9 @@ you have typed several other characters. In that case, you can type
Afterwards, you can move the cursor to the right with C-f.
When you add text in the middle of a line, you will notice that
characters to the right of the cursor are 'pushed over' to make room for
characters to the right of the cursor are "pushed over" to make room for
the text that you have inserted. Likewise, when you delete text behind
the cursor, characters to the right of the cursor are 'pulled back' to
the cursor, characters to the right of the cursor are "pulled back" to
fill in the blank space created by the removal of the text. These are
the bare essentials for editing the text of an input line:
@@ -8670,9 +8684,9 @@ File: bashref.info, Node: Readline Killing Commands, Next: Readline Arguments,
“Killing” text means to delete the text from the line, but to save it
away for later use, usually by “yanking” (re-inserting) it back into the
line. ('Cut' and 'paste' are more recent jargon for 'kill' and 'yank'.)
line. ("Cut" and "paste" are more recent jargon for "kill" and "yank".)
If the description for a command says that it 'kills' text, then you
If the description for a command says that it "kills" text, then you
can be sure that you can get the text back in a different (or the same)
place later.
@@ -8727,13 +8741,14 @@ command which normally acts in a forward direction, that command will
act in a backward direction. For example, to kill text back to the
start of the line, you might type M-- C-k.
The general way to pass numeric arguments to a command is to type
meta digits before the command. If the first 'digit' typed is a minus
sign (-), then the sign of the argument will be negative. Once you
have typed one meta digit to get the argument started, you can type the
remainder of the digits, and then the command. For example, to give the
C-d command an argument of 10, you could type M-1 0 C-d, which will
delete the next ten characters on the input line.
The general way to pass numeric arguments to a command is to type the
Meta key and then digits ("meta digits") before the command. If the
first "digit" typed is a minus sign (-), then the sign of the argument
will be negative. Once you have typed one meta digit to get the
argument started, you can type the remainder of the digits, and then the
command. For example, to give the C-d command an argument of 10, you
could type M-1 0 C-d, which will delete the next ten characters on the
input line.

File: bashref.info, Node: Searching, Prev: Readline Arguments, Up: Readline Interaction
@@ -9651,12 +9666,12 @@ File: bashref.info, Node: Commands For History, Next: Commands For Text, Prev
original state.
previous-history (C-p)
Move 'back' through the history list, fetching the previous
Move "back" through the history list, fetching the previous
command. This may also be bound to the up arrow key on some
keyboards.
next-history (C-n)
Move 'forward' through the history list, fetching the next command.
Move "forward" through the history list, fetching the next command.
This may also be bound to the down arrow key on some keyboards.
beginning-of-history (M-<)
@@ -9667,25 +9682,26 @@ File: bashref.info, Node: Commands For History, Next: Commands For Text, Prev
being entered.
reverse-search-history (C-r)
Search backward starting at the current line and moving 'up'
Search backward starting at the current line and moving "up"
through the history as necessary. This is an incremental search.
This command sets the region to the matched text and activates the
region.
forward-search-history (C-s)
Search forward starting at the current line and moving 'down'
Search forward starting at the current line and moving "down"
through the history as necessary. This is an incremental search.
This command sets the region to the matched text and activates the
region.
non-incremental-reverse-search-history (M-p)
Search backward starting at the current line and moving 'up'
Search backward starting at the current line and moving "up"
through the history as necessary using a non-incremental search for
a string supplied by the user. The search string may match
anywhere in a history line.
non-incremental-forward-search-history (M-n)
Search forward starting at the current line and moving 'down'
Search forward starting at the current line and moving "down"
through the history as necessary using a non-incremental search for
a string supplied by the user. The search string may match
anywhere in a history line.
@@ -10261,8 +10277,8 @@ Set Builtin::) to switch interactively between emacs and vi editing
modes, The Readline default is emacs mode.
When you enter a line in vi mode, you are already placed in
'insertion' mode, as if you had typed an i. Pressing <ESC> switches
you into 'command' mode, where you can edit the text of the line with
"insertion" mode, as if you had typed an i. Pressing <ESC> switches
you into "command" mode, where you can edit the text of the line with
the standard vi movement keys, move to previous history lines with k
and subsequent lines with j, and so forth.
@@ -11902,7 +11918,7 @@ FTP from <ftp://ftp.gnu.org/pub/gnu/bash/> and from
bashbug command to submit a bug report or use the form at the Bash
project page (https://savannah.gnu.org/projects/bash/). If you have a
fix, you are encouraged to submit that as well! Suggestions and
'philosophical' bug reports may be mailed to <bug-bash@gnu.org> or
"philosophical" bug reports may be mailed to <bug-bash@gnu.org> or
<help-bash@gnu.org>.
All bug reports should include:
@@ -11910,7 +11926,7 @@ fix, you are encouraged to submit that as well! Suggestions and
• The hardware and operating system.
• The compiler used to compile Bash.
• A description of the bug behavior.
• A short script or 'recipe' which exercises the bug and may be used
• A short script or "recipe" which exercises the bug and may be used
to reproduce it.
bashbug inserts the first three items automatically into the template
@@ -13339,7 +13355,7 @@ D.4 Function Index
* export-completions (): Commands For Completion.
(line 44)
* fetch-history (): Commands For History.
(line 108)
(line 109)
* forward-backward-delete-char (): Commands For Text. (line 23)
* forward-char (C-f): Commands For Moving. (line 14)
* forward-search-history (C-s): Commands For History.
@@ -13356,13 +13372,13 @@ D.4 Function Index
* history-expand-line (M-^): Miscellaneous Commands.
(line 127)
* history-search-backward (): Commands For History.
(line 53)
(line 54)
* history-search-forward (): Commands For History.
(line 60)
(line 61)
* history-substring-search-backward (): Commands For History.
(line 67)
(line 68)
* history-substring-search-forward (): Commands For History.
(line 73)
(line 74)
* insert-comment (M-#): Miscellaneous Commands.
(line 59)
* insert-completions (M-*): Commands For Completion.
@@ -13387,11 +13403,11 @@ D.4 Function Index
(line 18)
* next-screen-line (): Commands For Moving. (line 45)
* non-incremental-forward-search-history (M-n): Commands For History.
(line 47)
(line 48)
* non-incremental-reverse-search-history (M-p): Commands For History.
(line 41)
* operate-and-get-next (C-o): Commands For History.
(line 101)
(line 102)
* overwrite-mode (): Commands For Text. (line 77)
* possible-command-completions (C-x !): Commands For Completion.
(line 111)
@@ -13453,9 +13469,9 @@ D.4 Function Index
* yank (C-y): Commands For Killing.
(line 72)
* yank-last-arg (M-. or M-_): Commands For History.
(line 89)
(line 90)
* yank-nth-arg (M-C-y): Commands For History.
(line 79)
(line 80)
* yank-pop (M-y): Commands For Killing.
(line 75)
@@ -13636,138 +13652,138 @@ D.5 Concept Index

Tag Table:
Node: Top898
Node: Introduction2836
Node: What is Bash?3052
Node: What is a shell?4188
Node: Definitions6801
Node: Basic Shell Features10131
Node: Shell Syntax11358
Node: Shell Operation12388
Node: Quoting13682
Node: Escape Character15023
Node: Single Quotes15561
Node: Double Quotes15913
Node: ANSI-C Quoting17261
Node: Locale Translation18658
Node: Creating Internationalized Scripts20064
Node: Comments24265
Node: Shell Commands25035
Node: Reserved Words25977
Node: Simple Commands26845
Node: Pipelines27510
Node: Lists30769
Node: Compound Commands32644
Node: Looping Constructs33656
Node: Conditional Constructs36208
Node: Command Grouping51281
Node: Coprocesses52776
Node: GNU Parallel55465
Node: Shell Functions56386
Node: Shell Parameters64837
Node: Positional Parameters69741
Node: Special Parameters70834
Node: Shell Expansions74298
Node: Brace Expansion76490
Node: Tilde Expansion79829
Node: Shell Parameter Expansion82787
Node: Command Substitution103433
Node: Arithmetic Expansion106965
Node: Process Substitution108144
Node: Word Splitting109255
Node: Filename Expansion111702
Node: Pattern Matching114929
Node: Quote Removal120655
Node: Redirections120962
Node: Executing Commands131228
Node: Simple Command Expansion131898
Node: Command Search and Execution134009
Node: Command Execution Environment136456
Node: Environment139907
Node: Exit Status141813
Node: Signals143875
Node: Shell Scripts148808
Node: Shell Builtin Commands152109
Node: Bourne Shell Builtins154223
Node: Bash Builtins180945
Node: Modifying Shell Behavior217872
Node: The Set Builtin218217
Node: The Shopt Builtin230214
Node: Special Builtins247270
Node: Shell Variables248262
Node: Bourne Shell Variables248699
Node: Bash Variables251210
Node: Bash Features290338
Node: Invoking Bash291355
Node: Bash Startup Files297942
Node: Interactive Shells303187
Node: What is an Interactive Shell?303598
Node: Is this Shell Interactive?304263
Node: Interactive Shell Behavior305090
Node: Bash Conditional Expressions308854
Node: Shell Arithmetic314274
Node: Aliases317604
Node: Arrays320741
Node: The Directory Stack328332
Node: Directory Stack Builtins329132
Node: Controlling the Prompt333580
Node: The Restricted Shell336468
Node: Bash POSIX Mode339353
Node: Shell Compatibility Mode358303
Node: Job Control367313
Node: Job Control Basics367773
Node: Job Control Builtins374144
Node: Job Control Variables380829
Node: Command Line Editing382063
Node: Introduction and Notation383769
Node: Readline Interaction386124
Node: Readline Bare Essentials387315
Node: Readline Movement Commands389126
Node: Readline Killing Commands390125
Node: Readline Arguments392151
Node: Searching393211
Node: Readline Init File395457
Node: Readline Init File Syntax396763
Node: Conditional Init Constructs423717
Node: Sample Init File428105
Node: Bindable Readline Commands431228
Node: Commands For Moving432769
Node: Commands For History435236
Node: Commands For Text440629
Node: Commands For Killing444757
Node: Numeric Arguments447548
Node: Commands For Completion448703
Node: Keyboard Macros454402
Node: Miscellaneous Commands455106
Node: Readline vi Mode461676
Node: Programmable Completion462656
Node: Programmable Completion Builtins472395
Node: A Programmable Completion Example484135
Node: Using History Interactively489483
Node: Bash History Facilities490167
Node: Bash History Builtins493905
Node: History Interaction500379
Node: Event Designators505332
Node: Word Designators506913
Node: Modifiers509308
Node: Installing Bash511248
Node: Basic Installation512367
Node: Compilers and Options516246
Node: Compiling For Multiple Architectures516999
Node: Installation Names518755
Node: Specifying the System Type520992
Node: Sharing Defaults521741
Node: Operation Controls522458
Node: Optional Features523480
Node: Reporting Bugs536206
Node: Major Differences From The Bourne Shell537566
Node: GNU Free Documentation License558996
Node: Indexes584176
Node: Builtin Index584630
Node: Reserved Word Index591731
Node: Variable Index594179
Node: Function Index611595
Node: Concept Index625593
Node: Top904
Node: Introduction2848
Node: What is Bash?3064
Node: What is a shell?4200
Node: Definitions6813
Node: Basic Shell Features10143
Node: Shell Syntax11370
Node: Shell Operation12400
Node: Quoting13694
Node: Escape Character15035
Node: Single Quotes15573
Node: Double Quotes15925
Node: ANSI-C Quoting17273
Node: Locale Translation18670
Node: Creating Internationalized Scripts20076
Node: Comments24277
Node: Shell Commands25047
Node: Reserved Words25989
Node: Simple Commands27135
Node: Pipelines27800
Node: Lists31059
Node: Compound Commands32982
Node: Looping Constructs33994
Node: Conditional Constructs36546
Node: Command Grouping51686
Node: Coprocesses53181
Node: GNU Parallel55870
Node: Shell Functions56791
Node: Shell Parameters65242
Node: Positional Parameters70146
Node: Special Parameters71239
Node: Shell Expansions74703
Node: Brace Expansion76895
Node: Tilde Expansion80234
Node: Shell Parameter Expansion83192
Node: Command Substitution103838
Node: Arithmetic Expansion107370
Node: Process Substitution108549
Node: Word Splitting109660
Node: Filename Expansion112107
Node: Pattern Matching115334
Node: Quote Removal121060
Node: Redirections121367
Node: Executing Commands131626
Node: Simple Command Expansion132296
Node: Command Search and Execution134407
Node: Command Execution Environment136854
Node: Environment140305
Node: Exit Status142211
Node: Signals144273
Node: Shell Scripts149206
Node: Shell Builtin Commands152507
Node: Bourne Shell Builtins154621
Node: Bash Builtins181343
Node: Modifying Shell Behavior218270
Node: The Set Builtin218615
Node: The Shopt Builtin230612
Node: Special Builtins247668
Node: Shell Variables248660
Node: Bourne Shell Variables249097
Node: Bash Variables251608
Node: Bash Features290736
Node: Invoking Bash291753
Node: Bash Startup Files298340
Node: Interactive Shells303585
Node: What is an Interactive Shell?303996
Node: Is this Shell Interactive?304661
Node: Interactive Shell Behavior305488
Node: Bash Conditional Expressions309252
Node: Shell Arithmetic314672
Node: Aliases318002
Node: Arrays321139
Node: The Directory Stack328730
Node: Directory Stack Builtins329530
Node: Controlling the Prompt333978
Node: The Restricted Shell336866
Node: Bash POSIX Mode339751
Node: Shell Compatibility Mode358701
Node: Job Control367711
Node: Job Control Basics368171
Node: Job Control Builtins374542
Node: Job Control Variables381227
Node: Command Line Editing382461
Node: Introduction and Notation384167
Node: Readline Interaction386522
Node: Readline Bare Essentials387713
Node: Readline Movement Commands389524
Node: Readline Killing Commands390523
Node: Readline Arguments392549
Node: Searching393642
Node: Readline Init File395888
Node: Readline Init File Syntax397194
Node: Conditional Init Constructs424148
Node: Sample Init File428536
Node: Bindable Readline Commands431659
Node: Commands For Moving433200
Node: Commands For History435667
Node: Commands For Text441061
Node: Commands For Killing445189
Node: Numeric Arguments447980
Node: Commands For Completion449135
Node: Keyboard Macros454834
Node: Miscellaneous Commands455538
Node: Readline vi Mode462108
Node: Programmable Completion463088
Node: Programmable Completion Builtins472827
Node: A Programmable Completion Example484567
Node: Using History Interactively489915
Node: Bash History Facilities490599
Node: Bash History Builtins494337
Node: History Interaction500811
Node: Event Designators505764
Node: Word Designators507345
Node: Modifiers509740
Node: Installing Bash511680
Node: Basic Installation512799
Node: Compilers and Options516678
Node: Compiling For Multiple Architectures517431
Node: Installation Names519187
Node: Specifying the System Type521424
Node: Sharing Defaults522173
Node: Operation Controls522890
Node: Optional Features523912
Node: Reporting Bugs536638
Node: Major Differences From The Bourne Shell537998
Node: GNU Free Documentation License559428
Node: Indexes584608
Node: Builtin Index585062
Node: Reserved Word Index592163
Node: Variable Index594611
Node: Function Index612027
Node: Concept Index626025

End Tag Table
+78 -58
View File
@@ -732,8 +732,29 @@ some other grouping.
Reserved words are words that have special meaning to the shell.
They are used to begin and end the shell's compound commands.
The following words are recognized as reserved when unquoted and
the first word of a command (see below for exceptions):
Reserved words are recognized as reserved when unquoted and either
@itemize @bullet
@item
the first word of a command;
@item
the first word following a reserved word
other than @code{case}, @code{for}, @code{select}, or @code{in};
@item
the third word of a @code{case} command
(only @code{in} is valid);
@item
the third word of a @code{for} or @code{select}
command (only @code{in} and @code{do} are valid);
@item
following a control operator.
@end itemize
@noindent
The shell will also recognize reserved words where the syntax of a command
specifically requires the reserved word as the only correct token.
The following are reserved words:
@multitable @columnfractions .1 .1 .1 .1 .12 .1
@item @code{if} @tab @code{then} @tab @code{elif}
@@ -745,12 +766,6 @@ the first word of a command (see below for exceptions):
@item @code{@{} @tab @code{@}} @tab @code{[[} @tab @code{]]} @tab @code{!}
@end multitable
@noindent
@code{in} is recognized as a reserved word if it is the third word of a
@code{case} or @code{select} command.
@code{in} and @code{do} are recognized as reserved
words if they are the third word in a @code{for} command.
@node Simple Commands
@subsection Simple Commands
@cindex commands, simple
@@ -851,10 +866,39 @@ The return status of an asynchronous pipeline is 0.
@subsection Lists of Commands
@cindex commands, lists
A @code{list} is a sequence of one or more pipelines separated by one
of the operators @samp{;}, @samp{&}, @samp{&&}, or @samp{||},
and optionally terminated by one of @samp{;}, @samp{&}, or a
@code{newline}.
A @code{list} is a sequence of one or more @sc{and} or @sc{or} lists
separated by one of the operators
@samp{;} or @samp{&}, or a @code{newline},
and optionally terminated by one of those three characters.
@sc{and} and @sc{or} lists are sequences of one or more pipelines
separated by the control operators @samp{&&} and @samp{||},
respectively.
@sc{and} and @sc{or} lists are executed with left associativity.
An @sc{and} list has the form
@example
@var{command1} && @var{command2}
@end example
@noindent
@var{command2} is executed if, and only if, @var{command1}
returns an exit status of zero (success).
An @sc{or} list has the form
@example
@var{command1} || @var{command2}
@end example
@noindent
@var{command2} is executed if, and only if, @var{command1}
returns a non-zero exit status.
The return status of
@sc{and} and @sc{or} lists is the exit status of the last command
executed in the list.
Of these list operators, @samp{&&} and @samp{||}
have equal precedence, followed by @samp{;} and @samp{&},
@@ -873,36 +917,12 @@ When job control is not active (@pxref{Job Control}),
the standard input for asynchronous commands, in the absence of any
explicit redirections, is redirected from @code{/dev/null}.
Commands separated by a @samp{;} are executed sequentially; the shell
waits for each command to terminate in turn.
The return status is the exit status of the last command executed.
Commands separated or terminated by
@samp{;} (or equivalent @code{newline})
are executed sequentially; the shell waits for each
command to terminate in turn.
@sc{and} and @sc{or} lists are sequences of one or more pipelines
separated by the control operators @samp{&&} and @samp{||},
respectively.
@sc{and} and @sc{or} lists are executed with left associativity.
An @sc{and} list has the form
@example
@var{command1} && @var{command2}
@end example
@noindent
@var{command2} is executed if, and only if, @var{command1}
returns an exit status of zero (success).
An @sc{or} list has the form
@example
@var{command1} || @var{command2}
@end example
@noindent
@var{command2} is executed if, and only if, @var{command1}
returns a non-zero exit status.
The return status of
@sc{and} and @sc{or} lists is the exit status of the last command
executed in the list.
The return status of a list is the exit status of the last command executed.
@node Compound Commands
@subsection Compound Commands
@@ -1058,26 +1078,24 @@ the first @var{pattern} that matches @var{word},
proceeding from the first pattern to the last.
The match is performed according
to the rules described below in @ref{Pattern Matching}.
If the @code{nocasematch} shell option
(see the description of @code{shopt} in @ref{The Shopt Builtin})
is enabled, the match is performed without regard to the case
of alphabetic characters.
The @samp{|} is used to separate multiple patterns in a pattern list,
and the @samp{)} operator terminates the pattern list.
A pattern list and an associated @var{command-list} is known
as a @var{clause}.
Each clause must be terminated with @samp{;;}, @samp{;&}, or @samp{;;&}.
The @var{word} undergoes tilde expansion, parameter expansion, command
substitution, process substitution, arithmetic expansion, and quote removal
(@pxref{Shell Parameter Expansion})
before the shell attempts to match the pattern.
Each @var{pattern} undergoes tilde expansion, parameter expansion,
Each @var{pattern} examined undergoes tilde expansion, parameter expansion,
command substitution, arithmetic expansion, process substitution, and
quote removal.
If the @code{nocasematch} shell option
(see the description of @code{shopt} in @ref{The Shopt Builtin})
is enabled, the match is performed without regard to the case
of alphabetic characters.
There may be an arbitrary number of @code{case} clauses, each terminated
by a @samp{;;}, @samp{;&}, or @samp{;;&}.
A pattern list is a set of one or more patterns separated by @samp{|},
and terminated by the @samp{)} operator.
A case @var{clause} is a pattern list and an associated @var{command-list},
terminated by @samp{;;}, @samp{;&}, or @samp{;;&}.
The terminator is optional for the last clause preceding @code{esac}.
There may be an arbitrary number of @code{case} clauses.
The first pattern that matches determines the
command-list that is executed.
It's a common idiom to use @samp{*} as the final pattern to define the
@@ -1100,11 +1118,13 @@ echo " legs."
@noindent
If the @samp{;;} operator is used, the @code{case} command completes
after the first pattern match.
Using @samp{;&} in place of @samp{;;} causes execution to continue with
When a match is found, @code{case} executes
the corresponding @var{command-list}.
If the @samp{;;} operator terminates the case clause,
the @code{case} command completes after the first pattern match.
Using the @samp{;&} terminator continues execution with
the @var{command-list} associated with the next clause, if any.
Using @samp{;;&} in place of @samp{;;} causes the shell to test the patterns
Using the @samp{;;&} terminator causes the shell to test the pattern list
in the next clause, if any, and execute any associated @var{command-list}
if the match succeeds,
continuing the case statement execution as if the pattern list had not matched.
+10 -10
View File
@@ -7,13 +7,13 @@
#
sed -e 's|<B>gnu.bash.bug</B>|<A HREF="news:gnu.bash.bug">gnu.bash.bug</A>|g' \
-e 's|<I>/bin/bash</I>|<A HREF="file:/bin/bash"><I>/bin/bash</I></A>|g' \
-e 's|<I>/etc/profile</I>|<A HREF="file:/etc/profile"><I>/etc/profile</I></A>|g' \
-e 's|<I>~/.bash_profile</I>|<A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>|g' \
-e 's|<I>~/.bash_login</I>|<A HREF="file:~/.bash_login"><I>~/.bash_login</I></A>|g' \
-e 's|<I>~/.profile</I>|<A HREF="file:~/.profile"><I>~/.profile</I></A>|g' \
-e 's|<I>~/.bashrc</I>|<A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>|g' \
-e 's|<I>~/.bash_logout</I>|<A HREF="file:~/.bash_logout"><I>~/.bash_logout</I></A>|g' \
-e 's|<I>~/.bash_history</I>|<A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>|g' \
-e 's|<I>~/.inputrc</I>|<A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>|g' \
-e 's|<I>/etc/inputrc</I>|<A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A>|g'
-e 's|<[iI]>/bin/bash</[iI]>|<A HREF="file:/bin/bash"><i>/bin/bash</i></A>|g' \
-e 's|<[iI]>/etc/profile</[iI]>|<A HREF="file:/etc/profile"><i>/etc/profile</i></A>|g' \
-e 's|<[iI]>~/.bash_profile</[iI]>|<A HREF="file:~/.bash_profile"><i>~/.bash_profile</i></A>|g' \
-e 's|<[iI]>~/.bash_login</[iI]>|<A HREF="file:~/.bash_login"><i>~/.bash_login</i></A>|g' \
-e 's|<[iI]>~/.profile</[iI]>|<A HREF="file:~/.profile"><i>~/.profile</i></A>|g' \
-e 's|<[iI]>~/.bashrc</[iI]>|<A HREF="file:~/.bashrc"><i>~/.bashrc</i></A>|g' \
-e 's|<[iI]>~/.bash_logout</[iI]>|<A HREF="file:~/.bash_logout"><i>~/.bash_logout</i></A>|g' \
-e 's|<[iI]>~/.bash_history</[iI]>|<A HREF="file:~/.bash_history"><i>~/.bash_history</i></A>|g' \
-e 's|<[iI]>~/.inputrc</[iI]>|<A HREF="file:~/.inputrc"><i>~/.inputrc</i></A>|g' \
-e 's|<[iI]>/etc/inputrc</[iI]>|<A HREF="file:/etc/inputrc"><i>/etc/inputrc</i></A>|g'
+3 -3
View File
@@ -2,10 +2,10 @@
Copyright (C) 1988-2025 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Thu Aug 7 12:59:18 EDT 2025
@set LASTCHANGE Sat Sep 6 15:27:05 EDT 2025
@set EDITION 5.3
@set VERSION 5.3
@set UPDATED 7 August 2025
@set UPDATED-MONTH August 2025
@set UPDATED 6 September 2025
@set UPDATED-MONTH September 2025
+1 -1
View File
@@ -178,7 +178,7 @@ reader_loop (void)
current_command_number++;
executing = 1;
stdin_redir = 0;
stdin_redirected = 0;
execute_command (current_command);
+19 -23
View File
@@ -196,7 +196,7 @@ static int execute_intern_function (WORD_DESC *, FUNCTION_DEF *);
/* Set to 1 if fd 0 was the subject of redirection to a subshell. Global
so that reader_loop can set it to zero before executing a command. */
int stdin_redir;
int stdin_redirected;
/* The name of the command that is currently being executed.
`test' needs this, for example. */
@@ -484,7 +484,8 @@ execute_command (COMMAND *command)
return (result);
}
/* Return 1 if TYPE is a shell control structure type. */
/* Return 1 if TYPE is a shell control structure type (compound command, but
not a user-specified subshell). */
static int
shell_control_structure (enum command_type type)
{
@@ -840,7 +841,10 @@ execute_command_internal (COMMAND *command, int asynchronous, int pipe_in, int p
#endif /* COMMAND_TIMING */
if (shell_control_structure (command->type) && command->redirects)
stdin_redir = stdin_redirects (command->redirects);
{
stdin_redirected = stdin_redirects (command->redirects);
/*itrace("execute_command_internal: compound command with redirects: stdin_redirected = %d", stdin_redirected); */
}
#if defined (PROCESS_SUBSTITUTION)
# if !defined (HAVE_DEV_FD)
@@ -1605,13 +1609,7 @@ execute_in_subshell (COMMAND *command, int asynchronous, int pipe_in, int pipe_o
command terminated by a `&'. */
should_redir_stdin = (asynchronous && (command->flags & CMD_STDIN_REDIR) &&
pipe_in == NO_PIPE &&
#if 0 /*TAG:bash-5.4 POSIX interp 1913 */
/* POSIX interp 1913 says that the redirection of fd 0
from /dev/null is unconditional. */
(posixly_correct || stdin_redirects (command->redirects) == 0));
#else
stdin_redirects (command->redirects) == 0);
#endif
invert = (command->flags & CMD_INVERT_RETURN) != 0;
user_subshell = command->type == cm_subshell || ((command->flags & CMD_WANT_SUBSHELL) != 0);
@@ -1753,18 +1751,23 @@ execute_in_subshell (COMMAND *command, int asynchronous, int pipe_in, int pipe_o
executed as part of that compound command. */
if (user_subshell)
{
stdin_redir = stdin_redirects (command->redirects) || pipe_in != NO_PIPE;
/* itrace("execute_in_subshell: user subshell: before calling stdin_redirects: stdin_redirected = %d", stdin_redirected); */
stdin_redirected = stdin_redirects (command->redirects) || pipe_in != NO_PIPE;
/* itrace("execute_in_subshell: user subshell: after calling stdin_redirects: stdin_redirected = %d", stdin_redirected); */
#if 0
restore_default_signal (EXIT_TRAP); /* XXX - reset_signal_handlers above */
#endif
}
else if (shell_control_structure (command->type) && pipe_in != NO_PIPE)
stdin_redir = 1;
{
/*itrace("execute_in_subshell: setting stdin_redirected to 1 for compound command with input pipe");*/
stdin_redirected = 1;
}
/* If this is an asynchronous command (command &), we want to
redirect the standard input from /dev/null in the absence of
any specific redirection involving stdin. */
if (should_redir_stdin && stdin_redir == 0)
if (should_redir_stdin && stdin_redirected == 0)
async_redirect_stdin ();
/* In any case, we are not reading our command input from stdin. */
@@ -2852,6 +2855,7 @@ execute_connection (COMMAND *command, int asynchronous, int pipe_in, int pipe_ou
tc->flags |= CMD_IGNORE_RETURN;
tc->flags |= CMD_AMPERSAND;
/* itrace("execute_connection: async command: stdin_redirected = %d", stdin_redirected);*/
/* If this shell was compiled without job control support,
if we are currently in a subshell via `( xxx )', or if job
control is not active then the standard input for an
@@ -2859,17 +2863,9 @@ execute_connection (COMMAND *command, int asynchronous, int pipe_in, int pipe_ou
/* If we want to make this /dev/null redirection unconditional in posix
mode, change this to check posixly_correct */
#if defined (JOB_CONTROL)
#if 0 /*TAG:bash-5.4 POSIX interp 1913 */
if (((subshell_environment || !job_control) && !stdin_redir) || posixly_correct)
if ((subshell_environment || !job_control) && !stdin_redirected)
#else
if ((subshell_environment || !job_control) && !stdin_redir)
#endif
#else
#if 0 /*TAG:bash-5.4 POSIX interp 1913 */
if (!stdin_redir || posixly_correct)
#else
if (!stdin_redir)
#endif
if (!stdin_redirected)
#endif /* JOB_CONTROL */
tc->flags |= CMD_STDIN_REDIR;
@@ -4550,7 +4546,7 @@ execute_simple_command (SIMPLE_COM *simple_command, int pipe_in, int pipe_out, i
/* If we fork because of an input pipe, note input pipe for later to
inhibit async commands from redirecting stdin from /dev/null */
stdin_redir |= pipe_in != NO_PIPE;
stdin_redirected |= pipe_in != NO_PIPE;
do_piping (pipe_in, pipe_out);
pipe_in = pipe_out = NO_PIPE;
+1 -1
View File
@@ -59,7 +59,7 @@ extern int executing_command_builtin;
extern int funcnest, funcnest_max;
extern int evalnest, evalnest_max;
extern int sourcenest, sourcenest_max;
extern int stdin_redir;
extern int stdin_redirected;
extern int line_number_for_err_trap;
extern char *the_printed_command_except_trap;
+2
View File
@@ -2096,6 +2096,8 @@ print_pipeline (PROCESS *p, int job_index, int format, FILE *stream)
if (es == 0)
es = 2; /* strlen ("| ") */
name_padding = LONGEST_SIGNAL_DESC - es;
if (name_padding <= 0)
name_padding = 1;
fprintf (stream, "%*s", name_padding, "");
+1 -1
View File
@@ -390,7 +390,7 @@ charcmp_wc (wint_t c1, wint_t c2, int forcecoll)
if (c1 == c2)
return 0;
if (forcecoll == 0 && glob_asciirange && c1 <= UCHAR_MAX && c2 <= UCHAR_MAX)
if (forcecoll == 0 && glob_asciirange)
return ((int)(c1 - c2));
s1[0] = c1;
+4 -2
View File
@@ -241,11 +241,13 @@ _rl_kill_kbd_macro (void)
End the definition with rl_end_kbd_macro ().
If a numeric argument was explicitly typed, then append this
definition to the end of the existing macro, and start by
re-executing the existing macro. */
re-executing the existing macro.
We don't allow recursive keyboard macro definitions or keyboard macro
definitions while reading input from a bound macro. */
int
rl_start_kbd_macro (int ignore1, int ignore2)
{
if (RL_ISSTATE (RL_STATE_MACRODEF))
if (RL_ISSTATE (RL_STATE_MACRODEF|RL_STATE_MACROINPUT))
{
_rl_abort_internal ();
return 1;
+2 -2
View File
@@ -890,7 +890,7 @@ _rl_dispatch_subseq (register int key, Keymap map, int got_subseq)
{
if (map[ESC].type == ISKMAP)
{
if (RL_ISSTATE (RL_STATE_MACRODEF))
if (RL_ISSTATE (RL_STATE_MACRODEF) && RL_ISSTATE (RL_STATE_MACROINPUT) == 0)
_rl_add_macro_char (ESC);
RESIZE_KEYSEQ_BUFFER ();
rl_executing_keyseq[rl_key_sequence_length++] = ESC;
@@ -903,7 +903,7 @@ _rl_dispatch_subseq (register int key, Keymap map, int got_subseq)
return 0;
}
if (RL_ISSTATE (RL_STATE_MACRODEF))
if (RL_ISSTATE (RL_STATE_MACRODEF) && RL_ISSTATE (RL_STATE_MACROINPUT) == 0)
_rl_add_macro_char (key);
r = 0;
+3 -3
View File
@@ -1047,7 +1047,7 @@ _rl_insert_next (int count)
if (c < 0)
return 1;
if (RL_ISSTATE (RL_STATE_MACRODEF))
if (RL_ISSTATE (RL_STATE_MACRODEF) && RL_ISSTATE (RL_STATE_MACROINPUT) == 0)
_rl_add_macro_char (c);
#if defined (HANDLE_SIGNALS)
@@ -1793,7 +1793,7 @@ _rl_char_search (int count, int fdir, int bdir)
if (mb_len <= 0)
return 1;
if (RL_ISSTATE (RL_STATE_MACRODEF))
if (RL_ISSTATE (RL_STATE_MACRODEF) && RL_ISSTATE (RL_STATE_MACROINPUT) == 0)
for (i = 0; i < mb_len; i++)
_rl_add_macro_char (mbchar[i]);
@@ -1813,7 +1813,7 @@ _rl_char_search (int count, int fdir, int bdir)
if (c < 0)
return 1;
if (RL_ISSTATE (RL_STATE_MACRODEF))
if (RL_ISSTATE (RL_STATE_MACRODEF) && RL_ISSTATE (RL_STATE_MACROINPUT) == 0)
_rl_add_macro_char (c);
if (count < 0)