mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-27 15:43:18 +02:00
the `history' builtin prints error messages for certain read and write errors; implementation of new form of nofork command substitution that does not remove trailing newlines
This commit is contained in:
@@ -12541,3 +12541,42 @@ bashline.c
|
||||
- shell_expand_and_requote_line: calls shell_expand_line_internal
|
||||
with a third argument of 1 to force quoting
|
||||
From a proposal by Koichi Murase <myoga.murase@gmail.com> in 2/2024
|
||||
|
||||
1/13
|
||||
----
|
||||
builtins/history.def
|
||||
- history_error: new function, prints an error message for history
|
||||
file read or write errors for a few values of errno (EACCES,
|
||||
EIO, ENOENT, EISDIR)
|
||||
- history_builtin: call history_error as appropriate
|
||||
From a suggestion by Dan Jacobson <jidanni@jidanni.org>
|
||||
|
||||
1/14
|
||||
----
|
||||
parser.h
|
||||
- FUNSUB_CHAR: expand definition to include `;'
|
||||
|
||||
parse.y
|
||||
- parse_comsub,xparse_dolparen: make sure to include `;' as a valid
|
||||
character that introduces a potential funsub
|
||||
|
||||
command.h
|
||||
- PF_COMSUBNLS: new flags value for command substitution, means to
|
||||
not strip trailing newlines from command substitution output
|
||||
|
||||
subst.c
|
||||
- read_comsub: inhibit trailing newline removal if the PF_COMSUBNLS
|
||||
flag is set in the FLAGS parameter
|
||||
- function_substitute: set PF_COMSUBNLS in the flags passed to
|
||||
read_comsub if the first character of the command string is `;'
|
||||
|
||||
doc/bash.1,doc/bashref.texi
|
||||
- document new form of nofork command substitution that preserves
|
||||
trailing newlines
|
||||
|
||||
tests/comsub21.sub,tests/comsub23.sub,tests/comsub26.sub,tests/comsub27.sub
|
||||
- added tests for ${; command; }
|
||||
|
||||
tests/comsub28.sub
|
||||
- new file, contains basic tests for ${; command; }
|
||||
From a contribution by Kevin Pulo <kevin.pulo@mongodb.com>
|
||||
|
||||
@@ -1085,6 +1085,7 @@ tests/comsub24.sub f
|
||||
tests/comsub25.sub f
|
||||
tests/comsub26.sub f
|
||||
tests/comsub27.sub f
|
||||
tests/comsub28.sub f
|
||||
tests/comsub-eof.tests f
|
||||
tests/comsub-eof0.sub f
|
||||
tests/comsub-eof1.sub f
|
||||
@@ -1301,6 +1302,7 @@ tests/history8.sub f
|
||||
tests/history9.sub f
|
||||
tests/history10.sub f
|
||||
tests/history11.sub f
|
||||
tests/history12.sub f
|
||||
tests/ifs.tests f
|
||||
tests/ifs.right f
|
||||
tests/ifs1.sub f
|
||||
|
||||
+48
-12
@@ -1,7 +1,7 @@
|
||||
This file is history.def, from which is created history.c.
|
||||
It implements the builtin "history" in Bash.
|
||||
|
||||
Copyright (C) 1987-2025 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2026 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -106,6 +106,8 @@ $END
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
static void history_error (const char *, int, int);
|
||||
|
||||
static char *histtime (HIST_ENTRY *, const char *);
|
||||
static int parse_range (char *, char *, int *, int *);
|
||||
static int display_history (WORD_LIST *, int);
|
||||
@@ -287,17 +289,24 @@ history_builtin (WORD_LIST *list)
|
||||
if (flags & AFLAG) /* Append session's history to file. */
|
||||
result = maybe_append_history (filename);
|
||||
else if (flags & WFLAG) /* Write entire history. */
|
||||
result = write_history (filename);
|
||||
{
|
||||
result = write_history (filename);
|
||||
/* Report write errors from the history library. Right now we only
|
||||
report on missing files, an attempt to read a directory, or
|
||||
I/O and permission errors. */
|
||||
if (result > 0)
|
||||
history_error (filename, result, 0);
|
||||
}
|
||||
else if (flags & RFLAG) /* Read entire file. */
|
||||
{
|
||||
result = read_history (filename);
|
||||
history_lines_in_file = history_lines_read_from_file;
|
||||
/* history_lines_in_file = where_history () + history_base - 1; */
|
||||
#if 0
|
||||
/* Report read errors from the history library. */
|
||||
/* Report read errors from the history library. Right now we only
|
||||
report on missing files, an attempt to read a directory, or
|
||||
I/O and permission errors. */
|
||||
if (result > 0)
|
||||
builtin_error ("%s: %s: %s", filename, _("read error"), strerror (errno));
|
||||
#endif
|
||||
history_error (filename, result, 1);
|
||||
}
|
||||
else if (flags & NFLAG) /* Read `new' history from file. */
|
||||
{
|
||||
@@ -307,17 +316,16 @@ history_builtin (WORD_LIST *list)
|
||||
|
||||
using_history ();
|
||||
result = read_history_range (filename, history_lines_in_file, -1);
|
||||
/* Report read errors from the history library. Right now we only
|
||||
report on missing files, an attempt to read a directory, or
|
||||
I/O and permission errors. */
|
||||
if (result > 0)
|
||||
history_error (filename, result, 1);
|
||||
using_history ();
|
||||
|
||||
history_lines_in_file = history_lines_read_from_file;
|
||||
/* history_lines_in_file = where_history () + history_base - 1; */
|
||||
|
||||
#if 0
|
||||
/* Report read errors from the history library. */
|
||||
if (result > 0)
|
||||
builtin_error ("%s: %s: %s", filename, _("read error"), strerror (errno));
|
||||
#endif
|
||||
|
||||
/* If we're rewriting the history file at shell exit rather than just
|
||||
appending the lines from this session to it, the question is whether
|
||||
we reset history_lines_this_session to 0, losing any history entries
|
||||
@@ -336,6 +344,34 @@ history_builtin (WORD_LIST *list)
|
||||
return (result ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
/* Print an error message after a history file read or write error. R says
|
||||
which kind of error (read or write). We only report on missing filenames,
|
||||
attempts to read and write directories, I/O errors, and permission
|
||||
errors. */
|
||||
static void
|
||||
history_error (const char *filename, int e, int r)
|
||||
{
|
||||
switch (e)
|
||||
{
|
||||
case ENOENT:
|
||||
case EIO:
|
||||
#if defined (EISDIR)
|
||||
case EISDIR:
|
||||
#endif
|
||||
#if defined (EACCES)
|
||||
case EACCES:
|
||||
#endif
|
||||
if (r)
|
||||
builtin_error ("%s: %s: %s", filename, _("read error"), strerror (e));
|
||||
else
|
||||
builtin_error ("%s: %s: %s", filename, _("write error"), strerror (e));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Accessors for HIST_ENTRY lists that are called HLIST. */
|
||||
#define histline(i) (hlist[(i)]->line)
|
||||
#define histdata(i) (hlist[(i)]->data)
|
||||
|
||||
@@ -115,6 +115,7 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
|
||||
#define PF_EXPANDRHS 0x20 /* same as W_EXPANDRHS */
|
||||
#define PF_ALLINDS 0x40 /* array, act as if [@] was supplied */
|
||||
#define PF_BACKQUOTE 0x80 /* differentiate `` from $() for command_substitute */
|
||||
#define PF_COMSUBNLS 0x100 /* for ${; ...; } and read_comsub() to not strip trailing newlines */
|
||||
|
||||
/* Possible values for subshell_environment */
|
||||
#define SUBSHELL_ASYNC 0x01 /* subshell caused by `command &' */
|
||||
|
||||
+1937
-1909
File diff suppressed because it is too large
Load Diff
+18
-5
@@ -5,7 +5,7 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet.ramey@case.edu
|
||||
.\"
|
||||
.\" Last Change: Fri Jan 9 10:17:30 EST 2026
|
||||
.\" Last Change: Wed Jan 14 15:46:08 EST 2026
|
||||
.\"
|
||||
.\" For bash_builtins, strip all but "SHELL BUILTIN COMMANDS" section
|
||||
.\" For rbash, strip all but "RESTRICTED SHELL" section
|
||||
@@ -22,7 +22,7 @@
|
||||
.ds zX \" empty
|
||||
.if \n(zZ=1 .ig zZ
|
||||
.if \n(zY=1 .ig zY
|
||||
.TH BASH 1 "2026 January 9" "GNU Bash 5.3"
|
||||
.TH BASH 1 "2026 January 14" "GNU Bash 5.3"
|
||||
.\"
|
||||
.ie \n(.g \{\
|
||||
.ds ' \(aq
|
||||
@@ -4221,7 +4221,11 @@ which executes \fIcommand\fP in the current execution environment
|
||||
and captures its output, again with trailing newlines removed.
|
||||
.PP
|
||||
The character \fIc\fP following the open brace must be a space, tab,
|
||||
newline, or \fB|\fP, and the close brace must be in a position
|
||||
newline,
|
||||
.Q | ,
|
||||
or
|
||||
.Q ; ;
|
||||
and the close brace must be in a position
|
||||
where a reserved word may appear (i.e., preceded by a command terminator
|
||||
such as semicolon).
|
||||
\fBBash\fP allows the close brace to be joined to the remaining characters in
|
||||
@@ -4240,8 +4244,17 @@ function is executing, and the \fBreturn\fP builtin forces
|
||||
however, the rest of the execution environment,
|
||||
including the positional parameters, is shared with the caller.
|
||||
.PP
|
||||
If the first character following the open brace
|
||||
is a \fB|\fP, the construct expands to the
|
||||
If the first character following the open brace is a
|
||||
.Q ; ,
|
||||
the construct behaves like the form above but
|
||||
preserves any trailing newlines in the output of \fIcommand\fP
|
||||
instead of removing them.
|
||||
This form is useful when the trailing newlines are significant
|
||||
and should not be stripped from the command's output.
|
||||
.PP
|
||||
If the first character following the open brace is a
|
||||
.Q | ,
|
||||
the construct expands to the
|
||||
value of the \fBREPLY\fP shell variable after \fIcommand\fP executes,
|
||||
without removing any trailing newlines,
|
||||
and the standard output of \fIcommand\fP remains the same as in the
|
||||
|
||||
+246
-214
@@ -1,12 +1,12 @@
|
||||
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, 26 December 2025).
|
||||
Bash shell (version 5.3, 14 January 2026).
|
||||
|
||||
This is Edition 5.3, last updated 26 December 2025, of ‘The GNU Bash
|
||||
This is Edition 5.3, last updated 14 January 2026, of ‘The GNU Bash
|
||||
Reference Manual’, for ‘Bash’, Version 5.3.
|
||||
|
||||
Copyright © 1988-2025 Free Software Foundation, Inc.
|
||||
Copyright © 1988-2026 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this
|
||||
document under the terms of the GNU Free Documentation License,
|
||||
@@ -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, 26 December 2025). The Bash home page is
|
||||
Bash shell (version 5.3, 14 January 2026). The Bash home page is
|
||||
<http://www.gnu.org/software/bash/>.
|
||||
|
||||
This is Edition 5.3, last updated 26 December 2025, of ‘The GNU Bash
|
||||
This is Edition 5.3, last updated 14 January 2026, of ‘The GNU Bash
|
||||
Reference Manual’, for ‘Bash’, Version 5.3.
|
||||
|
||||
Bash contains features that appear in other popular shells, and some
|
||||
@@ -786,8 +786,8 @@ executing the command in the “background”, and these are referred to as
|
||||
“asynchronous” commands. The shell does not wait for the command to
|
||||
finish, and the return status is 0 (true). When job control is not
|
||||
active (*note Job Control::), the standard input for asynchronous
|
||||
commands, in the absence of any explicit redirections, is redirected
|
||||
from ‘/dev/null’.
|
||||
commands, in the absence of any explicit redirections involving the
|
||||
standard input, is redirected from ‘/dev/null’.
|
||||
|
||||
Commands separated or terminated by ‘;’ (or equivalent ‘newline’) are
|
||||
executed sequentially; the shell waits for each command to terminate in
|
||||
@@ -2386,7 +2386,7 @@ which executes COMMAND in the current execution environment and captures
|
||||
its output, again with trailing newlines removed.
|
||||
|
||||
The character C following the open brace must be a space, tab,
|
||||
newline, or ‘|’, and the close brace must be in a position where a
|
||||
newline, ‘|’, or ‘;’; and the close brace must be in a position where a
|
||||
reserved word may appear (i.e., preceded by a command terminator such as
|
||||
semicolon). Bash allows the close brace to be joined to the remaining
|
||||
characters in the word without being followed by a shell metacharacter
|
||||
@@ -2402,6 +2402,12 @@ function is executing, and the ‘return’ builtin forces COMMAND to
|
||||
complete; however, the rest of the execution environment, including the
|
||||
positional parameters, is shared with the caller.
|
||||
|
||||
If the first character following the open brace is a ‘;’, the
|
||||
construct behaves like the form above but preserves any trailing
|
||||
newlines in the output of COMMAND instead of removing them. This form
|
||||
is useful when the trailing newlines are significant and should not be
|
||||
stripped from the command's output.
|
||||
|
||||
If the first character following the open brace is a ‘|’, the
|
||||
construct expands to the value of the ‘REPLY’ shell variable after
|
||||
COMMAND executes, without removing any trailing newlines, and the
|
||||
@@ -3163,9 +3169,10 @@ subshells See the description of the ‘inherit_errexit’ shell option
|
||||
POSIX mode.
|
||||
|
||||
If a command is followed by a ‘&’ and job control is not active, the
|
||||
default standard input for the command is the empty file ‘/dev/null’.
|
||||
Otherwise, the invoked command inherits the file descriptors of the
|
||||
calling shell as modified by redirections.
|
||||
default standard input for the command is the empty file ‘/dev/null’,
|
||||
unless the command has an explicit redirection involving the standard
|
||||
input. Otherwise, the invoked command inherits the file descriptors of
|
||||
the calling shell as modified by redirections.
|
||||
|
||||
|
||||
File: bash.info, Node: Environment, Next: Exit Status, Prev: Command Execution Environment, Up: Executing Commands
|
||||
@@ -7713,10 +7720,10 @@ there are areas where the Bash default behavior differs from the
|
||||
specification. The Bash “posix mode” changes the Bash behavior in these
|
||||
areas so that it conforms more strictly to the standard.
|
||||
|
||||
Starting Bash with the ‘--posix’ command-line option or executing
|
||||
‘set -o posix’ while Bash is running will cause Bash to conform more
|
||||
closely to the POSIX standard by changing the behavior to match that
|
||||
specified by POSIX in areas where the Bash default differs.
|
||||
Starting Bash with the ‘--posix’ or ‘-o posix’ command-line option or
|
||||
executing ‘set -o posix’ while Bash is running will cause Bash to
|
||||
conform more closely to the POSIX standard by changing the behavior to
|
||||
match that specified by POSIX in areas where the Bash default differs.
|
||||
|
||||
When invoked as ‘sh’, Bash enters POSIX mode after reading the
|
||||
startup files.
|
||||
@@ -7806,65 +7813,73 @@ startup files.
|
||||
the command hash table, even if it returns it as a (last-ditch)
|
||||
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)".
|
||||
22. Normally, when job control is not enabled, the shell implicitly
|
||||
redirects the standard input of asynchronous commands from
|
||||
‘/dev/null’. A redirection to the standard input in this command
|
||||
inhibits this implicit redirection. In POSIX mode, a redirection
|
||||
that redirects file descriptor 0 to itself (e.g., ‘<&0’) does not
|
||||
count as a redirection that overrides the implicit redirection from
|
||||
‘/dev/null’.
|
||||
|
||||
23. The message printed by the job control code and builtins when a
|
||||
job exits with a non-zero status is "Done(status)".
|
||||
|
||||
24. The message printed by the job control code and builtins when a
|
||||
job is stopped is "Stopped(SIGNAME)", where SIGNAME is, for
|
||||
example, ‘SIGTSTP’.
|
||||
|
||||
24. If the shell is interactive, Bash does not perform job
|
||||
25. If the shell is interactive, Bash does not perform job
|
||||
notifications between executing commands in lists separated by ‘;’
|
||||
or newline. Non-interactive shells print status messages after a
|
||||
foreground job in a list completes.
|
||||
|
||||
25. If the shell is interactive, Bash waits until the next prompt
|
||||
26. If the shell is interactive, Bash waits until the next prompt
|
||||
before printing the status of a background job that changes status
|
||||
or a foreground job that terminates due to a signal.
|
||||
Non-interactive shells print status messages after a foreground job
|
||||
completes.
|
||||
|
||||
26. Bash permanently removes jobs from the jobs table after notifying
|
||||
27. Bash permanently removes jobs from the jobs table after notifying
|
||||
the user of their termination via the ‘wait’ or ‘jobs’ builtins.
|
||||
It removes the job from the jobs list after notifying the user of
|
||||
its termination, but the status is still available via ‘wait’, as
|
||||
long as ‘wait’ is supplied a PID argument.
|
||||
|
||||
27. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when
|
||||
28. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when
|
||||
the ‘v’ command is run, instead of checking ‘$VISUAL’ and
|
||||
‘$EDITOR’.
|
||||
|
||||
28. Prompt expansion enables the POSIX ‘PS1’ and ‘PS2’ expansions of
|
||||
29. Prompt expansion enables the POSIX ‘PS1’ and ‘PS2’ expansions of
|
||||
‘!’ to the history number and ‘!!’ to ‘!’, and Bash performs
|
||||
parameter expansion on the values of ‘PS1’ and ‘PS2’ regardless of
|
||||
the setting of the ‘promptvars’ option.
|
||||
|
||||
29. The default history file is ‘~/.sh_history’ (this is the default
|
||||
30. The default history file is ‘~/.sh_history’ (this is the default
|
||||
value the shell assigns to ‘$HISTFILE’).
|
||||
|
||||
30. The ‘!’ character does not introduce history expansion within a
|
||||
31. The ‘!’ character does not introduce history expansion within a
|
||||
double-quoted string, even if the ‘histexpand’ option is enabled.
|
||||
|
||||
31. When printing shell function definitions (e.g., by ‘type’), Bash
|
||||
32. When printing shell function definitions (e.g., by ‘type’), Bash
|
||||
does not print the ‘function’ reserved word unless necessary.
|
||||
|
||||
32. Non-interactive shells exit if a syntax error in an arithmetic
|
||||
33. Non-interactive shells exit if a syntax error in an arithmetic
|
||||
expansion results in an invalid expression.
|
||||
|
||||
33. Non-interactive shells exit if a parameter expansion error occurs.
|
||||
34. Non-interactive shells exit if a parameter expansion error occurs.
|
||||
|
||||
34. If a POSIX special builtin returns an error status, a
|
||||
35. If a POSIX special builtin returns an error status, a
|
||||
non-interactive shell exits. The fatal errors are those listed in
|
||||
the POSIX standard, and include things like passing incorrect
|
||||
options, redirection errors, variable assignment errors for
|
||||
assignments preceding the command name, and so on.
|
||||
|
||||
35. A non-interactive shell exits with an error status if a variable
|
||||
36. A non-interactive shell exits with an error status if a variable
|
||||
assignment error occurs when no command name follows the assignment
|
||||
statements. A variable assignment error occurs, for example, when
|
||||
trying to assign a value to a readonly variable.
|
||||
|
||||
36. A non-interactive shell exits with an error status if a variable
|
||||
37. A non-interactive shell exits with an error status if a variable
|
||||
assignment error occurs in an assignment statement preceding a
|
||||
special builtin, but not with any other simple command. For any
|
||||
other simple command, the shell aborts execution of that command,
|
||||
@@ -7872,160 +7887,160 @@ startup files.
|
||||
perform any further processing of the command in which the error
|
||||
occurred").
|
||||
|
||||
37. A non-interactive shell exits with an error status if the
|
||||
38. A non-interactive shell exits with an error status if the
|
||||
iteration variable in a ‘for’ statement or the selection variable
|
||||
in a ‘select’ statement is a readonly variable or has an invalid
|
||||
name.
|
||||
|
||||
38. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not
|
||||
39. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not
|
||||
found.
|
||||
|
||||
39. Non-interactive shells exit if there is a syntax error in a script
|
||||
40. Non-interactive shells exit if there is a syntax error in a script
|
||||
read with the ‘.’ or ‘source’ builtins, or in a string processed by
|
||||
the ‘eval’ builtin.
|
||||
|
||||
40. Non-interactive shells exit if the ‘export’, ‘readonly’ or ‘unset’
|
||||
41. Non-interactive shells exit if the ‘export’, ‘readonly’ or ‘unset’
|
||||
builtin commands get an argument that is not a valid identifier,
|
||||
and they are not operating on shell functions. These errors force
|
||||
an exit because these are special builtins.
|
||||
|
||||
41. Assignment statements preceding POSIX special builtins persist in
|
||||
42. Assignment statements preceding POSIX special builtins persist in
|
||||
the shell environment after the builtin completes.
|
||||
|
||||
42. The ‘command’ builtin does not prevent builtins that take
|
||||
43. The ‘command’ builtin does not prevent builtins that take
|
||||
assignment statements as arguments from expanding them as
|
||||
assignment statements; when not in POSIX mode, declaration commands
|
||||
lose their assignment statement expansion properties when preceded
|
||||
by ‘command’.
|
||||
|
||||
43. Enabling POSIX mode has the effect of setting the
|
||||
44. Enabling POSIX mode has the effect of setting the
|
||||
‘inherit_errexit’ option, so subshells spawned to execute command
|
||||
substitutions inherit the value of the ‘-e’ option from the parent
|
||||
shell. When the ‘inherit_errexit’ option is not enabled, Bash
|
||||
clears the ‘-e’ option in such subshells.
|
||||
|
||||
44. Enabling POSIX mode has the effect of setting the ‘shift_verbose’
|
||||
45. Enabling POSIX mode has the effect of setting the ‘shift_verbose’
|
||||
option, so numeric arguments to ‘shift’ that exceed the number of
|
||||
positional parameters will result in an error message.
|
||||
|
||||
45. Enabling POSIX mode has the effect of setting the
|
||||
46. Enabling POSIX mode has the effect of setting the
|
||||
‘interactive_comments’ option (*note Comments::).
|
||||
|
||||
46. The ‘.’ and ‘source’ builtins do not search the current directory
|
||||
47. The ‘.’ and ‘source’ builtins do not search the current directory
|
||||
for the filename argument if it is not found by searching ‘PATH’.
|
||||
|
||||
47. When the ‘alias’ builtin displays alias definitions, it does not
|
||||
48. When the ‘alias’ builtin displays alias definitions, it does not
|
||||
display them with a leading ‘alias ’ unless the ‘-p’ option is
|
||||
supplied.
|
||||
|
||||
48. The ‘bg’ builtin uses the required format to describe each job
|
||||
49. The ‘bg’ builtin uses the required format to describe each job
|
||||
placed in the background, which does not include an indication of
|
||||
whether the job is the current or previous job.
|
||||
|
||||
49. When the ‘cd’ builtin is invoked in logical mode, and the pathname
|
||||
50. When the ‘cd’ builtin is invoked in logical mode, and the pathname
|
||||
constructed from ‘$PWD’ and the directory name supplied as an
|
||||
argument does not refer to an existing directory, ‘cd’ will fail
|
||||
instead of falling back to physical mode.
|
||||
|
||||
50. When the ‘cd’ builtin cannot change a directory because the length
|
||||
51. When the ‘cd’ builtin cannot change a directory because the length
|
||||
of the pathname constructed from ‘$PWD’ and the directory name
|
||||
supplied as an argument exceeds ‘PATH_MAX’ when canonicalized, ‘cd’
|
||||
will attempt to use the supplied directory name.
|
||||
|
||||
51. When the ‘xpg_echo’ option is enabled, Bash does not attempt to
|
||||
52. When the ‘xpg_echo’ option is enabled, Bash does not attempt to
|
||||
interpret any arguments to ‘echo’ as options. ‘echo’ displays each
|
||||
argument after converting escape sequences.
|
||||
|
||||
52. The ‘export’ and ‘readonly’ builtin commands display their output
|
||||
53. The ‘export’ and ‘readonly’ builtin commands display their output
|
||||
in the format required by POSIX.
|
||||
|
||||
53. When listing the history, the ‘fc’ builtin does not include an
|
||||
54. When listing the history, the ‘fc’ builtin does not include an
|
||||
indication of whether or not a history entry has been modified.
|
||||
|
||||
54. The default editor used by ‘fc’ is ‘ed’.
|
||||
55. The default editor used by ‘fc’ is ‘ed’.
|
||||
|
||||
55. ‘fc’ treats extra arguments as an error instead of ignoring them.
|
||||
56. ‘fc’ treats extra arguments as an error instead of ignoring them.
|
||||
|
||||
56. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints
|
||||
57. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints
|
||||
an error message and returns failure.
|
||||
|
||||
57. The output of ‘kill -l’ prints all the signal names on a single
|
||||
58. The output of ‘kill -l’ prints all the signal names on a single
|
||||
line, separated by spaces, without the ‘SIG’ prefix.
|
||||
|
||||
58. The ‘kill’ builtin does not accept signal names with a ‘SIG’
|
||||
59. The ‘kill’ builtin does not accept signal names with a ‘SIG’
|
||||
prefix.
|
||||
|
||||
59. The ‘kill’ builtin returns a failure status if any of the pid or
|
||||
60. The ‘kill’ builtin returns a failure status if any of the pid or
|
||||
job arguments are invalid or if sending the specified signal to any
|
||||
of them fails. In default mode, ‘kill’ returns success if the
|
||||
signal was successfully sent to any of the specified processes.
|
||||
|
||||
60. The ‘printf’ builtin uses ‘double’ (via ‘strtod’) to convert
|
||||
61. The ‘printf’ builtin uses ‘double’ (via ‘strtod’) to convert
|
||||
arguments corresponding to floating point conversion specifiers,
|
||||
instead of ‘long double’ if it's available. The ‘L’ length
|
||||
modifier forces ‘printf’ to use ‘long double’ if it's available.
|
||||
|
||||
61. The ‘pwd’ builtin verifies that the value it prints is the same as
|
||||
62. The ‘pwd’ builtin verifies that the value it prints is the same as
|
||||
the current directory, even if it is not asked to check the file
|
||||
system with the ‘-P’ option.
|
||||
|
||||
62. The ‘read’ builtin may be interrupted by a signal for which a trap
|
||||
63. The ‘read’ builtin may be interrupted by a signal for which a trap
|
||||
has been set. If Bash receives a trapped signal while executing
|
||||
‘read’, the trap handler executes and ‘read’ returns an exit status
|
||||
greater than 128.
|
||||
|
||||
63. When the ‘set’ builtin is invoked without options, it does not
|
||||
64. When the ‘set’ builtin is invoked without options, it does not
|
||||
display shell function names and definitions.
|
||||
|
||||
64. When the ‘set’ builtin is invoked without options, it displays
|
||||
65. When the ‘set’ builtin is invoked without options, it displays
|
||||
variable values without quotes, unless they contain shell
|
||||
metacharacters, even if the result contains nonprinting characters.
|
||||
|
||||
65. The ‘test’ builtin compares strings using the current locale when
|
||||
66. The ‘test’ builtin compares strings using the current locale when
|
||||
evaluating the ‘<’ and ‘>’ binary operators.
|
||||
|
||||
66. The ‘test’ builtin's ‘-t’ unary primary requires an argument.
|
||||
67. The ‘test’ builtin's ‘-t’ unary primary requires an argument.
|
||||
Historical versions of ‘test’ made the argument optional in certain
|
||||
cases, and Bash attempts to accommodate those for backwards
|
||||
compatibility.
|
||||
|
||||
67. The ‘trap’ builtin displays signal names without the leading
|
||||
68. The ‘trap’ builtin displays signal names without the leading
|
||||
‘SIG’.
|
||||
|
||||
68. The ‘trap’ builtin doesn't check the first argument for a possible
|
||||
69. The ‘trap’ builtin doesn't check the first argument for a possible
|
||||
signal specification and revert the signal handling to the original
|
||||
disposition if it is, unless that argument consists solely of
|
||||
digits and is a valid signal number. If users want to reset the
|
||||
handler for a given signal to the original disposition, they should
|
||||
use ‘-’ as the first argument.
|
||||
|
||||
69. ‘trap -p’ without arguments displays signals whose dispositions
|
||||
70. ‘trap -p’ without arguments displays signals whose dispositions
|
||||
are set to SIG_DFL and those that were ignored when the shell
|
||||
started, not just trapped signals.
|
||||
|
||||
70. The ‘type’ and ‘command’ builtins will not report a non-executable
|
||||
71. The ‘type’ and ‘command’ builtins will not report a non-executable
|
||||
file as having been found, though the shell will attempt to execute
|
||||
such a file if it is the only so-named file found in ‘$PATH’.
|
||||
|
||||
71. The ‘ulimit’ builtin uses a block size of 512 bytes for the ‘-c’
|
||||
72. The ‘ulimit’ builtin uses a block size of 512 bytes for the ‘-c’
|
||||
and ‘-f’ options.
|
||||
|
||||
72. The ‘unset’ builtin with the ‘-v’ option specified returns a fatal
|
||||
73. The ‘unset’ builtin with the ‘-v’ option specified returns a fatal
|
||||
error if it attempts to unset a ‘readonly’ or ‘non-unsettable’
|
||||
variable, which causes a non-interactive shell to exit.
|
||||
|
||||
73. When asked to unset a variable that appears in an assignment
|
||||
74. When asked to unset a variable that appears in an assignment
|
||||
statement preceding the command, the ‘unset’ builtin attempts to
|
||||
unset a variable of the same name in the current or previous scope
|
||||
as well. This implements the required "if an assigned variable is
|
||||
further modified by the utility, the modifications made by the
|
||||
utility shall persist" behavior.
|
||||
|
||||
74. The arrival of ‘SIGCHLD’ when a trap is set on ‘SIGCHLD’ does not
|
||||
75. The arrival of ‘SIGCHLD’ when a trap is set on ‘SIGCHLD’ does not
|
||||
interrupt the ‘wait’ builtin and cause it to return immediately.
|
||||
The trap command is run once for each child that exits.
|
||||
|
||||
75. Bash removes an exited background process's status from the list
|
||||
76. Bash removes an exited background process's status from the list
|
||||
of such statuses after the ‘wait’ builtin returns it.
|
||||
|
||||
There is additional POSIX behavior that Bash does not implement by
|
||||
@@ -10254,12 +10269,27 @@ File: bash.info, Node: Miscellaneous Commands, Prev: Keyboard Macros, Up: Bin
|
||||
is supplied, append a ‘*’ before pathname expansion.
|
||||
|
||||
‘shell-expand-line (M-C-e)’
|
||||
Expand the line by performing shell word expansions. This performs
|
||||
alias and history expansion, $'STRING' and $"STRING" quoting, tilde
|
||||
expansion, parameter and variable expansion, arithmetic expansion,
|
||||
command and process substitution, word splitting, and quote
|
||||
removal. An explicit argument suppresses command and process
|
||||
substitution.
|
||||
Expand the line by performing shell word expansions, treating the
|
||||
line as a single shell word. This performs alias and history
|
||||
expansion, $'STRING' and $"STRING" quoting, tilde expansion,
|
||||
parameter and variable expansion, arithmetic expansion, command and
|
||||
process substitution, word splitting, and quote removal. An
|
||||
explicit argument suppresses command and process substitution and
|
||||
treats the line as if it were quoted as part of a here-document.
|
||||
|
||||
‘shell-expand-and-requote-line ()’
|
||||
Expand the line by performing shell word expansions, splitting the
|
||||
line into shell words in the same way as for programmable
|
||||
completion. This performs alias and history expansion, $'STRING'
|
||||
and $"STRING" quoting, tilde expansion, parameter and variable
|
||||
expansion, arithmetic expansion, command and process substitution,
|
||||
word splitting, and quote removal on each word, then quotes the
|
||||
resulting words if necessary to prevent further expansion. An
|
||||
explicit argument suppresses command and process substitution and
|
||||
quotes each resultant word. As usual, double-quoting a word will
|
||||
suppress word splitting. This can be useful when combined with
|
||||
suppressing command substitution, for instance, so the words in the
|
||||
command substitution aren't quoted individually.
|
||||
|
||||
‘history-expand-line (M-^)’
|
||||
Perform history expansion on the current line.
|
||||
@@ -13321,7 +13351,7 @@ D.4 Function Index
|
||||
* accept-line (Newline or Return): Commands For History.
|
||||
(line 6)
|
||||
* alias-expand-line (): Miscellaneous Commands.
|
||||
(line 134)
|
||||
(line 149)
|
||||
* backward-char (C-b): Commands For Moving. (line 18)
|
||||
* backward-delete-char (Rubout): Commands For Text. (line 18)
|
||||
* backward-kill-line (C-x Rubout): Commands For Killing.
|
||||
@@ -13370,7 +13400,7 @@ D.4 Function Index
|
||||
(line 50)
|
||||
* digit-argument (M-0, M-1, ... M--): Numeric Arguments. (line 6)
|
||||
* display-shell-version (C-x C-v): Miscellaneous Commands.
|
||||
(line 148)
|
||||
(line 163)
|
||||
* do-lowercase-version (M-A, M-B, M-X, ...): Miscellaneous Commands.
|
||||
(line 14)
|
||||
* downcase-word (M-l): Commands For Text. (line 69)
|
||||
@@ -13383,7 +13413,7 @@ D.4 Function Index
|
||||
* dynamic-complete-history (M-<TAB>): Commands For Completion.
|
||||
(line 115)
|
||||
* edit-and-execute-command (C-x C-e): Miscellaneous Commands.
|
||||
(line 143)
|
||||
(line 158)
|
||||
* end-kbd-macro (C-x )): Keyboard Macros. (line 9)
|
||||
* end-of-file (usually C-d): Commands For Text. (line 6)
|
||||
* end-of-history (M->): Commands For History.
|
||||
@@ -13409,9 +13439,9 @@ D.4 Function Index
|
||||
* glob-list-expansions (C-x g): Miscellaneous Commands.
|
||||
(line 114)
|
||||
* history-and-alias-expand-line (): Miscellaneous Commands.
|
||||
(line 137)
|
||||
(line 152)
|
||||
* history-expand-line (M-^): Miscellaneous Commands.
|
||||
(line 127)
|
||||
(line 142)
|
||||
* history-search-backward (): Commands For History.
|
||||
(line 54)
|
||||
* history-search-forward (): Commands For History.
|
||||
@@ -13425,7 +13455,7 @@ D.4 Function Index
|
||||
* insert-completions (M-*): Commands For Completion.
|
||||
(line 24)
|
||||
* insert-last-argument (M-. or M-_): Miscellaneous Commands.
|
||||
(line 140)
|
||||
(line 155)
|
||||
* kill-line (C-k): Commands For Killing.
|
||||
(line 6)
|
||||
* kill-region (): Commands For Killing.
|
||||
@@ -13435,7 +13465,7 @@ D.4 Function Index
|
||||
* kill-word (M-d): Commands For Killing.
|
||||
(line 23)
|
||||
* magic-space (): Miscellaneous Commands.
|
||||
(line 130)
|
||||
(line 145)
|
||||
* menu-complete (): Commands For Completion.
|
||||
(line 28)
|
||||
* menu-complete-backward (): Commands For Completion.
|
||||
@@ -13482,6 +13512,8 @@ D.4 Function Index
|
||||
* shell-backward-kill-word (): Commands For Killing.
|
||||
(line 37)
|
||||
* shell-backward-word (M-C-b): Commands For Moving. (line 34)
|
||||
* shell-expand-and-requote-line (): Miscellaneous Commands.
|
||||
(line 128)
|
||||
* shell-expand-line (M-C-e): Miscellaneous Commands.
|
||||
(line 119)
|
||||
* shell-forward-word (M-C-f): Commands For Moving. (line 30)
|
||||
@@ -13693,138 +13725,138 @@ D.5 Concept Index
|
||||
|
||||
|
||||
Tag Table:
|
||||
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 Substitution103734
|
||||
Node: Arithmetic Expansion107263
|
||||
Node: Process Substitution108439
|
||||
Node: Word Splitting109547
|
||||
Node: Filename Expansion111991
|
||||
Node: Pattern Matching115215
|
||||
Node: Quote Removal120981
|
||||
Node: Redirections121285
|
||||
Node: Executing Commands131541
|
||||
Node: Simple Command Expansion132208
|
||||
Node: Command Search and Execution134316
|
||||
Node: Command Execution Environment136760
|
||||
Node: Environment140208
|
||||
Node: Exit Status142111
|
||||
Node: Signals144170
|
||||
Node: Shell Scripts149118
|
||||
Node: Shell Builtin Commands152416
|
||||
Node: Bourne Shell Builtins154757
|
||||
Node: Bash Builtins181476
|
||||
Node: Modifying Shell Behavior219212
|
||||
Node: The Set Builtin219554
|
||||
Node: The Shopt Builtin231548
|
||||
Node: Special Builtins248601
|
||||
Node: Shell Variables249590
|
||||
Node: Bourne Shell Variables250024
|
||||
Node: Bash Variables252532
|
||||
Node: Bash Features291816
|
||||
Node: Invoking Bash292830
|
||||
Node: Bash Startup Files299414
|
||||
Node: Interactive Shells304656
|
||||
Node: What is an Interactive Shell?305064
|
||||
Node: Is this Shell Interactive?305726
|
||||
Node: Interactive Shell Behavior306550
|
||||
Node: Bash Conditional Expressions310311
|
||||
Node: Shell Arithmetic315728
|
||||
Node: Aliases319055
|
||||
Node: Arrays322189
|
||||
Node: The Directory Stack329892
|
||||
Node: Directory Stack Builtins330689
|
||||
Node: Controlling the Prompt335134
|
||||
Node: The Restricted Shell338018
|
||||
Node: Bash POSIX Mode340900
|
||||
Node: Shell Compatibility Mode359847
|
||||
Node: Job Control368854
|
||||
Node: Job Control Basics369311
|
||||
Node: Job Control Builtins375679
|
||||
Node: Job Control Variables382467
|
||||
Node: Command Line Editing383698
|
||||
Node: Introduction and Notation385401
|
||||
Node: Readline Interaction387753
|
||||
Node: Readline Bare Essentials388941
|
||||
Node: Readline Movement Commands390749
|
||||
Node: Readline Killing Commands391745
|
||||
Node: Readline Arguments393768
|
||||
Node: Searching394858
|
||||
Node: Readline Init File397101
|
||||
Node: Readline Init File Syntax398404
|
||||
Node: Conditional Init Constructs425355
|
||||
Node: Sample Init File429740
|
||||
Node: Bindable Readline Commands432860
|
||||
Node: Commands For Moving434398
|
||||
Node: Commands For History436862
|
||||
Node: Commands For Text442253
|
||||
Node: Commands For Killing446378
|
||||
Node: Numeric Arguments449166
|
||||
Node: Commands For Completion450318
|
||||
Node: Keyboard Macros456014
|
||||
Node: Miscellaneous Commands456715
|
||||
Node: Readline vi Mode463282
|
||||
Node: Programmable Completion464259
|
||||
Node: Programmable Completion Builtins473995
|
||||
Node: A Programmable Completion Example485732
|
||||
Node: Using History Interactively491077
|
||||
Node: Bash History Facilities491758
|
||||
Node: Bash History Builtins495493
|
||||
Node: History Interaction503088
|
||||
Node: Event Designators508038
|
||||
Node: Word Designators509616
|
||||
Node: Modifiers512008
|
||||
Node: Installing Bash513945
|
||||
Node: Basic Installation515061
|
||||
Node: Compilers and Options518937
|
||||
Node: Compiling For Multiple Architectures519687
|
||||
Node: Installation Names521440
|
||||
Node: Specifying the System Type523674
|
||||
Node: Sharing Defaults524420
|
||||
Node: Operation Controls525134
|
||||
Node: Optional Features526153
|
||||
Node: Reporting Bugs538876
|
||||
Node: Major Differences From The Bourne Shell540233
|
||||
Node: GNU Free Documentation License561660
|
||||
Node: Indexes586837
|
||||
Node: Builtin Index587288
|
||||
Node: Reserved Word Index594386
|
||||
Node: Variable Index596831
|
||||
Node: Function Index614244
|
||||
Node: Concept Index628239
|
||||
Node: Top899
|
||||
Node: Introduction2838
|
||||
Node: What is Bash?3051
|
||||
Node: What is a shell?4184
|
||||
Node: Definitions6794
|
||||
Node: Basic Shell Features10121
|
||||
Node: Shell Syntax11345
|
||||
Node: Shell Operation12372
|
||||
Node: Quoting13663
|
||||
Node: Escape Character15001
|
||||
Node: Single Quotes15536
|
||||
Node: Double Quotes15885
|
||||
Node: ANSI-C Quoting17230
|
||||
Node: Locale Translation18624
|
||||
Node: Creating Internationalized Scripts20027
|
||||
Node: Comments24225
|
||||
Node: Shell Commands24992
|
||||
Node: Reserved Words25931
|
||||
Node: Simple Commands27074
|
||||
Node: Pipelines27736
|
||||
Node: Lists30992
|
||||
Node: Compound Commands32941
|
||||
Node: Looping Constructs33950
|
||||
Node: Conditional Constructs36499
|
||||
Node: Command Grouping51636
|
||||
Node: Coprocesses53128
|
||||
Node: GNU Parallel55814
|
||||
Node: Shell Functions56732
|
||||
Node: Shell Parameters65180
|
||||
Node: Positional Parameters70081
|
||||
Node: Special Parameters71171
|
||||
Node: Shell Expansions74632
|
||||
Node: Brace Expansion76821
|
||||
Node: Tilde Expansion80157
|
||||
Node: Shell Parameter Expansion83112
|
||||
Node: Command Substitution103759
|
||||
Node: Arithmetic Expansion107610
|
||||
Node: Process Substitution108786
|
||||
Node: Word Splitting109894
|
||||
Node: Filename Expansion112338
|
||||
Node: Pattern Matching115562
|
||||
Node: Quote Removal121328
|
||||
Node: Redirections121632
|
||||
Node: Executing Commands131888
|
||||
Node: Simple Command Expansion132555
|
||||
Node: Command Search and Execution134663
|
||||
Node: Command Execution Environment137107
|
||||
Node: Environment140633
|
||||
Node: Exit Status142536
|
||||
Node: Signals144595
|
||||
Node: Shell Scripts149543
|
||||
Node: Shell Builtin Commands152841
|
||||
Node: Bourne Shell Builtins155182
|
||||
Node: Bash Builtins181901
|
||||
Node: Modifying Shell Behavior219637
|
||||
Node: The Set Builtin219979
|
||||
Node: The Shopt Builtin231973
|
||||
Node: Special Builtins249026
|
||||
Node: Shell Variables250015
|
||||
Node: Bourne Shell Variables250449
|
||||
Node: Bash Variables252957
|
||||
Node: Bash Features292241
|
||||
Node: Invoking Bash293255
|
||||
Node: Bash Startup Files299839
|
||||
Node: Interactive Shells305081
|
||||
Node: What is an Interactive Shell?305489
|
||||
Node: Is this Shell Interactive?306151
|
||||
Node: Interactive Shell Behavior306975
|
||||
Node: Bash Conditional Expressions310736
|
||||
Node: Shell Arithmetic316153
|
||||
Node: Aliases319480
|
||||
Node: Arrays322614
|
||||
Node: The Directory Stack330317
|
||||
Node: Directory Stack Builtins331114
|
||||
Node: Controlling the Prompt335559
|
||||
Node: The Restricted Shell338443
|
||||
Node: Bash POSIX Mode341325
|
||||
Node: Shell Compatibility Mode360741
|
||||
Node: Job Control369748
|
||||
Node: Job Control Basics370205
|
||||
Node: Job Control Builtins376573
|
||||
Node: Job Control Variables383361
|
||||
Node: Command Line Editing384592
|
||||
Node: Introduction and Notation386295
|
||||
Node: Readline Interaction388647
|
||||
Node: Readline Bare Essentials389835
|
||||
Node: Readline Movement Commands391643
|
||||
Node: Readline Killing Commands392639
|
||||
Node: Readline Arguments394662
|
||||
Node: Searching395752
|
||||
Node: Readline Init File397995
|
||||
Node: Readline Init File Syntax399298
|
||||
Node: Conditional Init Constructs426249
|
||||
Node: Sample Init File430634
|
||||
Node: Bindable Readline Commands433754
|
||||
Node: Commands For Moving435292
|
||||
Node: Commands For History437756
|
||||
Node: Commands For Text443147
|
||||
Node: Commands For Killing447272
|
||||
Node: Numeric Arguments450060
|
||||
Node: Commands For Completion451212
|
||||
Node: Keyboard Macros456908
|
||||
Node: Miscellaneous Commands457609
|
||||
Node: Readline vi Mode465152
|
||||
Node: Programmable Completion466129
|
||||
Node: Programmable Completion Builtins475865
|
||||
Node: A Programmable Completion Example487602
|
||||
Node: Using History Interactively492947
|
||||
Node: Bash History Facilities493628
|
||||
Node: Bash History Builtins497363
|
||||
Node: History Interaction504958
|
||||
Node: Event Designators509908
|
||||
Node: Word Designators511486
|
||||
Node: Modifiers513878
|
||||
Node: Installing Bash515815
|
||||
Node: Basic Installation516931
|
||||
Node: Compilers and Options520807
|
||||
Node: Compiling For Multiple Architectures521557
|
||||
Node: Installation Names523310
|
||||
Node: Specifying the System Type525544
|
||||
Node: Sharing Defaults526290
|
||||
Node: Operation Controls527004
|
||||
Node: Optional Features528023
|
||||
Node: Reporting Bugs540746
|
||||
Node: Major Differences From The Bourne Shell542103
|
||||
Node: GNU Free Documentation License563530
|
||||
Node: Indexes588707
|
||||
Node: Builtin Index589158
|
||||
Node: Reserved Word Index596256
|
||||
Node: Variable Index598701
|
||||
Node: Function Index616114
|
||||
Node: Concept Index630247
|
||||
|
||||
End Tag Table
|
||||
|
||||
|
||||
+246
-214
@@ -2,12 +2,12 @@ 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, 26 December 2025).
|
||||
Bash shell (version 5.3, 14 January 2026).
|
||||
|
||||
This is Edition 5.3, last updated 26 December 2025, of ‘The GNU Bash
|
||||
This is Edition 5.3, last updated 14 January 2026, of ‘The GNU Bash
|
||||
Reference Manual’, for ‘Bash’, Version 5.3.
|
||||
|
||||
Copyright © 1988-2025 Free Software Foundation, Inc.
|
||||
Copyright © 1988-2026 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this
|
||||
document under the terms of the GNU Free Documentation License,
|
||||
@@ -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, 26 December 2025). The Bash home page is
|
||||
Bash shell (version 5.3, 14 January 2026). The Bash home page is
|
||||
<http://www.gnu.org/software/bash/>.
|
||||
|
||||
This is Edition 5.3, last updated 26 December 2025, of ‘The GNU Bash
|
||||
This is Edition 5.3, last updated 14 January 2026, of ‘The GNU Bash
|
||||
Reference Manual’, for ‘Bash’, Version 5.3.
|
||||
|
||||
Bash contains features that appear in other popular shells, and some
|
||||
@@ -787,8 +787,8 @@ executing the command in the “background”, and these are referred to as
|
||||
“asynchronous” commands. The shell does not wait for the command to
|
||||
finish, and the return status is 0 (true). When job control is not
|
||||
active (*note Job Control::), the standard input for asynchronous
|
||||
commands, in the absence of any explicit redirections, is redirected
|
||||
from ‘/dev/null’.
|
||||
commands, in the absence of any explicit redirections involving the
|
||||
standard input, is redirected from ‘/dev/null’.
|
||||
|
||||
Commands separated or terminated by ‘;’ (or equivalent ‘newline’) are
|
||||
executed sequentially; the shell waits for each command to terminate in
|
||||
@@ -2387,7 +2387,7 @@ which executes COMMAND in the current execution environment and captures
|
||||
its output, again with trailing newlines removed.
|
||||
|
||||
The character C following the open brace must be a space, tab,
|
||||
newline, or ‘|’, and the close brace must be in a position where a
|
||||
newline, ‘|’, or ‘;’; and the close brace must be in a position where a
|
||||
reserved word may appear (i.e., preceded by a command terminator such as
|
||||
semicolon). Bash allows the close brace to be joined to the remaining
|
||||
characters in the word without being followed by a shell metacharacter
|
||||
@@ -2403,6 +2403,12 @@ function is executing, and the ‘return’ builtin forces COMMAND to
|
||||
complete; however, the rest of the execution environment, including the
|
||||
positional parameters, is shared with the caller.
|
||||
|
||||
If the first character following the open brace is a ‘;’, the
|
||||
construct behaves like the form above but preserves any trailing
|
||||
newlines in the output of COMMAND instead of removing them. This form
|
||||
is useful when the trailing newlines are significant and should not be
|
||||
stripped from the command's output.
|
||||
|
||||
If the first character following the open brace is a ‘|’, the
|
||||
construct expands to the value of the ‘REPLY’ shell variable after
|
||||
COMMAND executes, without removing any trailing newlines, and the
|
||||
@@ -3164,9 +3170,10 @@ subshells See the description of the ‘inherit_errexit’ shell option
|
||||
POSIX mode.
|
||||
|
||||
If a command is followed by a ‘&’ and job control is not active, the
|
||||
default standard input for the command is the empty file ‘/dev/null’.
|
||||
Otherwise, the invoked command inherits the file descriptors of the
|
||||
calling shell as modified by redirections.
|
||||
default standard input for the command is the empty file ‘/dev/null’,
|
||||
unless the command has an explicit redirection involving the standard
|
||||
input. Otherwise, the invoked command inherits the file descriptors of
|
||||
the calling shell as modified by redirections.
|
||||
|
||||
|
||||
File: bashref.info, Node: Environment, Next: Exit Status, Prev: Command Execution Environment, Up: Executing Commands
|
||||
@@ -7714,10 +7721,10 @@ there are areas where the Bash default behavior differs from the
|
||||
specification. The Bash “posix mode” changes the Bash behavior in these
|
||||
areas so that it conforms more strictly to the standard.
|
||||
|
||||
Starting Bash with the ‘--posix’ command-line option or executing
|
||||
‘set -o posix’ while Bash is running will cause Bash to conform more
|
||||
closely to the POSIX standard by changing the behavior to match that
|
||||
specified by POSIX in areas where the Bash default differs.
|
||||
Starting Bash with the ‘--posix’ or ‘-o posix’ command-line option or
|
||||
executing ‘set -o posix’ while Bash is running will cause Bash to
|
||||
conform more closely to the POSIX standard by changing the behavior to
|
||||
match that specified by POSIX in areas where the Bash default differs.
|
||||
|
||||
When invoked as ‘sh’, Bash enters POSIX mode after reading the
|
||||
startup files.
|
||||
@@ -7807,65 +7814,73 @@ startup files.
|
||||
the command hash table, even if it returns it as a (last-ditch)
|
||||
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)".
|
||||
22. Normally, when job control is not enabled, the shell implicitly
|
||||
redirects the standard input of asynchronous commands from
|
||||
‘/dev/null’. A redirection to the standard input in this command
|
||||
inhibits this implicit redirection. In POSIX mode, a redirection
|
||||
that redirects file descriptor 0 to itself (e.g., ‘<&0’) does not
|
||||
count as a redirection that overrides the implicit redirection from
|
||||
‘/dev/null’.
|
||||
|
||||
23. The message printed by the job control code and builtins when a
|
||||
job exits with a non-zero status is "Done(status)".
|
||||
|
||||
24. The message printed by the job control code and builtins when a
|
||||
job is stopped is "Stopped(SIGNAME)", where SIGNAME is, for
|
||||
example, ‘SIGTSTP’.
|
||||
|
||||
24. If the shell is interactive, Bash does not perform job
|
||||
25. If the shell is interactive, Bash does not perform job
|
||||
notifications between executing commands in lists separated by ‘;’
|
||||
or newline. Non-interactive shells print status messages after a
|
||||
foreground job in a list completes.
|
||||
|
||||
25. If the shell is interactive, Bash waits until the next prompt
|
||||
26. If the shell is interactive, Bash waits until the next prompt
|
||||
before printing the status of a background job that changes status
|
||||
or a foreground job that terminates due to a signal.
|
||||
Non-interactive shells print status messages after a foreground job
|
||||
completes.
|
||||
|
||||
26. Bash permanently removes jobs from the jobs table after notifying
|
||||
27. Bash permanently removes jobs from the jobs table after notifying
|
||||
the user of their termination via the ‘wait’ or ‘jobs’ builtins.
|
||||
It removes the job from the jobs list after notifying the user of
|
||||
its termination, but the status is still available via ‘wait’, as
|
||||
long as ‘wait’ is supplied a PID argument.
|
||||
|
||||
27. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when
|
||||
28. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when
|
||||
the ‘v’ command is run, instead of checking ‘$VISUAL’ and
|
||||
‘$EDITOR’.
|
||||
|
||||
28. Prompt expansion enables the POSIX ‘PS1’ and ‘PS2’ expansions of
|
||||
29. Prompt expansion enables the POSIX ‘PS1’ and ‘PS2’ expansions of
|
||||
‘!’ to the history number and ‘!!’ to ‘!’, and Bash performs
|
||||
parameter expansion on the values of ‘PS1’ and ‘PS2’ regardless of
|
||||
the setting of the ‘promptvars’ option.
|
||||
|
||||
29. The default history file is ‘~/.sh_history’ (this is the default
|
||||
30. The default history file is ‘~/.sh_history’ (this is the default
|
||||
value the shell assigns to ‘$HISTFILE’).
|
||||
|
||||
30. The ‘!’ character does not introduce history expansion within a
|
||||
31. The ‘!’ character does not introduce history expansion within a
|
||||
double-quoted string, even if the ‘histexpand’ option is enabled.
|
||||
|
||||
31. When printing shell function definitions (e.g., by ‘type’), Bash
|
||||
32. When printing shell function definitions (e.g., by ‘type’), Bash
|
||||
does not print the ‘function’ reserved word unless necessary.
|
||||
|
||||
32. Non-interactive shells exit if a syntax error in an arithmetic
|
||||
33. Non-interactive shells exit if a syntax error in an arithmetic
|
||||
expansion results in an invalid expression.
|
||||
|
||||
33. Non-interactive shells exit if a parameter expansion error occurs.
|
||||
34. Non-interactive shells exit if a parameter expansion error occurs.
|
||||
|
||||
34. If a POSIX special builtin returns an error status, a
|
||||
35. If a POSIX special builtin returns an error status, a
|
||||
non-interactive shell exits. The fatal errors are those listed in
|
||||
the POSIX standard, and include things like passing incorrect
|
||||
options, redirection errors, variable assignment errors for
|
||||
assignments preceding the command name, and so on.
|
||||
|
||||
35. A non-interactive shell exits with an error status if a variable
|
||||
36. A non-interactive shell exits with an error status if a variable
|
||||
assignment error occurs when no command name follows the assignment
|
||||
statements. A variable assignment error occurs, for example, when
|
||||
trying to assign a value to a readonly variable.
|
||||
|
||||
36. A non-interactive shell exits with an error status if a variable
|
||||
37. A non-interactive shell exits with an error status if a variable
|
||||
assignment error occurs in an assignment statement preceding a
|
||||
special builtin, but not with any other simple command. For any
|
||||
other simple command, the shell aborts execution of that command,
|
||||
@@ -7873,160 +7888,160 @@ startup files.
|
||||
perform any further processing of the command in which the error
|
||||
occurred").
|
||||
|
||||
37. A non-interactive shell exits with an error status if the
|
||||
38. A non-interactive shell exits with an error status if the
|
||||
iteration variable in a ‘for’ statement or the selection variable
|
||||
in a ‘select’ statement is a readonly variable or has an invalid
|
||||
name.
|
||||
|
||||
38. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not
|
||||
39. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not
|
||||
found.
|
||||
|
||||
39. Non-interactive shells exit if there is a syntax error in a script
|
||||
40. Non-interactive shells exit if there is a syntax error in a script
|
||||
read with the ‘.’ or ‘source’ builtins, or in a string processed by
|
||||
the ‘eval’ builtin.
|
||||
|
||||
40. Non-interactive shells exit if the ‘export’, ‘readonly’ or ‘unset’
|
||||
41. Non-interactive shells exit if the ‘export’, ‘readonly’ or ‘unset’
|
||||
builtin commands get an argument that is not a valid identifier,
|
||||
and they are not operating on shell functions. These errors force
|
||||
an exit because these are special builtins.
|
||||
|
||||
41. Assignment statements preceding POSIX special builtins persist in
|
||||
42. Assignment statements preceding POSIX special builtins persist in
|
||||
the shell environment after the builtin completes.
|
||||
|
||||
42. The ‘command’ builtin does not prevent builtins that take
|
||||
43. The ‘command’ builtin does not prevent builtins that take
|
||||
assignment statements as arguments from expanding them as
|
||||
assignment statements; when not in POSIX mode, declaration commands
|
||||
lose their assignment statement expansion properties when preceded
|
||||
by ‘command’.
|
||||
|
||||
43. Enabling POSIX mode has the effect of setting the
|
||||
44. Enabling POSIX mode has the effect of setting the
|
||||
‘inherit_errexit’ option, so subshells spawned to execute command
|
||||
substitutions inherit the value of the ‘-e’ option from the parent
|
||||
shell. When the ‘inherit_errexit’ option is not enabled, Bash
|
||||
clears the ‘-e’ option in such subshells.
|
||||
|
||||
44. Enabling POSIX mode has the effect of setting the ‘shift_verbose’
|
||||
45. Enabling POSIX mode has the effect of setting the ‘shift_verbose’
|
||||
option, so numeric arguments to ‘shift’ that exceed the number of
|
||||
positional parameters will result in an error message.
|
||||
|
||||
45. Enabling POSIX mode has the effect of setting the
|
||||
46. Enabling POSIX mode has the effect of setting the
|
||||
‘interactive_comments’ option (*note Comments::).
|
||||
|
||||
46. The ‘.’ and ‘source’ builtins do not search the current directory
|
||||
47. The ‘.’ and ‘source’ builtins do not search the current directory
|
||||
for the filename argument if it is not found by searching ‘PATH’.
|
||||
|
||||
47. When the ‘alias’ builtin displays alias definitions, it does not
|
||||
48. When the ‘alias’ builtin displays alias definitions, it does not
|
||||
display them with a leading ‘alias ’ unless the ‘-p’ option is
|
||||
supplied.
|
||||
|
||||
48. The ‘bg’ builtin uses the required format to describe each job
|
||||
49. The ‘bg’ builtin uses the required format to describe each job
|
||||
placed in the background, which does not include an indication of
|
||||
whether the job is the current or previous job.
|
||||
|
||||
49. When the ‘cd’ builtin is invoked in logical mode, and the pathname
|
||||
50. When the ‘cd’ builtin is invoked in logical mode, and the pathname
|
||||
constructed from ‘$PWD’ and the directory name supplied as an
|
||||
argument does not refer to an existing directory, ‘cd’ will fail
|
||||
instead of falling back to physical mode.
|
||||
|
||||
50. When the ‘cd’ builtin cannot change a directory because the length
|
||||
51. When the ‘cd’ builtin cannot change a directory because the length
|
||||
of the pathname constructed from ‘$PWD’ and the directory name
|
||||
supplied as an argument exceeds ‘PATH_MAX’ when canonicalized, ‘cd’
|
||||
will attempt to use the supplied directory name.
|
||||
|
||||
51. When the ‘xpg_echo’ option is enabled, Bash does not attempt to
|
||||
52. When the ‘xpg_echo’ option is enabled, Bash does not attempt to
|
||||
interpret any arguments to ‘echo’ as options. ‘echo’ displays each
|
||||
argument after converting escape sequences.
|
||||
|
||||
52. The ‘export’ and ‘readonly’ builtin commands display their output
|
||||
53. The ‘export’ and ‘readonly’ builtin commands display their output
|
||||
in the format required by POSIX.
|
||||
|
||||
53. When listing the history, the ‘fc’ builtin does not include an
|
||||
54. When listing the history, the ‘fc’ builtin does not include an
|
||||
indication of whether or not a history entry has been modified.
|
||||
|
||||
54. The default editor used by ‘fc’ is ‘ed’.
|
||||
55. The default editor used by ‘fc’ is ‘ed’.
|
||||
|
||||
55. ‘fc’ treats extra arguments as an error instead of ignoring them.
|
||||
56. ‘fc’ treats extra arguments as an error instead of ignoring them.
|
||||
|
||||
56. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints
|
||||
57. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints
|
||||
an error message and returns failure.
|
||||
|
||||
57. The output of ‘kill -l’ prints all the signal names on a single
|
||||
58. The output of ‘kill -l’ prints all the signal names on a single
|
||||
line, separated by spaces, without the ‘SIG’ prefix.
|
||||
|
||||
58. The ‘kill’ builtin does not accept signal names with a ‘SIG’
|
||||
59. The ‘kill’ builtin does not accept signal names with a ‘SIG’
|
||||
prefix.
|
||||
|
||||
59. The ‘kill’ builtin returns a failure status if any of the pid or
|
||||
60. The ‘kill’ builtin returns a failure status if any of the pid or
|
||||
job arguments are invalid or if sending the specified signal to any
|
||||
of them fails. In default mode, ‘kill’ returns success if the
|
||||
signal was successfully sent to any of the specified processes.
|
||||
|
||||
60. The ‘printf’ builtin uses ‘double’ (via ‘strtod’) to convert
|
||||
61. The ‘printf’ builtin uses ‘double’ (via ‘strtod’) to convert
|
||||
arguments corresponding to floating point conversion specifiers,
|
||||
instead of ‘long double’ if it's available. The ‘L’ length
|
||||
modifier forces ‘printf’ to use ‘long double’ if it's available.
|
||||
|
||||
61. The ‘pwd’ builtin verifies that the value it prints is the same as
|
||||
62. The ‘pwd’ builtin verifies that the value it prints is the same as
|
||||
the current directory, even if it is not asked to check the file
|
||||
system with the ‘-P’ option.
|
||||
|
||||
62. The ‘read’ builtin may be interrupted by a signal for which a trap
|
||||
63. The ‘read’ builtin may be interrupted by a signal for which a trap
|
||||
has been set. If Bash receives a trapped signal while executing
|
||||
‘read’, the trap handler executes and ‘read’ returns an exit status
|
||||
greater than 128.
|
||||
|
||||
63. When the ‘set’ builtin is invoked without options, it does not
|
||||
64. When the ‘set’ builtin is invoked without options, it does not
|
||||
display shell function names and definitions.
|
||||
|
||||
64. When the ‘set’ builtin is invoked without options, it displays
|
||||
65. When the ‘set’ builtin is invoked without options, it displays
|
||||
variable values without quotes, unless they contain shell
|
||||
metacharacters, even if the result contains nonprinting characters.
|
||||
|
||||
65. The ‘test’ builtin compares strings using the current locale when
|
||||
66. The ‘test’ builtin compares strings using the current locale when
|
||||
evaluating the ‘<’ and ‘>’ binary operators.
|
||||
|
||||
66. The ‘test’ builtin's ‘-t’ unary primary requires an argument.
|
||||
67. The ‘test’ builtin's ‘-t’ unary primary requires an argument.
|
||||
Historical versions of ‘test’ made the argument optional in certain
|
||||
cases, and Bash attempts to accommodate those for backwards
|
||||
compatibility.
|
||||
|
||||
67. The ‘trap’ builtin displays signal names without the leading
|
||||
68. The ‘trap’ builtin displays signal names without the leading
|
||||
‘SIG’.
|
||||
|
||||
68. The ‘trap’ builtin doesn't check the first argument for a possible
|
||||
69. The ‘trap’ builtin doesn't check the first argument for a possible
|
||||
signal specification and revert the signal handling to the original
|
||||
disposition if it is, unless that argument consists solely of
|
||||
digits and is a valid signal number. If users want to reset the
|
||||
handler for a given signal to the original disposition, they should
|
||||
use ‘-’ as the first argument.
|
||||
|
||||
69. ‘trap -p’ without arguments displays signals whose dispositions
|
||||
70. ‘trap -p’ without arguments displays signals whose dispositions
|
||||
are set to SIG_DFL and those that were ignored when the shell
|
||||
started, not just trapped signals.
|
||||
|
||||
70. The ‘type’ and ‘command’ builtins will not report a non-executable
|
||||
71. The ‘type’ and ‘command’ builtins will not report a non-executable
|
||||
file as having been found, though the shell will attempt to execute
|
||||
such a file if it is the only so-named file found in ‘$PATH’.
|
||||
|
||||
71. The ‘ulimit’ builtin uses a block size of 512 bytes for the ‘-c’
|
||||
72. The ‘ulimit’ builtin uses a block size of 512 bytes for the ‘-c’
|
||||
and ‘-f’ options.
|
||||
|
||||
72. The ‘unset’ builtin with the ‘-v’ option specified returns a fatal
|
||||
73. The ‘unset’ builtin with the ‘-v’ option specified returns a fatal
|
||||
error if it attempts to unset a ‘readonly’ or ‘non-unsettable’
|
||||
variable, which causes a non-interactive shell to exit.
|
||||
|
||||
73. When asked to unset a variable that appears in an assignment
|
||||
74. When asked to unset a variable that appears in an assignment
|
||||
statement preceding the command, the ‘unset’ builtin attempts to
|
||||
unset a variable of the same name in the current or previous scope
|
||||
as well. This implements the required "if an assigned variable is
|
||||
further modified by the utility, the modifications made by the
|
||||
utility shall persist" behavior.
|
||||
|
||||
74. The arrival of ‘SIGCHLD’ when a trap is set on ‘SIGCHLD’ does not
|
||||
75. The arrival of ‘SIGCHLD’ when a trap is set on ‘SIGCHLD’ does not
|
||||
interrupt the ‘wait’ builtin and cause it to return immediately.
|
||||
The trap command is run once for each child that exits.
|
||||
|
||||
75. Bash removes an exited background process's status from the list
|
||||
76. Bash removes an exited background process's status from the list
|
||||
of such statuses after the ‘wait’ builtin returns it.
|
||||
|
||||
There is additional POSIX behavior that Bash does not implement by
|
||||
@@ -10255,12 +10270,27 @@ File: bashref.info, Node: Miscellaneous Commands, Prev: Keyboard Macros, Up:
|
||||
is supplied, append a ‘*’ before pathname expansion.
|
||||
|
||||
‘shell-expand-line (M-C-e)’
|
||||
Expand the line by performing shell word expansions. This performs
|
||||
alias and history expansion, $'STRING' and $"STRING" quoting, tilde
|
||||
expansion, parameter and variable expansion, arithmetic expansion,
|
||||
command and process substitution, word splitting, and quote
|
||||
removal. An explicit argument suppresses command and process
|
||||
substitution.
|
||||
Expand the line by performing shell word expansions, treating the
|
||||
line as a single shell word. This performs alias and history
|
||||
expansion, $'STRING' and $"STRING" quoting, tilde expansion,
|
||||
parameter and variable expansion, arithmetic expansion, command and
|
||||
process substitution, word splitting, and quote removal. An
|
||||
explicit argument suppresses command and process substitution and
|
||||
treats the line as if it were quoted as part of a here-document.
|
||||
|
||||
‘shell-expand-and-requote-line ()’
|
||||
Expand the line by performing shell word expansions, splitting the
|
||||
line into shell words in the same way as for programmable
|
||||
completion. This performs alias and history expansion, $'STRING'
|
||||
and $"STRING" quoting, tilde expansion, parameter and variable
|
||||
expansion, arithmetic expansion, command and process substitution,
|
||||
word splitting, and quote removal on each word, then quotes the
|
||||
resulting words if necessary to prevent further expansion. An
|
||||
explicit argument suppresses command and process substitution and
|
||||
quotes each resultant word. As usual, double-quoting a word will
|
||||
suppress word splitting. This can be useful when combined with
|
||||
suppressing command substitution, for instance, so the words in the
|
||||
command substitution aren't quoted individually.
|
||||
|
||||
‘history-expand-line (M-^)’
|
||||
Perform history expansion on the current line.
|
||||
@@ -13322,7 +13352,7 @@ D.4 Function Index
|
||||
* accept-line (Newline or Return): Commands For History.
|
||||
(line 6)
|
||||
* alias-expand-line (): Miscellaneous Commands.
|
||||
(line 134)
|
||||
(line 149)
|
||||
* backward-char (C-b): Commands For Moving. (line 18)
|
||||
* backward-delete-char (Rubout): Commands For Text. (line 18)
|
||||
* backward-kill-line (C-x Rubout): Commands For Killing.
|
||||
@@ -13371,7 +13401,7 @@ D.4 Function Index
|
||||
(line 50)
|
||||
* digit-argument (M-0, M-1, ... M--): Numeric Arguments. (line 6)
|
||||
* display-shell-version (C-x C-v): Miscellaneous Commands.
|
||||
(line 148)
|
||||
(line 163)
|
||||
* do-lowercase-version (M-A, M-B, M-X, ...): Miscellaneous Commands.
|
||||
(line 14)
|
||||
* downcase-word (M-l): Commands For Text. (line 69)
|
||||
@@ -13384,7 +13414,7 @@ D.4 Function Index
|
||||
* dynamic-complete-history (M-<TAB>): Commands For Completion.
|
||||
(line 115)
|
||||
* edit-and-execute-command (C-x C-e): Miscellaneous Commands.
|
||||
(line 143)
|
||||
(line 158)
|
||||
* end-kbd-macro (C-x )): Keyboard Macros. (line 9)
|
||||
* end-of-file (usually C-d): Commands For Text. (line 6)
|
||||
* end-of-history (M->): Commands For History.
|
||||
@@ -13410,9 +13440,9 @@ D.4 Function Index
|
||||
* glob-list-expansions (C-x g): Miscellaneous Commands.
|
||||
(line 114)
|
||||
* history-and-alias-expand-line (): Miscellaneous Commands.
|
||||
(line 137)
|
||||
(line 152)
|
||||
* history-expand-line (M-^): Miscellaneous Commands.
|
||||
(line 127)
|
||||
(line 142)
|
||||
* history-search-backward (): Commands For History.
|
||||
(line 54)
|
||||
* history-search-forward (): Commands For History.
|
||||
@@ -13426,7 +13456,7 @@ D.4 Function Index
|
||||
* insert-completions (M-*): Commands For Completion.
|
||||
(line 24)
|
||||
* insert-last-argument (M-. or M-_): Miscellaneous Commands.
|
||||
(line 140)
|
||||
(line 155)
|
||||
* kill-line (C-k): Commands For Killing.
|
||||
(line 6)
|
||||
* kill-region (): Commands For Killing.
|
||||
@@ -13436,7 +13466,7 @@ D.4 Function Index
|
||||
* kill-word (M-d): Commands For Killing.
|
||||
(line 23)
|
||||
* magic-space (): Miscellaneous Commands.
|
||||
(line 130)
|
||||
(line 145)
|
||||
* menu-complete (): Commands For Completion.
|
||||
(line 28)
|
||||
* menu-complete-backward (): Commands For Completion.
|
||||
@@ -13483,6 +13513,8 @@ D.4 Function Index
|
||||
* shell-backward-kill-word (): Commands For Killing.
|
||||
(line 37)
|
||||
* shell-backward-word (M-C-b): Commands For Moving. (line 34)
|
||||
* shell-expand-and-requote-line (): Miscellaneous Commands.
|
||||
(line 128)
|
||||
* shell-expand-line (M-C-e): Miscellaneous Commands.
|
||||
(line 119)
|
||||
* shell-forward-word (M-C-f): Commands For Moving. (line 30)
|
||||
@@ -13694,138 +13726,138 @@ D.5 Concept Index
|
||||
|
||||
|
||||
Tag Table:
|
||||
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 Substitution103842
|
||||
Node: Arithmetic Expansion107374
|
||||
Node: Process Substitution108553
|
||||
Node: Word Splitting109664
|
||||
Node: Filename Expansion112111
|
||||
Node: Pattern Matching115338
|
||||
Node: Quote Removal121107
|
||||
Node: Redirections121414
|
||||
Node: Executing Commands131673
|
||||
Node: Simple Command Expansion132343
|
||||
Node: Command Search and Execution134454
|
||||
Node: Command Execution Environment136901
|
||||
Node: Environment140352
|
||||
Node: Exit Status142258
|
||||
Node: Signals144320
|
||||
Node: Shell Scripts149271
|
||||
Node: Shell Builtin Commands152572
|
||||
Node: Bourne Shell Builtins154916
|
||||
Node: Bash Builtins181638
|
||||
Node: Modifying Shell Behavior219377
|
||||
Node: The Set Builtin219722
|
||||
Node: The Shopt Builtin231719
|
||||
Node: Special Builtins248775
|
||||
Node: Shell Variables249767
|
||||
Node: Bourne Shell Variables250204
|
||||
Node: Bash Variables252715
|
||||
Node: Bash Features292002
|
||||
Node: Invoking Bash293019
|
||||
Node: Bash Startup Files299606
|
||||
Node: Interactive Shells304851
|
||||
Node: What is an Interactive Shell?305262
|
||||
Node: Is this Shell Interactive?305927
|
||||
Node: Interactive Shell Behavior306754
|
||||
Node: Bash Conditional Expressions310518
|
||||
Node: Shell Arithmetic315938
|
||||
Node: Aliases319268
|
||||
Node: Arrays322405
|
||||
Node: The Directory Stack330111
|
||||
Node: Directory Stack Builtins330911
|
||||
Node: Controlling the Prompt335359
|
||||
Node: The Restricted Shell338246
|
||||
Node: Bash POSIX Mode341131
|
||||
Node: Shell Compatibility Mode360081
|
||||
Node: Job Control369091
|
||||
Node: Job Control Basics369551
|
||||
Node: Job Control Builtins375922
|
||||
Node: Job Control Variables382713
|
||||
Node: Command Line Editing383947
|
||||
Node: Introduction and Notation385653
|
||||
Node: Readline Interaction388008
|
||||
Node: Readline Bare Essentials389199
|
||||
Node: Readline Movement Commands391010
|
||||
Node: Readline Killing Commands392009
|
||||
Node: Readline Arguments394035
|
||||
Node: Searching395128
|
||||
Node: Readline Init File397374
|
||||
Node: Readline Init File Syntax398680
|
||||
Node: Conditional Init Constructs425634
|
||||
Node: Sample Init File430022
|
||||
Node: Bindable Readline Commands433145
|
||||
Node: Commands For Moving434686
|
||||
Node: Commands For History437153
|
||||
Node: Commands For Text442547
|
||||
Node: Commands For Killing446675
|
||||
Node: Numeric Arguments449466
|
||||
Node: Commands For Completion450621
|
||||
Node: Keyboard Macros456320
|
||||
Node: Miscellaneous Commands457024
|
||||
Node: Readline vi Mode463594
|
||||
Node: Programmable Completion464574
|
||||
Node: Programmable Completion Builtins474313
|
||||
Node: A Programmable Completion Example486053
|
||||
Node: Using History Interactively491401
|
||||
Node: Bash History Facilities492085
|
||||
Node: Bash History Builtins495823
|
||||
Node: History Interaction503421
|
||||
Node: Event Designators508374
|
||||
Node: Word Designators509955
|
||||
Node: Modifiers512350
|
||||
Node: Installing Bash514290
|
||||
Node: Basic Installation515409
|
||||
Node: Compilers and Options519288
|
||||
Node: Compiling For Multiple Architectures520041
|
||||
Node: Installation Names521797
|
||||
Node: Specifying the System Type524034
|
||||
Node: Sharing Defaults524783
|
||||
Node: Operation Controls525500
|
||||
Node: Optional Features526522
|
||||
Node: Reporting Bugs539248
|
||||
Node: Major Differences From The Bourne Shell540608
|
||||
Node: GNU Free Documentation License562038
|
||||
Node: Indexes587218
|
||||
Node: Builtin Index587672
|
||||
Node: Reserved Word Index594773
|
||||
Node: Variable Index597221
|
||||
Node: Function Index614637
|
||||
Node: Concept Index628635
|
||||
Node: Top902
|
||||
Node: Introduction2844
|
||||
Node: What is Bash?3060
|
||||
Node: What is a shell?4196
|
||||
Node: Definitions6809
|
||||
Node: Basic Shell Features10139
|
||||
Node: Shell Syntax11366
|
||||
Node: Shell Operation12396
|
||||
Node: Quoting13690
|
||||
Node: Escape Character15031
|
||||
Node: Single Quotes15569
|
||||
Node: Double Quotes15921
|
||||
Node: ANSI-C Quoting17269
|
||||
Node: Locale Translation18666
|
||||
Node: Creating Internationalized Scripts20072
|
||||
Node: Comments24273
|
||||
Node: Shell Commands25043
|
||||
Node: Reserved Words25985
|
||||
Node: Simple Commands27131
|
||||
Node: Pipelines27796
|
||||
Node: Lists31055
|
||||
Node: Compound Commands33007
|
||||
Node: Looping Constructs34019
|
||||
Node: Conditional Constructs36571
|
||||
Node: Command Grouping51711
|
||||
Node: Coprocesses53206
|
||||
Node: GNU Parallel55895
|
||||
Node: Shell Functions56816
|
||||
Node: Shell Parameters65267
|
||||
Node: Positional Parameters70171
|
||||
Node: Special Parameters71264
|
||||
Node: Shell Expansions74728
|
||||
Node: Brace Expansion76920
|
||||
Node: Tilde Expansion80259
|
||||
Node: Shell Parameter Expansion83217
|
||||
Node: Command Substitution103867
|
||||
Node: Arithmetic Expansion107721
|
||||
Node: Process Substitution108900
|
||||
Node: Word Splitting110011
|
||||
Node: Filename Expansion112458
|
||||
Node: Pattern Matching115685
|
||||
Node: Quote Removal121454
|
||||
Node: Redirections121761
|
||||
Node: Executing Commands132020
|
||||
Node: Simple Command Expansion132690
|
||||
Node: Command Search and Execution134801
|
||||
Node: Command Execution Environment137248
|
||||
Node: Environment140777
|
||||
Node: Exit Status142683
|
||||
Node: Signals144745
|
||||
Node: Shell Scripts149696
|
||||
Node: Shell Builtin Commands152997
|
||||
Node: Bourne Shell Builtins155341
|
||||
Node: Bash Builtins182063
|
||||
Node: Modifying Shell Behavior219802
|
||||
Node: The Set Builtin220147
|
||||
Node: The Shopt Builtin232144
|
||||
Node: Special Builtins249200
|
||||
Node: Shell Variables250192
|
||||
Node: Bourne Shell Variables250629
|
||||
Node: Bash Variables253140
|
||||
Node: Bash Features292427
|
||||
Node: Invoking Bash293444
|
||||
Node: Bash Startup Files300031
|
||||
Node: Interactive Shells305276
|
||||
Node: What is an Interactive Shell?305687
|
||||
Node: Is this Shell Interactive?306352
|
||||
Node: Interactive Shell Behavior307179
|
||||
Node: Bash Conditional Expressions310943
|
||||
Node: Shell Arithmetic316363
|
||||
Node: Aliases319693
|
||||
Node: Arrays322830
|
||||
Node: The Directory Stack330536
|
||||
Node: Directory Stack Builtins331336
|
||||
Node: Controlling the Prompt335784
|
||||
Node: The Restricted Shell338671
|
||||
Node: Bash POSIX Mode341556
|
||||
Node: Shell Compatibility Mode360975
|
||||
Node: Job Control369985
|
||||
Node: Job Control Basics370445
|
||||
Node: Job Control Builtins376816
|
||||
Node: Job Control Variables383607
|
||||
Node: Command Line Editing384841
|
||||
Node: Introduction and Notation386547
|
||||
Node: Readline Interaction388902
|
||||
Node: Readline Bare Essentials390093
|
||||
Node: Readline Movement Commands391904
|
||||
Node: Readline Killing Commands392903
|
||||
Node: Readline Arguments394929
|
||||
Node: Searching396022
|
||||
Node: Readline Init File398268
|
||||
Node: Readline Init File Syntax399574
|
||||
Node: Conditional Init Constructs426528
|
||||
Node: Sample Init File430916
|
||||
Node: Bindable Readline Commands434039
|
||||
Node: Commands For Moving435580
|
||||
Node: Commands For History438047
|
||||
Node: Commands For Text443441
|
||||
Node: Commands For Killing447569
|
||||
Node: Numeric Arguments450360
|
||||
Node: Commands For Completion451515
|
||||
Node: Keyboard Macros457214
|
||||
Node: Miscellaneous Commands457918
|
||||
Node: Readline vi Mode465464
|
||||
Node: Programmable Completion466444
|
||||
Node: Programmable Completion Builtins476183
|
||||
Node: A Programmable Completion Example487923
|
||||
Node: Using History Interactively493271
|
||||
Node: Bash History Facilities493955
|
||||
Node: Bash History Builtins497693
|
||||
Node: History Interaction505291
|
||||
Node: Event Designators510244
|
||||
Node: Word Designators511825
|
||||
Node: Modifiers514220
|
||||
Node: Installing Bash516160
|
||||
Node: Basic Installation517279
|
||||
Node: Compilers and Options521158
|
||||
Node: Compiling For Multiple Architectures521911
|
||||
Node: Installation Names523667
|
||||
Node: Specifying the System Type525904
|
||||
Node: Sharing Defaults526653
|
||||
Node: Operation Controls527370
|
||||
Node: Optional Features528392
|
||||
Node: Reporting Bugs541118
|
||||
Node: Major Differences From The Bourne Shell542478
|
||||
Node: GNU Free Documentation License563908
|
||||
Node: Indexes589088
|
||||
Node: Builtin Index589542
|
||||
Node: Reserved Word Index596643
|
||||
Node: Variable Index599091
|
||||
Node: Function Index616507
|
||||
Node: Concept Index630643
|
||||
|
||||
End Tag Table
|
||||
|
||||
|
||||
+14
-4
@@ -14,7 +14,7 @@ This is Edition @value{EDITION}, last updated @value{UPDATED},
|
||||
of @cite{The GNU Bash Reference Manual},
|
||||
for @code{Bash}, Version @value{VERSION}.
|
||||
|
||||
Copyright @copyright{} 1988--2025 Free Software Foundation, Inc.
|
||||
Copyright @copyright{} 1988--2026 Free Software Foundation, Inc.
|
||||
|
||||
@quotation
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
@@ -2881,7 +2881,8 @@ which executes @var{command} in the current execution environment
|
||||
and captures its output, again with trailing newlines removed.
|
||||
|
||||
The character @var{c} following the open brace must be a space, tab,
|
||||
newline, or @samp{|}, and the close brace must be in a position
|
||||
newline, @samp{|}, or @samp{;};
|
||||
and the close brace must be in a position
|
||||
where a reserved word may appear (i.e., preceded by a command terminator
|
||||
such as semicolon).
|
||||
Bash allows the close brace to be joined to the remaining characters in
|
||||
@@ -2900,8 +2901,17 @@ function is executing, and the @code{return} builtin forces
|
||||
however, the rest of the execution environment,
|
||||
including the positional parameters, is shared with the caller.
|
||||
|
||||
If the first character following the open brace
|
||||
is a @samp{|}, the construct expands to the
|
||||
If the first character following the open brace is a
|
||||
@samp{;},
|
||||
the construct behaves like the form above but
|
||||
preserves any trailing newlines in the output of @var{command}
|
||||
instead of removing them.
|
||||
This form is useful when the trailing newlines are significant
|
||||
and should not be stripped from the command's output.
|
||||
|
||||
If the first character following the open brace is a
|
||||
@samp{|},
|
||||
the construct expands to the
|
||||
value of the @code{REPLY} shell variable after @var{command} executes,
|
||||
without removing any trailing newlines,
|
||||
and the standard output of @var{command} remains the same as in the
|
||||
|
||||
+2
-2
@@ -2,10 +2,10 @@
|
||||
Copyright (C) 1988-2026 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set LASTCHANGE Fri Jan 9 10:17:58 EST 2026
|
||||
@set LASTCHANGE Wed Jan 14 15:46:16 EST 2026
|
||||
|
||||
@set EDITION 5.3
|
||||
@set VERSION 5.3
|
||||
|
||||
@set UPDATED 9 January 2026
|
||||
@set UPDATED 14 January 2026
|
||||
@set UPDATED-MONTH January 2026
|
||||
|
||||
@@ -462,6 +462,8 @@ valid_function_word (WORD_DESC *word, int flags)
|
||||
{
|
||||
char *newname;
|
||||
|
||||
/* We perform quote removal on the function name identical to that
|
||||
performed on a quoted delimiter in a here-document. */
|
||||
newname = string_quote_removal (name, 0);
|
||||
if (newname == 0)
|
||||
{
|
||||
|
||||
@@ -827,7 +827,8 @@ slow_write_error:
|
||||
|
||||
/* Workhorse function for writing history. Writes the last NELEMENT entries
|
||||
from the history list to FILENAME. OVERWRITE is non-zero if you
|
||||
wish to replace FILENAME with the entries. */
|
||||
wish to replace FILENAME with the entries. Returns 0 if successful, or
|
||||
errno if not. */
|
||||
static int
|
||||
history_do_write (const char *filename, int nelements, int overwrite)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* parse.y - Yacc grammar for bash. */
|
||||
|
||||
/* Copyright (C) 1989-2025 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2026 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -4680,7 +4680,7 @@ INTERNAL_DEBUG(("current_token (%d) != shell_eof_token (%c)", current_token, she
|
||||
lastc = tcmd[retlen - 1];
|
||||
retlen++;
|
||||
ret = xmalloc (retlen + 4);
|
||||
ret[0] = (dolbrace_spec == '|') ? '|' : ' ';
|
||||
ret[0] = (dolbrace_spec == '|' || dolbrace_spec == ';') ? dolbrace_spec : ' ';
|
||||
strcpy (ret + 1, tcmd); /* ( */
|
||||
if (was_newline)
|
||||
ret[retlen++] = '\n';
|
||||
@@ -4764,7 +4764,7 @@ xparse_dolparen (const char *base, char *string, size_t *indp, int flags)
|
||||
local_extglob = extended_glob;
|
||||
#endif
|
||||
|
||||
if (funsub && FUNSUB_CHAR (*string) && *string == '|')
|
||||
if (funsub && FUNSUB_CHAR (*string) && (*string == '|' || *string == ';'))
|
||||
string++;
|
||||
|
||||
token_to_read = funsub ? DOLBRACE : DOLPAREN; /* let's trick the parser */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* parser.h -- Everything you wanted to know about the parser, but were
|
||||
afraid to ask. */
|
||||
|
||||
/* Copyright (C) 1995-2024 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995-2026 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -79,11 +79,7 @@ struct dstack {
|
||||
|
||||
/* characters that can appear following ${ to introduce a nofork command
|
||||
substitution. */
|
||||
#if 0
|
||||
#define FUNSUB_CHAR(n) ((n) == ' ' || (n) == '\t' || (n) == '\n' || (n) == '|' || (n) == '(') /* ) */
|
||||
#else
|
||||
#define FUNSUB_CHAR(n) ((n) == ' ' || (n) == '\t' || (n) == '\n' || (n) == '|')
|
||||
#endif
|
||||
#define FUNSUB_CHAR(n) ((n) == ' ' || (n) == '\t' || (n) == '\n' || (n) == '|' || (n) == ';')
|
||||
|
||||
/* variable declarations from parse.y */
|
||||
extern struct dstack dstack;
|
||||
|
||||
@@ -6858,37 +6858,41 @@ read_comsub (int fd, int quoted, int flags, int *rflag)
|
||||
return (char *)NULL;
|
||||
}
|
||||
|
||||
/* Strip trailing newlines from the output of the command. */
|
||||
if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
|
||||
/* Strip trailing newlines from the output of the command if
|
||||
FLAGS does not include PF_COMSUBNLS. */
|
||||
if ((flags & PF_COMSUBNLS) == 0)
|
||||
{
|
||||
while (istring_index > 0)
|
||||
if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
|
||||
{
|
||||
if (istring[istring_index - 1] == '\n')
|
||||
while (istring_index > 0)
|
||||
{
|
||||
--istring_index;
|
||||
|
||||
/* If the newline was quoted, remove the quoting char. */
|
||||
if (istring[istring_index - 1] == CTLESC)
|
||||
--istring_index;
|
||||
|
||||
#ifdef __MSYS__
|
||||
if (istring_index > 0 && istring[istring_index - 1] == '\r')
|
||||
if (istring[istring_index - 1] == '\n')
|
||||
{
|
||||
--istring_index;
|
||||
|
||||
/* If the carriage return was quoted, remove the quoting char. */
|
||||
if (istring[istring_index - 1] == CTLESC)
|
||||
/* If the newline was quoted, remove the quoting char. */
|
||||
if (istring_index > 0 && istring[istring_index - 1] == CTLESC)
|
||||
--istring_index;
|
||||
}
|
||||
|
||||
#ifdef __MSYS__
|
||||
if (istring_index > 0 && istring[istring_index - 1] == '\r')
|
||||
{
|
||||
--istring_index;
|
||||
|
||||
/* If the carriage return was quoted, remove the quoting char. */
|
||||
if (istring_index > 0 && istring[istring_index - 1] == CTLESC)
|
||||
--istring_index;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
istring[istring_index] = '\0';
|
||||
}
|
||||
istring[istring_index] = '\0';
|
||||
else
|
||||
strip_trailing (istring, istring_index - 1, 1);
|
||||
}
|
||||
else
|
||||
strip_trailing (istring, istring_index - 1, 1);
|
||||
|
||||
if (rflag)
|
||||
*rflag = tflag;
|
||||
@@ -7012,7 +7016,7 @@ function_substitute (char *string, int quoted, int flags)
|
||||
{
|
||||
volatile int function_code;
|
||||
int valsub, stdout_valid, saveout, old_frozen;
|
||||
int result, pflags, tflag, was_trap;
|
||||
int result, pflags, tflag, xflags, was_trap;
|
||||
char *istring, *s;
|
||||
WORD_DESC *ret;
|
||||
SHELL_VAR *v;
|
||||
@@ -7027,8 +7031,14 @@ function_substitute (char *string, int quoted, int flags)
|
||||
ARRAY *psa;
|
||||
#endif
|
||||
|
||||
xflags = flags;
|
||||
if (valsub = (string && *string == '|'))
|
||||
string++;
|
||||
else if (string && *string == ';')
|
||||
{
|
||||
xflags |= PF_COMSUBNLS;
|
||||
string++;
|
||||
}
|
||||
|
||||
/* In the case of no command to run, just return NULL. */
|
||||
for (s = string; s && *s && (shellblank (*s) || *s == '\n'); s++)
|
||||
@@ -7192,7 +7202,7 @@ function_substitute (char *string, int quoted, int flags)
|
||||
/* We call anonclose as part of the outer nofork unwind-protects */
|
||||
BLOCK_SIGNAL (SIGINT, set, oset);
|
||||
lseek (afd, 0, SEEK_SET);
|
||||
istring = read_comsub (afd, quoted, flags, &tflag);
|
||||
istring = read_comsub (afd, quoted, xflags, &tflag);
|
||||
UNBLOCK_SIGNAL (oset);
|
||||
}
|
||||
else
|
||||
|
||||
+80
-5
@@ -65,6 +65,8 @@ one two
|
||||
comsub21.sub
|
||||
123
|
||||
123
|
||||
123
|
||||
0
|
||||
0
|
||||
123
|
||||
123
|
||||
@@ -73,8 +75,21 @@ Mon Aug 29 20:03:02 EDT 2022
|
||||
Mon Aug 29 20:03:02 EDT 2022
|
||||
Mon Aug 29 20:03:02 EDT 2022
|
||||
Mon Aug 29 20:03:02 EDT 2022
|
||||
Mon Aug 29 20:03:02 EDT 2022
|
||||
|
||||
Mon Aug 29 20:03:02 EDT 2022
|
||||
Mon Aug 29 20:03:02 EDT 2022
|
||||
Mon Aug 29 20:03:02 EDT 2022
|
||||
Mon Aug 29 20:03:02 EDT 2022
|
||||
Mon Aug 29 20:03:02 EDT 2022
|
||||
|
||||
123
|
||||
123
|
||||
|
||||
before 123
|
||||
before
|
||||
123
|
||||
|
||||
in for 123
|
||||
comsub22.sub
|
||||
outside before: value
|
||||
@@ -87,21 +102,29 @@ outside before: value
|
||||
comsub23.sub
|
||||
.
|
||||
declare -a a=([0]="1" [1]="2" [2]="3" [3]="4")
|
||||
declare -a a=([0]="1" [1]="2" [2]="3" [3]=$'4\n')
|
||||
declare -- int="2"
|
||||
after here-doc: 1
|
||||
[1]- Running sleep 1 &
|
||||
[2]+ Running sleep 1 &
|
||||
[1]- Running sleep 1 &
|
||||
[2]+ Running sleep 1 &
|
||||
[1]- Running sleep 1 &
|
||||
[2]+ Running sleep 1 &
|
||||
=
|
||||
17772 26794
|
||||
17772 26794
|
||||
we should try rhs
|
||||
comsub
|
||||
and
|
||||
funsub
|
||||
and
|
||||
newline funsub
|
||||
|
||||
in here-documents
|
||||
after all they work here
|
||||
and work here
|
||||
and also here
|
||||
after for
|
||||
uname
|
||||
after arith for
|
||||
@@ -196,6 +219,8 @@ AFTER
|
||||
unbalanced braces}}
|
||||
combined comsubs
|
||||
combined comsubs
|
||||
combined nostrip comsubs
|
||||
|
||||
inside
|
||||
after: var = inside
|
||||
after: 42 var = inside
|
||||
@@ -210,17 +235,67 @@ declare -- x=""
|
||||
a[${ unset x;}]
|
||||
declare -i x
|
||||
declare -- x=""
|
||||
./comsub27.sub: line 36: ${ unset x;}: arithmetic syntax error: operand expected (error token is "${ unset x;}")
|
||||
./comsub27.sub: line 50: ${ unset x;}: arithmetic syntax error: operand expected (error token is "${ unset x;}")
|
||||
declare -i x
|
||||
declare -- SECONDS=""
|
||||
declare -i SECONDS="0"
|
||||
declare -- x="0"
|
||||
declare -a x=([2]="a[]")
|
||||
declare -ai a=()
|
||||
./comsub27.sub: line 61: b[]: bad array subscript
|
||||
./comsub27.sub: line 61: b[]: bad array subscript
|
||||
./comsub27.sub: line 75: b[]: bad array subscript
|
||||
./comsub27.sub: line 75: b[]: bad array subscript
|
||||
declare -ai a=([0]="1" [1]="0" [2]="3")
|
||||
declare -Ai a=()
|
||||
./comsub27.sub: line 71: b[]: bad array subscript
|
||||
./comsub27.sub: line 71: b[]: bad array subscript
|
||||
./comsub27.sub: line 85: b[]: bad array subscript
|
||||
./comsub27.sub: line 85: b[]: bad array subscript
|
||||
declare -Ai a=([3]="0" [1]="0" )
|
||||
comsub28.sub
|
||||
AAaa
|
||||
bb
|
||||
cc
|
||||
ddBB
|
||||
aa bb cc dd
|
||||
AAaa bb cc dd BB
|
||||
AAaa
|
||||
bb
|
||||
cc
|
||||
dd
|
||||
BB
|
||||
aa bb cc dd
|
||||
aa
|
||||
bb
|
||||
cc
|
||||
dd
|
||||
aa bb cc dd
|
||||
DDDDDaa bb cc dd EEEEE
|
||||
DDDDDaa
|
||||
bb
|
||||
cc
|
||||
ddEEEEE
|
||||
DDDDDaa
|
||||
bb
|
||||
cc
|
||||
dd
|
||||
EEEEE
|
||||
abcde
|
||||
abcde
|
||||
=two newlines
|
||||
|
||||
=
|
||||
a
|
||||
nested
|
||||
|
||||
b
|
||||
|
||||
a
|
||||
nested
|
||||
b
|
||||
|
||||
a
|
||||
nested
|
||||
|
||||
b
|
||||
42
|
||||
|
||||
42
|
||||
42
|
||||
|
||||
@@ -153,3 +153,4 @@ test_runsub ./comsub24.sub
|
||||
test_runsub ./comsub25.sub
|
||||
test_runsub ./comsub26.sub
|
||||
test_runsub ./comsub27.sub
|
||||
test_runsub ./comsub28.sub
|
||||
|
||||
@@ -22,7 +22,9 @@ alias number="echo 123"
|
||||
|
||||
echo ${ number; }
|
||||
echo $(( ${ number; } ))
|
||||
echo $(( "${; number; }" ))
|
||||
(( ${ number; } )) ; echo $?
|
||||
(( "${; number; }" )) ; echo $?
|
||||
|
||||
set -o posix
|
||||
echo ${ number; }
|
||||
@@ -36,11 +38,17 @@ shopt -s expand_aliases
|
||||
alias my_alias='echo $DATE'
|
||||
|
||||
echo ${ eval my_alias; }
|
||||
echo ${; eval my_alias; }
|
||||
echo ${ my_alias; }
|
||||
echo ${; my_alias; }
|
||||
echo "${; my_alias; }"
|
||||
|
||||
set -o posix
|
||||
echo ${ eval my_alias; }
|
||||
echo ${; eval my_alias; }
|
||||
echo ${ my_alias; }
|
||||
echo ${; my_alias; }
|
||||
echo "${; my_alias; }"
|
||||
set +o posix ; shopt -s expand_aliases
|
||||
|
||||
alias e=echo
|
||||
@@ -48,7 +56,9 @@ alias v='e 123'
|
||||
|
||||
set -o posix
|
||||
echo ${ v; }
|
||||
echo "${; v; }"
|
||||
echo ${ echo before ; v; }
|
||||
echo "${; echo before ; v; }"
|
||||
echo ${ for f in 0; do
|
||||
echo in for
|
||||
done; v; }
|
||||
@@ -58,8 +68,10 @@ alias let='let --'
|
||||
|
||||
let '1 == 1'
|
||||
: ${ let '1 == 1'; }
|
||||
: "${; let '1 == 1'; }"
|
||||
|
||||
set -o posix
|
||||
let '1 == 1'
|
||||
: ${ let '1 == 1'; }
|
||||
: "${; let '1 == 1'; }"
|
||||
set +o posix ; shopt -s expand_aliases
|
||||
|
||||
+13
-2
@@ -16,7 +16,8 @@
|
||||
|
||||
# make sure parsing is right within conditional commands
|
||||
[[ ${ echo -n "[${ echo -n foo; }]" ; } == '[foo]' ]] || echo bad 1
|
||||
[[ "${ echo -n "[${ echo -n foo; }]" ; }" == '[foo]' ]] || echo bad 1
|
||||
[[ "${ echo "[${ echo foo; }]" ; }" == '[foo]' ]] || echo bad 2
|
||||
[[ "${; echo -n "[${; echo -n foo; }]" ; }" == '[foo]' ]] || echo bad 3
|
||||
|
||||
# mix multiple calls to parse_and_execute
|
||||
got=$(eval 'x=${ for i in test; do case $i in test) echo .;; esac; done; }' ; echo $x)
|
||||
@@ -26,6 +27,9 @@ echo $got
|
||||
: ${ a=(1 2 3 ${ echo 4;} ); }
|
||||
declare -p a
|
||||
unset a
|
||||
: ${;a=(1 2 3 "${;echo 4;}" ); } # array element contains newline
|
||||
declare -p a
|
||||
unset a
|
||||
|
||||
# function execution with side effects
|
||||
int=0
|
||||
@@ -55,6 +59,9 @@ printf '%s\n' "$jl1"
|
||||
jl2=${ jobs; }
|
||||
printf '%s\n' "$jl2"
|
||||
|
||||
jl3=${; jobs; }
|
||||
printf '%s=\n' "$jl3"
|
||||
|
||||
# nofork command substitution doesn't affect the shell's random number sequence
|
||||
RANDOM=42
|
||||
echo $RANDOM ${ echo $RANDOM; }
|
||||
@@ -69,6 +76,8 @@ we should try rhs
|
||||
${word-$(echo comsub)}
|
||||
and
|
||||
${word-${ echo funsub; }}
|
||||
and
|
||||
${word-${; echo newline funsub; }}
|
||||
in here-documents
|
||||
EOF
|
||||
|
||||
@@ -77,10 +86,12 @@ exec 4<&-
|
||||
|
||||
echo after all they ${word-$(echo work here)}
|
||||
echo and ${word-${ echo work here; }}
|
||||
echo and ${word-${; echo -n also here; }}
|
||||
|
||||
unset x
|
||||
|
||||
set -- 'a[${ break;}]'
|
||||
# now two null strings as the positional parameters
|
||||
set -- 'a[${ break;}]' 'a[${; break;}]'
|
||||
declare -n x
|
||||
|
||||
for x do :; done
|
||||
|
||||
@@ -24,6 +24,7 @@ echo ${ echo unbalanced braces; }}}
|
||||
|
||||
echo $(echo combined ${| REPLY=comsubs; })
|
||||
echo ${ echo $(echo combined ${| REPLY=comsubs; }); }
|
||||
echo "${; echo $(echo combined nostrip ${| REPLY=comsubs; }); }"
|
||||
|
||||
var=outside
|
||||
echo ${ var=inside; echo $var; }
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
declare -i x
|
||||
x='a[${ unset x;}]'
|
||||
declare -p x
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# tests of new funsub form that doesn't remove trailing newlines
|
||||
|
||||
# basic tests
|
||||
# final newline removed
|
||||
echo "AA${ printf '%s\n' aa bb cc dd; }BB"
|
||||
|
||||
# final newline not removed, newlines removed by word splitting
|
||||
echo ${;printf '%s\n' aa bb cc dd; }
|
||||
# final newline not removed, newlines removed by word splitting
|
||||
echo AA${;printf '%s\n' aa bb cc dd; }BB
|
||||
# final newline not removed, no newlines removed
|
||||
echo "AA${;printf '%s\n' aa bb cc dd; }BB"
|
||||
|
||||
# return results from first printf, newlines removed by word splitting
|
||||
echo ${;printf '%s\n' aa bb cc dd; return; echo ee ff; }
|
||||
# return results from first printf, no newlines removed
|
||||
printf '%s' "${;printf '%s\n' aa bb cc dd; return; echo ee ff; }"
|
||||
|
||||
# newlines removed by word splitting
|
||||
echo ${;printf '%s\n' aa bb cc dd
|
||||
}
|
||||
# newlines removed by word splitting
|
||||
echo DDDDD${;
|
||||
printf '%s\n' aa bb cc dd
|
||||
}EEEEE
|
||||
# newlines not removed by word splitting, final newline removed
|
||||
echo "DDDDD${
|
||||
printf '%s\n' aa bb cc dd
|
||||
}EEEEE"
|
||||
# no newlines removed
|
||||
echo "DDDDD${;
|
||||
printf '%s\n' aa bb cc dd
|
||||
}EEEEE"
|
||||
|
||||
yy=${;:;}
|
||||
unset -v yy
|
||||
|
||||
echo ${;( echo abcde ); } # newlines removed by word splitting
|
||||
printf '%s' "${;( echo abcde ); }" # no newlines removed
|
||||
|
||||
# no newlines removed
|
||||
a==${; printf '%s' $'two newlines\n\n'; }=
|
||||
echo "$a"
|
||||
|
||||
# no newlines removed
|
||||
echo "${;echo a ; echo "${;echo nested; }"; echo b; }"
|
||||
echo "${;echo a ; echo "${ echo nested; }"; echo b; }"
|
||||
echo "${ echo a ; echo "${;echo nested; }"; echo b; }"
|
||||
|
||||
# no newlines removed
|
||||
echo "${;echo $(( 24+18 )); }"
|
||||
# no newlines removed, arith parsing handles it
|
||||
echo $(( "${;echo 24 + 18; }"))
|
||||
echo $(( "${;echo 14 + 18; }+" 10))
|
||||
@@ -556,3 +556,10 @@ e
|
||||
|
||||
./history11.sub: line 71: history: 20: history position out of range
|
||||
./history11.sub: line 72: history: -30: history position out of range
|
||||
history12.sub
|
||||
./history12.sub: line 32: history: notthere: read error: No such file or directory
|
||||
./history12.sub: line 38: history: notthere: read error: Permission denied
|
||||
./history12.sub: line 40: history: .: read error: Is a directory
|
||||
./history12.sub: line 46: history: histdir: write error: Is a directory
|
||||
./history12.sub: line 47: history: histdir/notthere: write error: Permission denied
|
||||
./history12.sub: line 51: history: nodir/notthere: write error: No such file or directory
|
||||
|
||||
@@ -139,3 +139,4 @@ test_runsub ./history8.sub
|
||||
test_runsub ./history9.sub
|
||||
test_runsub ./history10.sub
|
||||
test_runsub ./history11.sub
|
||||
test_runsub ./history12.sub
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# error messages on history file read and write errors
|
||||
|
||||
: ${TMPDIR:=/tmp}
|
||||
|
||||
cd $TMPDIR || exit 1
|
||||
|
||||
FILENAME=notthere
|
||||
DIRNAME=histdir
|
||||
|
||||
unset HISTTIMEFORMAT
|
||||
rm -f $FILENAME
|
||||
|
||||
trap 'rm -f $FILENAME ; rm -rf $DIRNAME' 0 1 2 3 6 15
|
||||
|
||||
HISTFILE=/dev/null
|
||||
set -o history
|
||||
|
||||
history -r /dev/null # should succeed
|
||||
history -r notthere # failure
|
||||
|
||||
history -w # should succeed
|
||||
history -w $FILENAME # should succeed
|
||||
|
||||
chmod 200 $FILENAME
|
||||
history -r $FILENAME
|
||||
|
||||
history -r .
|
||||
|
||||
mkdir $DIRNAME
|
||||
touch $DIRNAME/$FILENAME
|
||||
chmod 555 $DIRNAME
|
||||
|
||||
history -w $DIRNAME
|
||||
history -w $DIRNAME/$FILENAME
|
||||
|
||||
chmod u+w $DIRNAME
|
||||
|
||||
history -w nodir/$FILENAME
|
||||
Reference in New Issue
Block a user