mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-21 12:57:58 +02:00
do not require leading . for rl color prefix etension; fix for isearch in single-byte locales; next set of doc updates (SIGNALS); add warning for invalid job id; allow function names to be non-identifiers in posix mode
This commit is contained in:
@@ -10398,3 +10398,70 @@ doc/bash.1,doc/bashref.texi
|
||||
- update word splitting section to add what IFS whitespace means and
|
||||
how word splitting uses it. Based on a bug-bash discussion
|
||||
|
||||
10/21
|
||||
-----
|
||||
lib/readline/colors.c
|
||||
doc/bash.1,lib/readline/doc/readline.3,lib/readline/doc/rluser.texi
|
||||
- RL_COLOR_PREFIX_EXTENSION: remove the leading `.' again; this was
|
||||
the result of a misunderstanding about how `dircolors' works
|
||||
Report from Daniël Gerbrand Haasbroek <dghaasbroek@gmail.com>
|
||||
|
||||
lib/readline/isearch.c
|
||||
- _rl_isearch_dispatch: when adding the character to the search
|
||||
string, insert it as a single byte in the C locale (or if we're
|
||||
not doing multibyte characters)
|
||||
Report and patch from Grisha Levit <grishalevit@gmail.com>
|
||||
|
||||
10/23
|
||||
-----
|
||||
doc/bash.1,doc/bashref.texi
|
||||
- SIGNALS: update section to make it clear how job control affects
|
||||
SIGINT receipt and the behavior of the shell when it's waiting
|
||||
for a command that receives one.
|
||||
From a suggestion by Simone Robinson <robinson027@yahoo.com>
|
||||
|
||||
builtins/common.c
|
||||
- get_job_spec: warn about deprecated notation if the job spec doesn't
|
||||
have a leading `%'; code to return BAD_JOBSPEC tagged for bash-5.4
|
||||
- sh_invalidjob: new convenience function to print error for invalid
|
||||
job specifications
|
||||
|
||||
builtins/jobs.def, builtins/ kill.def, builtins/ wait.def, builtins/fg_bg.def
|
||||
- handle BAD_JOBSPEC return from get_job_spec; call sh_invalidjob.
|
||||
Nothing returns that yet.
|
||||
|
||||
builtins/kill.def
|
||||
- kill_builtin: change to use common error message via sh_badpid() if
|
||||
we get an argument where the first character is not a digit or `%'
|
||||
|
||||
builtins/jobs.def
|
||||
- jobs_builtin: check for INVALID_JOB return from get_job_spec to
|
||||
avoid call to get_job_by_jid
|
||||
|
||||
10/24
|
||||
-----
|
||||
error.c, error.h
|
||||
- err_invalidid: common error function for invalid identifiers;
|
||||
changed callers in execute_cmd.c, general.c
|
||||
|
||||
general.c
|
||||
- valid_function_word: separated posix check against special builtin
|
||||
names (flags&4) and posix check for valid identifiers (flags&1);
|
||||
callers need to differentiate. This means that posix mode does not
|
||||
require function names to be valid identifiers
|
||||
|
||||
execute_cmd.c
|
||||
- execute_intern_function: don't call valid_function_word with
|
||||
(flags&1) in posix mode unless POSIX_RESTRICT_FUNCNAME is defined;
|
||||
call with flags&4 to keep the check against special builtin names
|
||||
|
||||
print_cmd.c
|
||||
- print_function_def,named_function_string: don't print functions
|
||||
with names that are invalid identifiers with a leading `function'
|
||||
|
||||
config-top.h
|
||||
- POSIX_RESTRICT_FUNCNAME: placeholder, not defined by default
|
||||
|
||||
doc/bashref.texi
|
||||
- Posix mode: remove item about function names being valid shell
|
||||
identifiers
|
||||
|
||||
@@ -94,113 +94,111 @@ The following list is what's changed when 'POSIX mode' is in effect:
|
||||
10. Redirection operators do not perform word splitting on the word in
|
||||
a redirection.
|
||||
|
||||
11. Function names must be valid shell ‘name’s. That is, they may not
|
||||
contain characters other than letters, digits, and underscores, and
|
||||
may not start with a digit. Declaring a function with an invalid
|
||||
name in a non-interactive shell is a fatal syntax error.
|
||||
|
||||
12. Function names may not be the same as one of the POSIX special
|
||||
11. Function names may not be the same as one of the POSIX special
|
||||
builtins.
|
||||
|
||||
13. Tilde expansion is only performed on assignments preceding a
|
||||
12. Tilde expansion is only performed on assignments preceding a
|
||||
command name, rather than on all assignment statements on the line.
|
||||
|
||||
14. While variable indirection is available, it may not be applied to
|
||||
13. While variable indirection is available, it may not be applied to
|
||||
the ‘#’ and ‘?’ special parameters.
|
||||
|
||||
15. Expanding the ‘*’ special parameter in a pattern context where the
|
||||
14. Expanding the ‘*’ special parameter in a pattern context where the
|
||||
expansion is double-quoted does not treat the ‘$*’ as if it were
|
||||
double-quoted.
|
||||
|
||||
16. A double quote character (‘"’) is treated specially when it
|
||||
15. A double quote character (‘"’) is treated specially when it
|
||||
appears in a backquoted command substitution in the body of a
|
||||
here-document that undergoes expansion. That means, for example,
|
||||
that a backslash preceding a double quote character will escape it
|
||||
and the backslash will be removed.
|
||||
|
||||
17. Command substitutions don't set the ‘?’ special parameter. The
|
||||
16. Command substitutions don't set the ‘?’ special parameter. The
|
||||
exit status of a simple command without a command word is still the
|
||||
exit status of the last command substitution that occurred while
|
||||
evaluating the variable assignments and redirections in that
|
||||
command, but that does not happen until after all of the
|
||||
assignments and redirections.
|
||||
|
||||
18. Literal tildes that appear as the first character in elements of
|
||||
17. Literal tildes that appear as the first character in elements of
|
||||
the ‘PATH’ variable are not expanded as described above under *note
|
||||
Tilde Expansion::.
|
||||
|
||||
19. Command lookup finds POSIX special builtins before shell
|
||||
18. Command lookup finds POSIX special builtins before shell
|
||||
functions, including output printed by the ‘type’ and ‘command’
|
||||
builtins.
|
||||
|
||||
20. Even if a shell function whose name contains a slash was defined
|
||||
19. Even if a shell function whose name contains a slash was defined
|
||||
before entering POSIX mode, the shell will not execute a function
|
||||
whose name contains one or more slashes.
|
||||
|
||||
21. When a command in the hash table no longer exists, Bash will
|
||||
20. When a command in the hash table no longer exists, Bash will
|
||||
re-search ‘$PATH’ to find the new location. This is also available
|
||||
with ‘shopt -s checkhash’.
|
||||
|
||||
22. Bash will not insert a command without the execute bit set into
|
||||
21. Bash will not insert a command without the execute bit set into
|
||||
the command hash table, even if it returns it as a (last-ditch)
|
||||
result from a ‘$PATH’ search.
|
||||
|
||||
23. The message printed by the job control code and builtins when a
|
||||
22. 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
|
||||
23. The message printed by the job control code and builtins when a
|
||||
job is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for
|
||||
example, ‘SIGTSTP’.
|
||||
|
||||
25. If the shell is interactive, Bash does not perform job
|
||||
24. 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.
|
||||
|
||||
26. If the shell is interactive, Bash waits until the next prompt
|
||||
25. 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.
|
||||
|
||||
27. Bash permanently removes jobs from the jobs table after notifying
|
||||
26. 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.
|
||||
|
||||
28. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when
|
||||
27. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when
|
||||
the ‘v’ command is run, instead of checking ‘$VISUAL’ and
|
||||
‘$EDITOR’.
|
||||
|
||||
29. Prompt expansion enables the POSIX ‘PS1’ and ‘PS2’ expansions of
|
||||
28. 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.
|
||||
|
||||
30. The default history file is ‘~/.sh_history’ (this is the default
|
||||
29. The default history file is ‘~/.sh_history’ (this is the default
|
||||
value the shell assigns to ‘$HISTFILE’).
|
||||
|
||||
31. The ‘!’ character does not introduce history expansion within a
|
||||
30. The ‘!’ character does not introduce history expansion within a
|
||||
double-quoted string, even if the ‘histexpand’ option is enabled.
|
||||
|
||||
32. When printing shell function definitions (e.g., by ‘type’), Bash
|
||||
does not print the ‘function’ keyword.
|
||||
31. When printing shell function definitions (e.g., by ‘type’), Bash
|
||||
does not print the ‘function’ keyword unless necessary.
|
||||
|
||||
33. Non-interactive shells exit if a syntax error in an arithmetic
|
||||
32. Non-interactive shells exit if a syntax error in an arithmetic
|
||||
expansion results in an invalid expression.
|
||||
|
||||
34. Non-interactive shells exit if a parameter expansion error occurs.
|
||||
33. Non-interactive shells exit if a parameter expansion error occurs.
|
||||
|
||||
35. If a POSIX special builtin returns an error status, a
|
||||
34. 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.
|
||||
|
||||
36. A non-interactive shell exits with an error status if a variable
|
||||
35. 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.
|
||||
|
||||
37. 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 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,
|
||||
@@ -208,156 +206,156 @@ The following list is what's changed when 'POSIX mode' is in effect:
|
||||
perform any further processing of the command in which the error
|
||||
occurred").
|
||||
|
||||
38. A non-interactive shell exits with an error status if the
|
||||
37. 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.
|
||||
|
||||
39. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not
|
||||
38. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not
|
||||
found.
|
||||
|
||||
40. Non-interactive shells exit if there is a syntax error in a script
|
||||
39. 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.
|
||||
|
||||
41. Non-interactive shells exit if the ‘export’, ‘readonly’ or ‘unset’
|
||||
40. 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.
|
||||
|
||||
42. Assignment statements preceding POSIX special builtins persist in
|
||||
41. Assignment statements preceding POSIX special builtins persist in
|
||||
the shell environment after the builtin completes.
|
||||
|
||||
43. The ‘command’ builtin does not prevent builtins that take
|
||||
42. 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’.
|
||||
|
||||
44. Enabling POSIX mode has the effect of setting the
|
||||
43. 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.
|
||||
|
||||
45. Enabling POSIX mode has the effect of setting the ‘shift_verbose’
|
||||
44. 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.
|
||||
|
||||
46. Enabling POSIX mode has the effect of setting the
|
||||
45. Enabling POSIX mode has the effect of setting the
|
||||
‘interactive_comments’ option (*note Comments::).
|
||||
|
||||
47. The ‘.’ and ‘source’ builtins do not search the current directory
|
||||
46. The ‘.’ and ‘source’ builtins do not search the current directory
|
||||
for the filename argument if it is not found by searching ‘PATH’.
|
||||
|
||||
48. When the ‘alias’ builtin displays alias definitions, it does not
|
||||
47. When the ‘alias’ builtin displays alias definitions, it does not
|
||||
display them with a leading ‘alias ’ unless the ‘-p’ option is
|
||||
supplied.
|
||||
|
||||
49. The ‘bg’ builtin uses the required format to describe each job
|
||||
48. 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.
|
||||
|
||||
50. When the ‘cd’ builtin is invoked in logical mode, and the pathname
|
||||
49. 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.
|
||||
|
||||
51. When the ‘cd’ builtin cannot change a directory because the length
|
||||
50. 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.
|
||||
|
||||
52. When the ‘xpg_echo’ option is enabled, Bash does not attempt to
|
||||
51. 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.
|
||||
|
||||
53. The ‘export’ and ‘readonly’ builtin commands display their output
|
||||
52. The ‘export’ and ‘readonly’ builtin commands display their output
|
||||
in the format required by POSIX.
|
||||
|
||||
54. When listing the history, the ‘fc’ builtin does not include an
|
||||
53. When listing the history, the ‘fc’ builtin does not include an
|
||||
indication of whether or not a history entry has been modified.
|
||||
|
||||
55. The default editor used by ‘fc’ is ‘ed’.
|
||||
54. The default editor used by ‘fc’ is ‘ed’.
|
||||
|
||||
56. ‘fc’ treats extra arguments as an error instead of ignoring them.
|
||||
55. ‘fc’ treats extra arguments as an error instead of ignoring them.
|
||||
|
||||
57. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints
|
||||
56. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints
|
||||
an error message and returns failure.
|
||||
|
||||
58. The output of ‘kill -l’ prints all the signal names on a single
|
||||
57. The output of ‘kill -l’ prints all the signal names on a single
|
||||
line, separated by spaces, without the ‘SIG’ prefix.
|
||||
|
||||
59. The ‘kill’ builtin does not accept signal names with a ‘SIG’
|
||||
58. The ‘kill’ builtin does not accept signal names with a ‘SIG’
|
||||
prefix.
|
||||
|
||||
60. The ‘printf’ builtin uses ‘double’ (via ‘strtod’) to convert
|
||||
59. 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
|
||||
60. 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
|
||||
61. 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
|
||||
62. 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
|
||||
63. 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
|
||||
64. 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.
|
||||
65. 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
|
||||
66. The ‘trap’ builtin displays signal names without the leading
|
||||
‘SIG’.
|
||||
|
||||
68. The ‘trap’ builtin doesn't check the first argument for a possible
|
||||
67. 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
|
||||
68. ‘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
|
||||
69. 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’
|
||||
70. 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
|
||||
71. 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
|
||||
72. 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
|
||||
73. 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
|
||||
of such statuses after the ‘wait’ builtin is used to obtain it.
|
||||
74. Bash removes an exited background process's status from the list
|
||||
of such statuses after the ‘wait’ builtin returns it.
|
||||
|
||||
There is other POSIX behavior that Bash does not implement by default
|
||||
even when in POSIX mode. Specifically:
|
||||
|
||||
@@ -272,6 +272,13 @@ sh_nojobs (const char *s)
|
||||
else
|
||||
builtin_error (_("no job control"));
|
||||
}
|
||||
|
||||
void
|
||||
sh_invalidjob (const char *s)
|
||||
{
|
||||
builtin_error (_("%s: invalid job specification"), s);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (RESTRICTED_SHELL)
|
||||
@@ -693,6 +700,14 @@ get_job_spec (WORD_LIST *list)
|
||||
|
||||
if (*word == '%')
|
||||
word++;
|
||||
else
|
||||
#if 1
|
||||
/* This could be builtin_error or sh_invalidjob() */
|
||||
builtin_warning (_("%s: job specification requires leading `%%'"), word);
|
||||
#else
|
||||
/* TAG:bash-5.4 10/23/2024 */
|
||||
return (BAD_JOBSPEC);
|
||||
#endif
|
||||
|
||||
if (DIGIT (*word) && all_digits (word))
|
||||
{
|
||||
|
||||
@@ -103,6 +103,7 @@ extern void sh_erange (const char *, const char *);
|
||||
extern void sh_badpid (const char *);
|
||||
extern void sh_badjob (const char *);
|
||||
extern void sh_nojobs (const char *);
|
||||
extern void sh_invalidjob (const char *);
|
||||
extern void sh_restricted (const char *);
|
||||
extern void sh_notbuiltin (const char *);
|
||||
extern void sh_wrerror (void);
|
||||
|
||||
+4
-2
@@ -1,7 +1,7 @@
|
||||
This file is fg_bg.def, from which is created fg_bg.c.
|
||||
It implements the builtins "bg" and "fg" in Bash.
|
||||
|
||||
Copyright (C) 1987-2022 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -144,7 +144,9 @@ fg_bg (WORD_LIST *list, int foreground)
|
||||
|
||||
if (INVALID_JOB (job))
|
||||
{
|
||||
if (job != DUP_JOB)
|
||||
if (job == BAD_JOBSPEC)
|
||||
sh_invalidjob (list->word->word);
|
||||
else if (job != DUP_JOB)
|
||||
sh_badjob (list ? list->word->word : _("current"));
|
||||
|
||||
goto failure;
|
||||
|
||||
+5
-2
@@ -155,7 +155,7 @@ jobs_builtin (WORD_LIST *list)
|
||||
BLOCK_CHILD (set, oset);
|
||||
job = get_job_spec (list);
|
||||
|
||||
if ((job == NO_JOB) || jobs == 0 || get_job_by_jid (job) == 0)
|
||||
if ((job == NO_JOB) || jobs == 0 || INVALID_JOB (job) || get_job_by_jid (job) == 0)
|
||||
{
|
||||
sh_badjob (list->word->word);
|
||||
any_failed++;
|
||||
@@ -287,7 +287,10 @@ disown_builtin (WORD_LIST *list)
|
||||
|
||||
if (job == NO_JOB || jobs == 0 || INVALID_JOB (job))
|
||||
{
|
||||
sh_badjob (list ? list->word->word : _("current"));
|
||||
if (job == BAD_JOBSPEC)
|
||||
sh_invalidjob (list->word->word);
|
||||
else
|
||||
sh_badjob (list ? list->word->word : _("current"));
|
||||
retval = EXECUTION_FAILURE;
|
||||
}
|
||||
else if (nohup_only)
|
||||
|
||||
@@ -207,7 +207,11 @@ use_sigspec:
|
||||
#if defined (JOB_CONTROL)
|
||||
else if (*list->word->word && *list->word->word != '%')
|
||||
{
|
||||
#if 1
|
||||
sh_badpid (list->word->word);
|
||||
#else
|
||||
builtin_error (_("%s: arguments must be process or job IDs"), list->word->word);
|
||||
#endif
|
||||
CONTINUE_OR_FAIL;
|
||||
}
|
||||
else if (*word)
|
||||
|
||||
@@ -380,6 +380,8 @@ set_waitlist (WORD_LIST *list)
|
||||
}
|
||||
else if (l->word->word[0] == '%')
|
||||
sh_badjob (l->word->word);
|
||||
else if (job == BAD_JOBSPEC)
|
||||
sh_invalidjob (l->word->word);
|
||||
else
|
||||
sh_badpid (l->word->word);
|
||||
continue;
|
||||
|
||||
+4
-1
@@ -139,7 +139,6 @@
|
||||
|
||||
/* Define as 1 if you want to enable code that implements multiple coprocs
|
||||
executing simultaneously */
|
||||
/* TAG: bash-5.3 */
|
||||
#ifndef MULTIPLE_COPROCS
|
||||
# define MULTIPLE_COPROCS 1
|
||||
#endif
|
||||
@@ -206,3 +205,7 @@
|
||||
#ifndef PATSUB_REPLACE_DEFAULT
|
||||
#define PATSUB_REPLACE_DEFAULT 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you want posix mode to restrict shell function names to
|
||||
shell NAMEs. */
|
||||
/* #define POSIX_RESTRICT_FUNCNAME 0 */
|
||||
|
||||
+1799
-1781
File diff suppressed because it is too large
Load Diff
+40
-7
@@ -5,14 +5,14 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet.ramey@case.edu
|
||||
.\"
|
||||
.\" Last Change: Sun Oct 20 12:31:15 EDT 2024
|
||||
.\" Last Change: Wed Oct 23 11:32:05 EDT 2024
|
||||
.\"
|
||||
.\" bash_builtins, strip all but Built-Ins section
|
||||
.\" avoid a warning about an undefined register
|
||||
.\" .if !rzY .nr zY 0
|
||||
.if \n(zZ=1 .ig zZ
|
||||
.if \n(zY=1 .ig zY
|
||||
.TH BASH 1 "2024 October 20" "GNU Bash 5.3"
|
||||
.TH BASH 1 "2024 October 23" "GNU Bash 5.3"
|
||||
.\"
|
||||
.ie \n(.g \{\
|
||||
.ds ' \(aq
|
||||
@@ -5791,8 +5791,8 @@ sends a
|
||||
to all jobs when an interactive login shell exits.
|
||||
.PP
|
||||
If \fBbash\fP is waiting for a command to complete and receives a signal
|
||||
for which a trap has been set, the trap will not be executed until
|
||||
the command completes.
|
||||
for which a trap has been set,
|
||||
it will not execute the trap until the command completes.
|
||||
If \fBbash\fP is waiting for an asynchronous command via the \fBwait\fP
|
||||
builtin,
|
||||
and it receives a signal for which a trap has been set,
|
||||
@@ -5811,12 +5811,21 @@ same process group as the terminal, and \fB\*^C\fP sends
|
||||
.SM
|
||||
.B SIGINT
|
||||
to all processes in that process group.
|
||||
Since \fBbash\fP does not enable job control by default when the
|
||||
shell is not interactive,
|
||||
this scenario is most common in non-interactive shells.
|
||||
.PP
|
||||
When job control is enabled, and \fBbash\fP is waiting for a foreground
|
||||
command to complete, the shell does not receive keyboard-generated
|
||||
signals, because it is not in the same process group as the terminal.
|
||||
This scenario is most common in interactive shells, where \fBbash\fP
|
||||
attempts to enable job control by default.
|
||||
See
|
||||
.SM
|
||||
.B "JOB CONTROL"
|
||||
below for more information about process groups.
|
||||
.PP
|
||||
When \fBbash\fP is running without job control enabled and receives
|
||||
When job control is not enabled, and \fBbash\fP receives
|
||||
.SM
|
||||
.B SIGINT
|
||||
while waiting for a foreground command, it waits until that foreground
|
||||
@@ -5828,13 +5837,18 @@ If the command terminates due to the
|
||||
.SM
|
||||
.BR SIGINT ,
|
||||
\fBbash\fP concludes
|
||||
that the user meant to end the entire script, and acts on the
|
||||
that the user meant to send the
|
||||
.SM
|
||||
.B SIGINT
|
||||
to the shell as well, and acts on the
|
||||
.SM
|
||||
.B SIGINT
|
||||
(e.g., by running a
|
||||
.SM
|
||||
.B SIGINT
|
||||
trap or exiting itself);
|
||||
trap,
|
||||
exiting a non-interactive shell,
|
||||
or returning to the top level to read a new command).
|
||||
.IP 2.
|
||||
If the command does not terminate due to
|
||||
.SM
|
||||
@@ -5859,6 +5873,25 @@ trap set on
|
||||
as it does with any other trapped signal it
|
||||
receives while it is waiting for the foreground command to
|
||||
complete, for compatibility.
|
||||
.PP
|
||||
When job control is enabled, \fBbash\fP does not receive keyboard-generated
|
||||
signals such as
|
||||
.SM
|
||||
.B SIGINT
|
||||
while it is waiting for a foreground command.
|
||||
An interactive shell does not pay attention to the
|
||||
.SM
|
||||
.BR SIGINT ,
|
||||
even if the foreground command terminates as a result, other than noting
|
||||
its exit status.
|
||||
If the shell is not interactive, and
|
||||
the foreground command terminates due to the
|
||||
.SM
|
||||
.BR SIGINT ,
|
||||
\fBbash\fP pretends it received the
|
||||
.SM
|
||||
.B SIGINT
|
||||
itself (scenario 1 above), for compatibility.
|
||||
.SH "JOB CONTROL"
|
||||
.I Job control
|
||||
refers to the ability to selectively stop (\fIsuspend\fP)
|
||||
|
||||
+181
-169
@@ -1,9 +1,9 @@
|
||||
This is bash.info, produced by makeinfo version 7.1 from bashref.texi.
|
||||
|
||||
This text is a brief description of the features that are present in the
|
||||
Bash shell (version 5.3, 20 October 2024).
|
||||
Bash shell (version 5.3, 23 October 2024).
|
||||
|
||||
This is Edition 5.3, last updated 20 October 2024, of ‘The GNU Bash
|
||||
This is Edition 5.3, last updated 23 October 2024, of ‘The GNU Bash
|
||||
Reference Manual’, for ‘Bash’, Version 5.3.
|
||||
|
||||
Copyright © 1988-2024 Free Software Foundation, Inc.
|
||||
@@ -26,10 +26,10 @@ Bash Features
|
||||
*************
|
||||
|
||||
This text is a brief description of the features that are present in the
|
||||
Bash shell (version 5.3, 20 October 2024). The Bash home page is
|
||||
Bash shell (version 5.3, 23 October 2024). The Bash home page is
|
||||
<http://www.gnu.org/software/bash/>.
|
||||
|
||||
This is Edition 5.3, last updated 20 October 2024, of ‘The GNU Bash
|
||||
This is Edition 5.3, last updated 23 October 2024, of ‘The GNU Bash
|
||||
Reference Manual’, for ‘Bash’, Version 5.3.
|
||||
|
||||
Bash contains features that appear in other popular shells, and some
|
||||
@@ -3222,7 +3222,7 @@ Shopt Builtin::), Bash sends a ‘SIGHUP’ to all jobs when an interactive
|
||||
login shell exits.
|
||||
|
||||
If Bash is waiting for a command to complete and receives a signal
|
||||
for which a trap has been set, the trap will not be executed until the
|
||||
for which a trap has been set, it will not execute the trap until the
|
||||
command completes. If Bash is waiting for an asynchronous command via
|
||||
the ‘wait’ builtin, and it receives a signal for which a trap has been
|
||||
set, the ‘wait’ builtin will return immediately with an exit status
|
||||
@@ -3233,19 +3233,28 @@ command to complete, the shell receives keyboard-generated signals such
|
||||
as ‘SIGINT’ (usually generated by ‘^C’) that users commonly intend to
|
||||
send to that command. This happens because the shell and the command
|
||||
are in the same process group as the terminal, and ‘^C’ sends ‘SIGINT’
|
||||
to all processes in that process group. See *note Job Control::, for a
|
||||
more in-depth discussion of process groups.
|
||||
to all processes in that process group. Since Bash does not enable job
|
||||
control by default when the shell is not interactive, this scenario is
|
||||
most common in non-interactive shells.
|
||||
|
||||
When Bash is running without job control enabled and receives
|
||||
‘SIGINT’ while waiting for a foreground command, it waits until that
|
||||
foreground command terminates and then decides what to do about the
|
||||
‘SIGINT’:
|
||||
When job control is enabled, and Bash is waiting for a foreground
|
||||
command to complete, the shell does not receive keyboard-generated
|
||||
signals, because it is not in the same process group as the terminal.
|
||||
This scenario is most common in interactive shells, where Bash attempts
|
||||
to enable job control by default. See *note Job Control::, for a more
|
||||
in-depth discussion of process groups.
|
||||
|
||||
When job control is not enabled, and Bash receives ‘SIGINT’ while
|
||||
waiting for a foreground command, it waits until that foreground command
|
||||
terminates and then decides what to do about the ‘SIGINT’:
|
||||
|
||||
1. If the command terminates due to the ‘SIGINT’, Bash concludes that
|
||||
the user meant to end the entire script, and acts on the ‘SIGINT’
|
||||
(e.g., by running a ‘SIGINT’ trap or exiting itself);
|
||||
the user meant to send the ‘SIGINT’ to the shell as well, and acts
|
||||
on the ‘SIGINT’ (e.g., by running a ‘SIGINT’ trap, exiting a
|
||||
non-interactive shell, or returning to the top level to read a new
|
||||
command).
|
||||
|
||||
2. If the pipeline does not terminate due to ‘SIGINT’, the program
|
||||
2. If the command does not terminate due to ‘SIGINT’, the program
|
||||
handled the ‘SIGINT’ itself and did not treat it as a fatal signal.
|
||||
In that case, Bash does not treat ‘SIGINT’ as a fatal signal,
|
||||
either, instead assuming that the ‘SIGINT’ was used as part of the
|
||||
@@ -3255,6 +3264,14 @@ foreground command terminates and then decides what to do about the
|
||||
receives while it is waiting for the foreground command to
|
||||
complete, for compatibility.
|
||||
|
||||
When job control is enabled, Bash does not receive keyboard-generated
|
||||
signals such as ‘SIGINT’ while it is waiting for a foreground command.
|
||||
An interactive shell does not pay attention to the ‘SIGINT’, even if the
|
||||
foreground command terminates as a result, other than noting its exit
|
||||
status. If the shell is not interactive, and the foreground command
|
||||
terminates due to the ‘SIGINT’, Bash pretends it received the ‘SIGINT’
|
||||
itself (scenario 1 above), for compatibility.
|
||||
|
||||
|
||||
File: bash.info, Node: Shell Scripts, Prev: Executing Commands, Up: Basic Shell Features
|
||||
|
||||
@@ -7610,116 +7627,111 @@ startup files.
|
||||
10. Redirection operators do not perform word splitting on the word in
|
||||
a redirection.
|
||||
|
||||
11. Function names must be valid shell ‘name’s. That is, they may not
|
||||
contain characters other than letters, digits, and underscores, and
|
||||
may not start with a digit. Declaring a function with an invalid
|
||||
name in a non-interactive shell is a fatal syntax error.
|
||||
|
||||
12. Function names may not be the same as one of the POSIX special
|
||||
11. Function names may not be the same as one of the POSIX special
|
||||
builtins.
|
||||
|
||||
13. Tilde expansion is only performed on assignments preceding a
|
||||
12. Tilde expansion is only performed on assignments preceding a
|
||||
command name, rather than on all assignment statements on the line.
|
||||
|
||||
14. While variable indirection is available, it may not be applied to
|
||||
13. While variable indirection is available, it may not be applied to
|
||||
the ‘#’ and ‘?’ special parameters.
|
||||
|
||||
15. Expanding the ‘*’ special parameter in a pattern context where the
|
||||
14. Expanding the ‘*’ special parameter in a pattern context where the
|
||||
expansion is double-quoted does not treat the ‘$*’ as if it were
|
||||
double-quoted.
|
||||
|
||||
16. A double quote character (‘"’) is treated specially when it
|
||||
15. A double quote character (‘"’) is treated specially when it
|
||||
appears in a backquoted command substitution in the body of a
|
||||
here-document that undergoes expansion. That means, for example,
|
||||
that a backslash preceding a double quote character will escape it
|
||||
and the backslash will be removed.
|
||||
|
||||
17. Command substitutions don't set the ‘?’ special parameter. The
|
||||
16. Command substitutions don't set the ‘?’ special parameter. The
|
||||
exit status of a simple command without a command word is still the
|
||||
exit status of the last command substitution that occurred while
|
||||
evaluating the variable assignments and redirections in that
|
||||
command, but that does not happen until after all of the
|
||||
assignments and redirections.
|
||||
|
||||
18. Literal tildes that appear as the first character in elements of
|
||||
17. Literal tildes that appear as the first character in elements of
|
||||
the ‘PATH’ variable are not expanded as described above under *note
|
||||
Tilde Expansion::.
|
||||
|
||||
19. Command lookup finds POSIX special builtins before shell
|
||||
18. Command lookup finds POSIX special builtins before shell
|
||||
functions, including output printed by the ‘type’ and ‘command’
|
||||
builtins.
|
||||
|
||||
20. Even if a shell function whose name contains a slash was defined
|
||||
19. Even if a shell function whose name contains a slash was defined
|
||||
before entering POSIX mode, the shell will not execute a function
|
||||
whose name contains one or more slashes.
|
||||
|
||||
21. When a command in the hash table no longer exists, Bash will
|
||||
20. When a command in the hash table no longer exists, Bash will
|
||||
re-search ‘$PATH’ to find the new location. This is also available
|
||||
with ‘shopt -s checkhash’.
|
||||
|
||||
22. Bash will not insert a command without the execute bit set into
|
||||
21. Bash will not insert a command without the execute bit set into
|
||||
the command hash table, even if it returns it as a (last-ditch)
|
||||
result from a ‘$PATH’ search.
|
||||
|
||||
23. The message printed by the job control code and builtins when a
|
||||
22. 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
|
||||
23. The message printed by the job control code and builtins when a
|
||||
job is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for
|
||||
example, ‘SIGTSTP’.
|
||||
|
||||
25. If the shell is interactive, Bash does not perform job
|
||||
24. 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.
|
||||
|
||||
26. If the shell is interactive, Bash waits until the next prompt
|
||||
25. 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.
|
||||
|
||||
27. Bash permanently removes jobs from the jobs table after notifying
|
||||
26. 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.
|
||||
|
||||
28. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when
|
||||
27. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when
|
||||
the ‘v’ command is run, instead of checking ‘$VISUAL’ and
|
||||
‘$EDITOR’.
|
||||
|
||||
29. Prompt expansion enables the POSIX ‘PS1’ and ‘PS2’ expansions of
|
||||
28. 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.
|
||||
|
||||
30. The default history file is ‘~/.sh_history’ (this is the default
|
||||
29. The default history file is ‘~/.sh_history’ (this is the default
|
||||
value the shell assigns to ‘$HISTFILE’).
|
||||
|
||||
31. The ‘!’ character does not introduce history expansion within a
|
||||
30. The ‘!’ character does not introduce history expansion within a
|
||||
double-quoted string, even if the ‘histexpand’ option is enabled.
|
||||
|
||||
32. When printing shell function definitions (e.g., by ‘type’), Bash
|
||||
does not print the ‘function’ keyword.
|
||||
31. When printing shell function definitions (e.g., by ‘type’), Bash
|
||||
does not print the ‘function’ keyword unless necessary.
|
||||
|
||||
33. Non-interactive shells exit if a syntax error in an arithmetic
|
||||
32. Non-interactive shells exit if a syntax error in an arithmetic
|
||||
expansion results in an invalid expression.
|
||||
|
||||
34. Non-interactive shells exit if a parameter expansion error occurs.
|
||||
33. Non-interactive shells exit if a parameter expansion error occurs.
|
||||
|
||||
35. If a POSIX special builtin returns an error status, a
|
||||
34. 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.
|
||||
|
||||
36. A non-interactive shell exits with an error status if a variable
|
||||
35. 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.
|
||||
|
||||
37. 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 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,
|
||||
@@ -7727,155 +7739,155 @@ startup files.
|
||||
perform any further processing of the command in which the error
|
||||
occurred").
|
||||
|
||||
38. A non-interactive shell exits with an error status if the
|
||||
37. 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.
|
||||
|
||||
39. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not
|
||||
38. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not
|
||||
found.
|
||||
|
||||
40. Non-interactive shells exit if there is a syntax error in a script
|
||||
39. 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.
|
||||
|
||||
41. Non-interactive shells exit if the ‘export’, ‘readonly’ or ‘unset’
|
||||
40. 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.
|
||||
|
||||
42. Assignment statements preceding POSIX special builtins persist in
|
||||
41. Assignment statements preceding POSIX special builtins persist in
|
||||
the shell environment after the builtin completes.
|
||||
|
||||
43. The ‘command’ builtin does not prevent builtins that take
|
||||
42. 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’.
|
||||
|
||||
44. Enabling POSIX mode has the effect of setting the
|
||||
43. 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.
|
||||
|
||||
45. Enabling POSIX mode has the effect of setting the ‘shift_verbose’
|
||||
44. 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.
|
||||
|
||||
46. Enabling POSIX mode has the effect of setting the
|
||||
45. Enabling POSIX mode has the effect of setting the
|
||||
‘interactive_comments’ option (*note Comments::).
|
||||
|
||||
47. The ‘.’ and ‘source’ builtins do not search the current directory
|
||||
46. The ‘.’ and ‘source’ builtins do not search the current directory
|
||||
for the filename argument if it is not found by searching ‘PATH’.
|
||||
|
||||
48. When the ‘alias’ builtin displays alias definitions, it does not
|
||||
47. When the ‘alias’ builtin displays alias definitions, it does not
|
||||
display them with a leading ‘alias ’ unless the ‘-p’ option is
|
||||
supplied.
|
||||
|
||||
49. The ‘bg’ builtin uses the required format to describe each job
|
||||
48. 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.
|
||||
|
||||
50. When the ‘cd’ builtin is invoked in logical mode, and the pathname
|
||||
49. 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.
|
||||
|
||||
51. When the ‘cd’ builtin cannot change a directory because the length
|
||||
50. 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.
|
||||
|
||||
52. When the ‘xpg_echo’ option is enabled, Bash does not attempt to
|
||||
51. 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.
|
||||
|
||||
53. The ‘export’ and ‘readonly’ builtin commands display their output
|
||||
52. The ‘export’ and ‘readonly’ builtin commands display their output
|
||||
in the format required by POSIX.
|
||||
|
||||
54. When listing the history, the ‘fc’ builtin does not include an
|
||||
53. When listing the history, the ‘fc’ builtin does not include an
|
||||
indication of whether or not a history entry has been modified.
|
||||
|
||||
55. The default editor used by ‘fc’ is ‘ed’.
|
||||
54. The default editor used by ‘fc’ is ‘ed’.
|
||||
|
||||
56. ‘fc’ treats extra arguments as an error instead of ignoring them.
|
||||
55. ‘fc’ treats extra arguments as an error instead of ignoring them.
|
||||
|
||||
57. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints
|
||||
56. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints
|
||||
an error message and returns failure.
|
||||
|
||||
58. The output of ‘kill -l’ prints all the signal names on a single
|
||||
57. The output of ‘kill -l’ prints all the signal names on a single
|
||||
line, separated by spaces, without the ‘SIG’ prefix.
|
||||
|
||||
59. The ‘kill’ builtin does not accept signal names with a ‘SIG’
|
||||
58. The ‘kill’ builtin does not accept signal names with a ‘SIG’
|
||||
prefix.
|
||||
|
||||
60. The ‘printf’ builtin uses ‘double’ (via ‘strtod’) to convert
|
||||
59. 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
|
||||
60. 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
|
||||
61. 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
|
||||
62. 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
|
||||
63. 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
|
||||
64. 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.
|
||||
65. 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
|
||||
66. The ‘trap’ builtin displays signal names without the leading
|
||||
‘SIG’.
|
||||
|
||||
68. The ‘trap’ builtin doesn't check the first argument for a possible
|
||||
67. 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
|
||||
68. ‘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
|
||||
69. 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’
|
||||
70. 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
|
||||
71. 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
|
||||
72. 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
|
||||
73. 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
|
||||
74. Bash removes an exited background process's status from the list
|
||||
of such statuses after the ‘wait’ builtin returns it.
|
||||
|
||||
There is other POSIX behavior that Bash does not implement by default
|
||||
@@ -8768,9 +8780,9 @@ Variable Settings
|
||||
different color. The color definitions are taken from the
|
||||
value of the ‘LS_COLORS’ environment variable. If there is a
|
||||
color definition in ‘LS_COLORS’ for the custom suffix
|
||||
‘.readline-colored-completion-prefix’, Readline uses this
|
||||
color for the common prefix instead of its default. The
|
||||
default is ‘off’.
|
||||
‘readline-colored-completion-prefix’, Readline uses this color
|
||||
for the common prefix instead of its default. The default is
|
||||
‘off’.
|
||||
|
||||
‘colored-stats’
|
||||
If set to ‘on’, Readline displays possible completions using
|
||||
@@ -13489,88 +13501,88 @@ Node: Command Execution Environment133995
|
||||
Node: Environment137443
|
||||
Node: Exit Status139346
|
||||
Node: Signals141404
|
||||
Node: Shell Scripts145302
|
||||
Node: Shell Builtin Commands148600
|
||||
Node: Bourne Shell Builtins150711
|
||||
Node: Bash Builtins177261
|
||||
Node: Modifying Shell Behavior213709
|
||||
Node: The Set Builtin214051
|
||||
Node: The Shopt Builtin225987
|
||||
Node: Special Builtins243039
|
||||
Node: Shell Variables244028
|
||||
Node: Bourne Shell Variables244462
|
||||
Node: Bash Variables246970
|
||||
Node: Bash Features285279
|
||||
Node: Invoking Bash286293
|
||||
Node: Bash Startup Files292719
|
||||
Node: Interactive Shells298011
|
||||
Node: What is an Interactive Shell?298419
|
||||
Node: Is this Shell Interactive?299081
|
||||
Node: Interactive Shell Behavior299905
|
||||
Node: Bash Conditional Expressions303666
|
||||
Node: Shell Arithmetic308885
|
||||
Node: Aliases312214
|
||||
Node: Arrays315349
|
||||
Node: The Directory Stack322412
|
||||
Node: Directory Stack Builtins323209
|
||||
Node: Controlling the Prompt327654
|
||||
Node: The Restricted Shell330538
|
||||
Node: Bash POSIX Mode333420
|
||||
Node: Shell Compatibility Mode351749
|
||||
Node: Job Control360756
|
||||
Node: Job Control Basics361213
|
||||
Node: Job Control Builtins367491
|
||||
Node: Job Control Variables374173
|
||||
Node: Command Line Editing375404
|
||||
Node: Introduction and Notation377107
|
||||
Node: Readline Interaction379459
|
||||
Node: Readline Bare Essentials380647
|
||||
Node: Readline Movement Commands382455
|
||||
Node: Readline Killing Commands383451
|
||||
Node: Readline Arguments385474
|
||||
Node: Searching386531
|
||||
Node: Readline Init File388792
|
||||
Node: Readline Init File Syntax390096
|
||||
Node: Conditional Init Constructs416844
|
||||
Node: Sample Init File421229
|
||||
Node: Bindable Readline Commands424350
|
||||
Node: Commands For Moving425888
|
||||
Node: Commands For History428115
|
||||
Node: Commands For Text433368
|
||||
Node: Commands For Killing437493
|
||||
Node: Numeric Arguments440281
|
||||
Node: Commands For Completion441433
|
||||
Node: Keyboard Macros445933
|
||||
Node: Miscellaneous Commands446634
|
||||
Node: Readline vi Mode453187
|
||||
Node: Programmable Completion454164
|
||||
Node: Programmable Completion Builtins462210
|
||||
Node: A Programmable Completion Example473875
|
||||
Node: Using History Interactively479220
|
||||
Node: Bash History Facilities479901
|
||||
Node: Bash History Builtins483636
|
||||
Node: History Interaction490107
|
||||
Node: Event Designators495061
|
||||
Node: Word Designators496639
|
||||
Node: Modifiers498947
|
||||
Node: Installing Bash500888
|
||||
Node: Basic Installation502004
|
||||
Node: Compilers and Options505880
|
||||
Node: Compiling For Multiple Architectures506630
|
||||
Node: Installation Names508383
|
||||
Node: Specifying the System Type510617
|
||||
Node: Sharing Defaults511363
|
||||
Node: Operation Controls512077
|
||||
Node: Optional Features513096
|
||||
Node: Reporting Bugs525476
|
||||
Node: Major Differences From The Bourne Shell526834
|
||||
Node: GNU Free Documentation License548254
|
||||
Node: Indexes573431
|
||||
Node: Builtin Index573882
|
||||
Node: Reserved Word Index580980
|
||||
Node: Variable Index583425
|
||||
Node: Function Index600838
|
||||
Node: Concept Index614694
|
||||
Node: Shell Scripts146333
|
||||
Node: Shell Builtin Commands149631
|
||||
Node: Bourne Shell Builtins151742
|
||||
Node: Bash Builtins178292
|
||||
Node: Modifying Shell Behavior214740
|
||||
Node: The Set Builtin215082
|
||||
Node: The Shopt Builtin227018
|
||||
Node: Special Builtins244070
|
||||
Node: Shell Variables245059
|
||||
Node: Bourne Shell Variables245493
|
||||
Node: Bash Variables248001
|
||||
Node: Bash Features286310
|
||||
Node: Invoking Bash287324
|
||||
Node: Bash Startup Files293750
|
||||
Node: Interactive Shells299042
|
||||
Node: What is an Interactive Shell?299450
|
||||
Node: Is this Shell Interactive?300112
|
||||
Node: Interactive Shell Behavior300936
|
||||
Node: Bash Conditional Expressions304697
|
||||
Node: Shell Arithmetic309916
|
||||
Node: Aliases313245
|
||||
Node: Arrays316380
|
||||
Node: The Directory Stack323443
|
||||
Node: Directory Stack Builtins324240
|
||||
Node: Controlling the Prompt328685
|
||||
Node: The Restricted Shell331569
|
||||
Node: Bash POSIX Mode334451
|
||||
Node: Shell Compatibility Mode352513
|
||||
Node: Job Control361520
|
||||
Node: Job Control Basics361977
|
||||
Node: Job Control Builtins368255
|
||||
Node: Job Control Variables374937
|
||||
Node: Command Line Editing376168
|
||||
Node: Introduction and Notation377871
|
||||
Node: Readline Interaction380223
|
||||
Node: Readline Bare Essentials381411
|
||||
Node: Readline Movement Commands383219
|
||||
Node: Readline Killing Commands384215
|
||||
Node: Readline Arguments386238
|
||||
Node: Searching387295
|
||||
Node: Readline Init File389556
|
||||
Node: Readline Init File Syntax390860
|
||||
Node: Conditional Init Constructs417607
|
||||
Node: Sample Init File421992
|
||||
Node: Bindable Readline Commands425113
|
||||
Node: Commands For Moving426651
|
||||
Node: Commands For History428878
|
||||
Node: Commands For Text434131
|
||||
Node: Commands For Killing438256
|
||||
Node: Numeric Arguments441044
|
||||
Node: Commands For Completion442196
|
||||
Node: Keyboard Macros446696
|
||||
Node: Miscellaneous Commands447397
|
||||
Node: Readline vi Mode453950
|
||||
Node: Programmable Completion454927
|
||||
Node: Programmable Completion Builtins462973
|
||||
Node: A Programmable Completion Example474638
|
||||
Node: Using History Interactively479983
|
||||
Node: Bash History Facilities480664
|
||||
Node: Bash History Builtins484399
|
||||
Node: History Interaction490870
|
||||
Node: Event Designators495824
|
||||
Node: Word Designators497402
|
||||
Node: Modifiers499710
|
||||
Node: Installing Bash501651
|
||||
Node: Basic Installation502767
|
||||
Node: Compilers and Options506643
|
||||
Node: Compiling For Multiple Architectures507393
|
||||
Node: Installation Names509146
|
||||
Node: Specifying the System Type511380
|
||||
Node: Sharing Defaults512126
|
||||
Node: Operation Controls512840
|
||||
Node: Optional Features513859
|
||||
Node: Reporting Bugs526239
|
||||
Node: Major Differences From The Bourne Shell527597
|
||||
Node: GNU Free Documentation License549017
|
||||
Node: Indexes574194
|
||||
Node: Builtin Index574645
|
||||
Node: Reserved Word Index581743
|
||||
Node: Variable Index584188
|
||||
Node: Function Index601601
|
||||
Node: Concept Index615457
|
||||
|
||||
End Tag Table
|
||||
|
||||
|
||||
Binary file not shown.
+181
-169
@@ -2,9 +2,9 @@ This is bashref.info, produced by makeinfo version 7.1 from
|
||||
bashref.texi.
|
||||
|
||||
This text is a brief description of the features that are present in the
|
||||
Bash shell (version 5.3, 20 October 2024).
|
||||
Bash shell (version 5.3, 23 October 2024).
|
||||
|
||||
This is Edition 5.3, last updated 20 October 2024, of ‘The GNU Bash
|
||||
This is Edition 5.3, last updated 23 October 2024, of ‘The GNU Bash
|
||||
Reference Manual’, for ‘Bash’, Version 5.3.
|
||||
|
||||
Copyright © 1988-2024 Free Software Foundation, Inc.
|
||||
@@ -27,10 +27,10 @@ Bash Features
|
||||
*************
|
||||
|
||||
This text is a brief description of the features that are present in the
|
||||
Bash shell (version 5.3, 20 October 2024). The Bash home page is
|
||||
Bash shell (version 5.3, 23 October 2024). The Bash home page is
|
||||
<http://www.gnu.org/software/bash/>.
|
||||
|
||||
This is Edition 5.3, last updated 20 October 2024, of ‘The GNU Bash
|
||||
This is Edition 5.3, last updated 23 October 2024, of ‘The GNU Bash
|
||||
Reference Manual’, for ‘Bash’, Version 5.3.
|
||||
|
||||
Bash contains features that appear in other popular shells, and some
|
||||
@@ -3223,7 +3223,7 @@ Shopt Builtin::), Bash sends a ‘SIGHUP’ to all jobs when an interactive
|
||||
login shell exits.
|
||||
|
||||
If Bash is waiting for a command to complete and receives a signal
|
||||
for which a trap has been set, the trap will not be executed until the
|
||||
for which a trap has been set, it will not execute the trap until the
|
||||
command completes. If Bash is waiting for an asynchronous command via
|
||||
the ‘wait’ builtin, and it receives a signal for which a trap has been
|
||||
set, the ‘wait’ builtin will return immediately with an exit status
|
||||
@@ -3234,19 +3234,28 @@ command to complete, the shell receives keyboard-generated signals such
|
||||
as ‘SIGINT’ (usually generated by ‘^C’) that users commonly intend to
|
||||
send to that command. This happens because the shell and the command
|
||||
are in the same process group as the terminal, and ‘^C’ sends ‘SIGINT’
|
||||
to all processes in that process group. See *note Job Control::, for a
|
||||
more in-depth discussion of process groups.
|
||||
to all processes in that process group. Since Bash does not enable job
|
||||
control by default when the shell is not interactive, this scenario is
|
||||
most common in non-interactive shells.
|
||||
|
||||
When Bash is running without job control enabled and receives
|
||||
‘SIGINT’ while waiting for a foreground command, it waits until that
|
||||
foreground command terminates and then decides what to do about the
|
||||
‘SIGINT’:
|
||||
When job control is enabled, and Bash is waiting for a foreground
|
||||
command to complete, the shell does not receive keyboard-generated
|
||||
signals, because it is not in the same process group as the terminal.
|
||||
This scenario is most common in interactive shells, where Bash attempts
|
||||
to enable job control by default. See *note Job Control::, for a more
|
||||
in-depth discussion of process groups.
|
||||
|
||||
When job control is not enabled, and Bash receives ‘SIGINT’ while
|
||||
waiting for a foreground command, it waits until that foreground command
|
||||
terminates and then decides what to do about the ‘SIGINT’:
|
||||
|
||||
1. If the command terminates due to the ‘SIGINT’, Bash concludes that
|
||||
the user meant to end the entire script, and acts on the ‘SIGINT’
|
||||
(e.g., by running a ‘SIGINT’ trap or exiting itself);
|
||||
the user meant to send the ‘SIGINT’ to the shell as well, and acts
|
||||
on the ‘SIGINT’ (e.g., by running a ‘SIGINT’ trap, exiting a
|
||||
non-interactive shell, or returning to the top level to read a new
|
||||
command).
|
||||
|
||||
2. If the pipeline does not terminate due to ‘SIGINT’, the program
|
||||
2. If the command does not terminate due to ‘SIGINT’, the program
|
||||
handled the ‘SIGINT’ itself and did not treat it as a fatal signal.
|
||||
In that case, Bash does not treat ‘SIGINT’ as a fatal signal,
|
||||
either, instead assuming that the ‘SIGINT’ was used as part of the
|
||||
@@ -3256,6 +3265,14 @@ foreground command terminates and then decides what to do about the
|
||||
receives while it is waiting for the foreground command to
|
||||
complete, for compatibility.
|
||||
|
||||
When job control is enabled, Bash does not receive keyboard-generated
|
||||
signals such as ‘SIGINT’ while it is waiting for a foreground command.
|
||||
An interactive shell does not pay attention to the ‘SIGINT’, even if the
|
||||
foreground command terminates as a result, other than noting its exit
|
||||
status. If the shell is not interactive, and the foreground command
|
||||
terminates due to the ‘SIGINT’, Bash pretends it received the ‘SIGINT’
|
||||
itself (scenario 1 above), for compatibility.
|
||||
|
||||
|
||||
File: bashref.info, Node: Shell Scripts, Prev: Executing Commands, Up: Basic Shell Features
|
||||
|
||||
@@ -7611,116 +7628,111 @@ startup files.
|
||||
10. Redirection operators do not perform word splitting on the word in
|
||||
a redirection.
|
||||
|
||||
11. Function names must be valid shell ‘name’s. That is, they may not
|
||||
contain characters other than letters, digits, and underscores, and
|
||||
may not start with a digit. Declaring a function with an invalid
|
||||
name in a non-interactive shell is a fatal syntax error.
|
||||
|
||||
12. Function names may not be the same as one of the POSIX special
|
||||
11. Function names may not be the same as one of the POSIX special
|
||||
builtins.
|
||||
|
||||
13. Tilde expansion is only performed on assignments preceding a
|
||||
12. Tilde expansion is only performed on assignments preceding a
|
||||
command name, rather than on all assignment statements on the line.
|
||||
|
||||
14. While variable indirection is available, it may not be applied to
|
||||
13. While variable indirection is available, it may not be applied to
|
||||
the ‘#’ and ‘?’ special parameters.
|
||||
|
||||
15. Expanding the ‘*’ special parameter in a pattern context where the
|
||||
14. Expanding the ‘*’ special parameter in a pattern context where the
|
||||
expansion is double-quoted does not treat the ‘$*’ as if it were
|
||||
double-quoted.
|
||||
|
||||
16. A double quote character (‘"’) is treated specially when it
|
||||
15. A double quote character (‘"’) is treated specially when it
|
||||
appears in a backquoted command substitution in the body of a
|
||||
here-document that undergoes expansion. That means, for example,
|
||||
that a backslash preceding a double quote character will escape it
|
||||
and the backslash will be removed.
|
||||
|
||||
17. Command substitutions don't set the ‘?’ special parameter. The
|
||||
16. Command substitutions don't set the ‘?’ special parameter. The
|
||||
exit status of a simple command without a command word is still the
|
||||
exit status of the last command substitution that occurred while
|
||||
evaluating the variable assignments and redirections in that
|
||||
command, but that does not happen until after all of the
|
||||
assignments and redirections.
|
||||
|
||||
18. Literal tildes that appear as the first character in elements of
|
||||
17. Literal tildes that appear as the first character in elements of
|
||||
the ‘PATH’ variable are not expanded as described above under *note
|
||||
Tilde Expansion::.
|
||||
|
||||
19. Command lookup finds POSIX special builtins before shell
|
||||
18. Command lookup finds POSIX special builtins before shell
|
||||
functions, including output printed by the ‘type’ and ‘command’
|
||||
builtins.
|
||||
|
||||
20. Even if a shell function whose name contains a slash was defined
|
||||
19. Even if a shell function whose name contains a slash was defined
|
||||
before entering POSIX mode, the shell will not execute a function
|
||||
whose name contains one or more slashes.
|
||||
|
||||
21. When a command in the hash table no longer exists, Bash will
|
||||
20. When a command in the hash table no longer exists, Bash will
|
||||
re-search ‘$PATH’ to find the new location. This is also available
|
||||
with ‘shopt -s checkhash’.
|
||||
|
||||
22. Bash will not insert a command without the execute bit set into
|
||||
21. Bash will not insert a command without the execute bit set into
|
||||
the command hash table, even if it returns it as a (last-ditch)
|
||||
result from a ‘$PATH’ search.
|
||||
|
||||
23. The message printed by the job control code and builtins when a
|
||||
22. 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
|
||||
23. The message printed by the job control code and builtins when a
|
||||
job is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for
|
||||
example, ‘SIGTSTP’.
|
||||
|
||||
25. If the shell is interactive, Bash does not perform job
|
||||
24. 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.
|
||||
|
||||
26. If the shell is interactive, Bash waits until the next prompt
|
||||
25. 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.
|
||||
|
||||
27. Bash permanently removes jobs from the jobs table after notifying
|
||||
26. 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.
|
||||
|
||||
28. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when
|
||||
27. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when
|
||||
the ‘v’ command is run, instead of checking ‘$VISUAL’ and
|
||||
‘$EDITOR’.
|
||||
|
||||
29. Prompt expansion enables the POSIX ‘PS1’ and ‘PS2’ expansions of
|
||||
28. 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.
|
||||
|
||||
30. The default history file is ‘~/.sh_history’ (this is the default
|
||||
29. The default history file is ‘~/.sh_history’ (this is the default
|
||||
value the shell assigns to ‘$HISTFILE’).
|
||||
|
||||
31. The ‘!’ character does not introduce history expansion within a
|
||||
30. The ‘!’ character does not introduce history expansion within a
|
||||
double-quoted string, even if the ‘histexpand’ option is enabled.
|
||||
|
||||
32. When printing shell function definitions (e.g., by ‘type’), Bash
|
||||
does not print the ‘function’ keyword.
|
||||
31. When printing shell function definitions (e.g., by ‘type’), Bash
|
||||
does not print the ‘function’ keyword unless necessary.
|
||||
|
||||
33. Non-interactive shells exit if a syntax error in an arithmetic
|
||||
32. Non-interactive shells exit if a syntax error in an arithmetic
|
||||
expansion results in an invalid expression.
|
||||
|
||||
34. Non-interactive shells exit if a parameter expansion error occurs.
|
||||
33. Non-interactive shells exit if a parameter expansion error occurs.
|
||||
|
||||
35. If a POSIX special builtin returns an error status, a
|
||||
34. 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.
|
||||
|
||||
36. A non-interactive shell exits with an error status if a variable
|
||||
35. 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.
|
||||
|
||||
37. 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 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,
|
||||
@@ -7728,155 +7740,155 @@ startup files.
|
||||
perform any further processing of the command in which the error
|
||||
occurred").
|
||||
|
||||
38. A non-interactive shell exits with an error status if the
|
||||
37. 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.
|
||||
|
||||
39. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not
|
||||
38. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not
|
||||
found.
|
||||
|
||||
40. Non-interactive shells exit if there is a syntax error in a script
|
||||
39. 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.
|
||||
|
||||
41. Non-interactive shells exit if the ‘export’, ‘readonly’ or ‘unset’
|
||||
40. 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.
|
||||
|
||||
42. Assignment statements preceding POSIX special builtins persist in
|
||||
41. Assignment statements preceding POSIX special builtins persist in
|
||||
the shell environment after the builtin completes.
|
||||
|
||||
43. The ‘command’ builtin does not prevent builtins that take
|
||||
42. 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’.
|
||||
|
||||
44. Enabling POSIX mode has the effect of setting the
|
||||
43. 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.
|
||||
|
||||
45. Enabling POSIX mode has the effect of setting the ‘shift_verbose’
|
||||
44. 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.
|
||||
|
||||
46. Enabling POSIX mode has the effect of setting the
|
||||
45. Enabling POSIX mode has the effect of setting the
|
||||
‘interactive_comments’ option (*note Comments::).
|
||||
|
||||
47. The ‘.’ and ‘source’ builtins do not search the current directory
|
||||
46. The ‘.’ and ‘source’ builtins do not search the current directory
|
||||
for the filename argument if it is not found by searching ‘PATH’.
|
||||
|
||||
48. When the ‘alias’ builtin displays alias definitions, it does not
|
||||
47. When the ‘alias’ builtin displays alias definitions, it does not
|
||||
display them with a leading ‘alias ’ unless the ‘-p’ option is
|
||||
supplied.
|
||||
|
||||
49. The ‘bg’ builtin uses the required format to describe each job
|
||||
48. 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.
|
||||
|
||||
50. When the ‘cd’ builtin is invoked in logical mode, and the pathname
|
||||
49. 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.
|
||||
|
||||
51. When the ‘cd’ builtin cannot change a directory because the length
|
||||
50. 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.
|
||||
|
||||
52. When the ‘xpg_echo’ option is enabled, Bash does not attempt to
|
||||
51. 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.
|
||||
|
||||
53. The ‘export’ and ‘readonly’ builtin commands display their output
|
||||
52. The ‘export’ and ‘readonly’ builtin commands display their output
|
||||
in the format required by POSIX.
|
||||
|
||||
54. When listing the history, the ‘fc’ builtin does not include an
|
||||
53. When listing the history, the ‘fc’ builtin does not include an
|
||||
indication of whether or not a history entry has been modified.
|
||||
|
||||
55. The default editor used by ‘fc’ is ‘ed’.
|
||||
54. The default editor used by ‘fc’ is ‘ed’.
|
||||
|
||||
56. ‘fc’ treats extra arguments as an error instead of ignoring them.
|
||||
55. ‘fc’ treats extra arguments as an error instead of ignoring them.
|
||||
|
||||
57. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints
|
||||
56. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints
|
||||
an error message and returns failure.
|
||||
|
||||
58. The output of ‘kill -l’ prints all the signal names on a single
|
||||
57. The output of ‘kill -l’ prints all the signal names on a single
|
||||
line, separated by spaces, without the ‘SIG’ prefix.
|
||||
|
||||
59. The ‘kill’ builtin does not accept signal names with a ‘SIG’
|
||||
58. The ‘kill’ builtin does not accept signal names with a ‘SIG’
|
||||
prefix.
|
||||
|
||||
60. The ‘printf’ builtin uses ‘double’ (via ‘strtod’) to convert
|
||||
59. 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
|
||||
60. 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
|
||||
61. 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
|
||||
62. 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
|
||||
63. 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
|
||||
64. 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.
|
||||
65. 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
|
||||
66. The ‘trap’ builtin displays signal names without the leading
|
||||
‘SIG’.
|
||||
|
||||
68. The ‘trap’ builtin doesn't check the first argument for a possible
|
||||
67. 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
|
||||
68. ‘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
|
||||
69. 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’
|
||||
70. 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
|
||||
71. 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
|
||||
72. 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
|
||||
73. 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
|
||||
74. Bash removes an exited background process's status from the list
|
||||
of such statuses after the ‘wait’ builtin returns it.
|
||||
|
||||
There is other POSIX behavior that Bash does not implement by default
|
||||
@@ -8769,9 +8781,9 @@ Variable Settings
|
||||
different color. The color definitions are taken from the
|
||||
value of the ‘LS_COLORS’ environment variable. If there is a
|
||||
color definition in ‘LS_COLORS’ for the custom suffix
|
||||
‘.readline-colored-completion-prefix’, Readline uses this
|
||||
color for the common prefix instead of its default. The
|
||||
default is ‘off’.
|
||||
‘readline-colored-completion-prefix’, Readline uses this color
|
||||
for the common prefix instead of its default. The default is
|
||||
‘off’.
|
||||
|
||||
‘colored-stats’
|
||||
If set to ‘on’, Readline displays possible completions using
|
||||
@@ -13490,88 +13502,88 @@ Node: Command Execution Environment134136
|
||||
Node: Environment137587
|
||||
Node: Exit Status139493
|
||||
Node: Signals141554
|
||||
Node: Shell Scripts145455
|
||||
Node: Shell Builtin Commands148756
|
||||
Node: Bourne Shell Builtins150870
|
||||
Node: Bash Builtins177423
|
||||
Node: Modifying Shell Behavior213874
|
||||
Node: The Set Builtin214219
|
||||
Node: The Shopt Builtin226158
|
||||
Node: Special Builtins243213
|
||||
Node: Shell Variables244205
|
||||
Node: Bourne Shell Variables244642
|
||||
Node: Bash Variables247153
|
||||
Node: Bash Features285465
|
||||
Node: Invoking Bash286482
|
||||
Node: Bash Startup Files292911
|
||||
Node: Interactive Shells298206
|
||||
Node: What is an Interactive Shell?298617
|
||||
Node: Is this Shell Interactive?299282
|
||||
Node: Interactive Shell Behavior300109
|
||||
Node: Bash Conditional Expressions303873
|
||||
Node: Shell Arithmetic309095
|
||||
Node: Aliases312427
|
||||
Node: Arrays315565
|
||||
Node: The Directory Stack322631
|
||||
Node: Directory Stack Builtins323431
|
||||
Node: Controlling the Prompt327879
|
||||
Node: The Restricted Shell330766
|
||||
Node: Bash POSIX Mode333651
|
||||
Node: Shell Compatibility Mode351983
|
||||
Node: Job Control360993
|
||||
Node: Job Control Basics361453
|
||||
Node: Job Control Builtins367734
|
||||
Node: Job Control Variables374419
|
||||
Node: Command Line Editing375653
|
||||
Node: Introduction and Notation377359
|
||||
Node: Readline Interaction379714
|
||||
Node: Readline Bare Essentials380905
|
||||
Node: Readline Movement Commands382716
|
||||
Node: Readline Killing Commands383715
|
||||
Node: Readline Arguments385741
|
||||
Node: Searching386801
|
||||
Node: Readline Init File389065
|
||||
Node: Readline Init File Syntax390372
|
||||
Node: Conditional Init Constructs417123
|
||||
Node: Sample Init File421511
|
||||
Node: Bindable Readline Commands424635
|
||||
Node: Commands For Moving426176
|
||||
Node: Commands For History428406
|
||||
Node: Commands For Text433662
|
||||
Node: Commands For Killing437790
|
||||
Node: Numeric Arguments440581
|
||||
Node: Commands For Completion441736
|
||||
Node: Keyboard Macros446239
|
||||
Node: Miscellaneous Commands446943
|
||||
Node: Readline vi Mode453499
|
||||
Node: Programmable Completion454479
|
||||
Node: Programmable Completion Builtins462528
|
||||
Node: A Programmable Completion Example474196
|
||||
Node: Using History Interactively479544
|
||||
Node: Bash History Facilities480228
|
||||
Node: Bash History Builtins483966
|
||||
Node: History Interaction490440
|
||||
Node: Event Designators495397
|
||||
Node: Word Designators496978
|
||||
Node: Modifiers499289
|
||||
Node: Installing Bash501233
|
||||
Node: Basic Installation502352
|
||||
Node: Compilers and Options506231
|
||||
Node: Compiling For Multiple Architectures506984
|
||||
Node: Installation Names508740
|
||||
Node: Specifying the System Type510977
|
||||
Node: Sharing Defaults511726
|
||||
Node: Operation Controls512443
|
||||
Node: Optional Features513465
|
||||
Node: Reporting Bugs525848
|
||||
Node: Major Differences From The Bourne Shell527209
|
||||
Node: GNU Free Documentation License548632
|
||||
Node: Indexes573812
|
||||
Node: Builtin Index574266
|
||||
Node: Reserved Word Index581367
|
||||
Node: Variable Index583815
|
||||
Node: Function Index601231
|
||||
Node: Concept Index615090
|
||||
Node: Shell Scripts146486
|
||||
Node: Shell Builtin Commands149787
|
||||
Node: Bourne Shell Builtins151901
|
||||
Node: Bash Builtins178454
|
||||
Node: Modifying Shell Behavior214905
|
||||
Node: The Set Builtin215250
|
||||
Node: The Shopt Builtin227189
|
||||
Node: Special Builtins244244
|
||||
Node: Shell Variables245236
|
||||
Node: Bourne Shell Variables245673
|
||||
Node: Bash Variables248184
|
||||
Node: Bash Features286496
|
||||
Node: Invoking Bash287513
|
||||
Node: Bash Startup Files293942
|
||||
Node: Interactive Shells299237
|
||||
Node: What is an Interactive Shell?299648
|
||||
Node: Is this Shell Interactive?300313
|
||||
Node: Interactive Shell Behavior301140
|
||||
Node: Bash Conditional Expressions304904
|
||||
Node: Shell Arithmetic310126
|
||||
Node: Aliases313458
|
||||
Node: Arrays316596
|
||||
Node: The Directory Stack323662
|
||||
Node: Directory Stack Builtins324462
|
||||
Node: Controlling the Prompt328910
|
||||
Node: The Restricted Shell331797
|
||||
Node: Bash POSIX Mode334682
|
||||
Node: Shell Compatibility Mode352747
|
||||
Node: Job Control361757
|
||||
Node: Job Control Basics362217
|
||||
Node: Job Control Builtins368498
|
||||
Node: Job Control Variables375183
|
||||
Node: Command Line Editing376417
|
||||
Node: Introduction and Notation378123
|
||||
Node: Readline Interaction380478
|
||||
Node: Readline Bare Essentials381669
|
||||
Node: Readline Movement Commands383480
|
||||
Node: Readline Killing Commands384479
|
||||
Node: Readline Arguments386505
|
||||
Node: Searching387565
|
||||
Node: Readline Init File389829
|
||||
Node: Readline Init File Syntax391136
|
||||
Node: Conditional Init Constructs417886
|
||||
Node: Sample Init File422274
|
||||
Node: Bindable Readline Commands425398
|
||||
Node: Commands For Moving426939
|
||||
Node: Commands For History429169
|
||||
Node: Commands For Text434425
|
||||
Node: Commands For Killing438553
|
||||
Node: Numeric Arguments441344
|
||||
Node: Commands For Completion442499
|
||||
Node: Keyboard Macros447002
|
||||
Node: Miscellaneous Commands447706
|
||||
Node: Readline vi Mode454262
|
||||
Node: Programmable Completion455242
|
||||
Node: Programmable Completion Builtins463291
|
||||
Node: A Programmable Completion Example474959
|
||||
Node: Using History Interactively480307
|
||||
Node: Bash History Facilities480991
|
||||
Node: Bash History Builtins484729
|
||||
Node: History Interaction491203
|
||||
Node: Event Designators496160
|
||||
Node: Word Designators497741
|
||||
Node: Modifiers500052
|
||||
Node: Installing Bash501996
|
||||
Node: Basic Installation503115
|
||||
Node: Compilers and Options506994
|
||||
Node: Compiling For Multiple Architectures507747
|
||||
Node: Installation Names509503
|
||||
Node: Specifying the System Type511740
|
||||
Node: Sharing Defaults512489
|
||||
Node: Operation Controls513206
|
||||
Node: Optional Features514228
|
||||
Node: Reporting Bugs526611
|
||||
Node: Major Differences From The Bourne Shell527972
|
||||
Node: GNU Free Documentation License549395
|
||||
Node: Indexes574575
|
||||
Node: Builtin Index575029
|
||||
Node: Reserved Word Index582130
|
||||
Node: Variable Index584578
|
||||
Node: Function Index601994
|
||||
Node: Concept Index615853
|
||||
|
||||
End Tag Table
|
||||
|
||||
|
||||
Binary file not shown.
+31
-15
@@ -3853,8 +3853,8 @@ If the @code{huponexit} shell option has been set using @code{shopt}
|
||||
an interactive login shell exits.
|
||||
|
||||
If Bash is waiting for a command to complete and receives a signal
|
||||
for which a trap has been set, the trap will not be executed until
|
||||
the command completes.
|
||||
for which a trap has been set,
|
||||
it will not execute the trap until the command completes.
|
||||
If Bash is waiting for an asynchronous command via the @code{wait} builtin,
|
||||
and it receives a signal for which a trap has been set,
|
||||
the @code{wait} builtin will return immediately with an exit status
|
||||
@@ -3867,20 +3867,33 @@ commonly intend to send to that command.
|
||||
This happens because the shell and the command are in the same process
|
||||
group as the terminal, and @samp{^C} sends @code{SIGINT} to all processes
|
||||
in that process group.
|
||||
Since Bash does not enable job control by default when the
|
||||
shell is not interactive,
|
||||
this scenario is most common in non-interactive shells.
|
||||
|
||||
When job control is enabled, and Bash is waiting for a foreground
|
||||
command to complete, the shell does not receive keyboard-generated
|
||||
signals, because it is not in the same process group as the terminal.
|
||||
This scenario is most common in interactive shells, where Bash
|
||||
attempts to enable job control by default.
|
||||
See @ref{Job Control}, for a more in-depth discussion of process groups.
|
||||
|
||||
When Bash is running without job control enabled and receives @code{SIGINT}
|
||||
When job control is not enabled, and Bash receives @code{SIGINT}
|
||||
while waiting for a foreground command, it waits until that foreground
|
||||
command terminates and then decides what to do about the @code{SIGINT}:
|
||||
|
||||
@enumerate
|
||||
@item
|
||||
If the command terminates due to the @code{SIGINT}, Bash concludes
|
||||
that the user meant to end the entire script, and acts on the
|
||||
@code{SIGINT} (e.g., by running a @code{SIGINT} trap or exiting itself);
|
||||
that the user meant to send the @code{SIGINT} to the shell as well,
|
||||
and acts on the
|
||||
@code{SIGINT}
|
||||
(e.g., by running a @code{SIGINT} trap,
|
||||
exiting a non-interactive shell,
|
||||
or returning to the top level to read a new command).
|
||||
|
||||
@item
|
||||
If the pipeline does not terminate due to @code{SIGINT}, the program
|
||||
If the command does not terminate due to @code{SIGINT}, the program
|
||||
handled the @code{SIGINT} itself and did not treat it as a fatal signal.
|
||||
In that case, Bash does not treat @code{SIGINT} as a fatal signal,
|
||||
either, instead assuming that the @code{SIGINT} was used as part of the
|
||||
@@ -3892,6 +3905,17 @@ receives while it is waiting for the foreground command to
|
||||
complete, for compatibility.
|
||||
@end enumerate
|
||||
|
||||
When job control is enabled, Bash does not receive keyboard-generated
|
||||
signals such as @code{SIGINT}
|
||||
while it is waiting for a foreground command.
|
||||
An interactive shell does not pay attention to the @code{SIGINT},
|
||||
even if the foreground command terminates as a result, other than noting
|
||||
its exit status.
|
||||
If the shell is not interactive, and
|
||||
the foreground command terminates due to the @code{SIGINT},
|
||||
Bash pretends it received the @code{SIGINT}
|
||||
itself (scenario 1 above), for compatibility.
|
||||
|
||||
@node Shell Scripts
|
||||
@section Shell Scripts
|
||||
@cindex shell script
|
||||
@@ -8953,14 +8977,6 @@ in a redirection unless the shell is interactive.
|
||||
Redirection operators do not perform word splitting on the word in a
|
||||
redirection.
|
||||
|
||||
@item
|
||||
Function names must be valid shell @code{name}s.
|
||||
That is, they may not
|
||||
contain characters other than letters, digits, and underscores, and
|
||||
may not start with a digit.
|
||||
Declaring a function with an invalid name in a non-interactive shell
|
||||
is a fatal syntax error.
|
||||
|
||||
@item
|
||||
Function names may not be the same as one of the @sc{posix} special
|
||||
builtins.
|
||||
@@ -9068,7 +9084,7 @@ double-quoted string, even if the @code{histexpand} option is enabled.
|
||||
|
||||
@item
|
||||
When printing shell function definitions (e.g., by @code{type}), Bash does
|
||||
not print the @code{function} keyword.
|
||||
not print the @code{function} keyword unless necessary.
|
||||
|
||||
@item
|
||||
Non-interactive shells exit if a syntax error in an arithmetic expansion
|
||||
|
||||
+2
-2
@@ -2,10 +2,10 @@
|
||||
Copyright (C) 1988-2024 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set LASTCHANGE Sun Oct 20 12:30:58 EDT 2024
|
||||
@set LASTCHANGE Wed Oct 23 11:32:20 EDT 2024
|
||||
|
||||
@set EDITION 5.3
|
||||
@set VERSION 5.3
|
||||
|
||||
@set UPDATED 20 October 2024
|
||||
@set UPDATED 23 October 2024
|
||||
@set UPDATED-MONTH October 2024
|
||||
|
||||
@@ -454,3 +454,9 @@ err_readonly (const char *s)
|
||||
{
|
||||
report_error (_("%s: readonly variable"), s);
|
||||
}
|
||||
|
||||
void
|
||||
err_invalidid (const char *s)
|
||||
{
|
||||
internal_error (_("`%s': not a valid identifier"), s);
|
||||
}
|
||||
|
||||
@@ -73,6 +73,8 @@ extern void err_badarraysub (const char *);
|
||||
extern void err_unboundvar (const char *);
|
||||
extern void err_readonly (const char *);
|
||||
|
||||
extern void err_invalidid (const char *);
|
||||
|
||||
#ifdef DEBUG
|
||||
# define INTERNAL_DEBUG(x) internal_debug x
|
||||
#else
|
||||
|
||||
+16
-3
@@ -1967,7 +1967,7 @@ cpl_reap (void)
|
||||
if (p->coproc->c_flags & COPROC_DEAD)
|
||||
{
|
||||
coproc_list.ncoproc--; /* keep running count, fix up pointers later */
|
||||
#ifdef DEBUG
|
||||
#if 0
|
||||
INTERNAL_DEBUG (("cpl_reap: deleting %d", p->coproc->c_pid));
|
||||
#endif
|
||||
coproc_dispose (p->coproc);
|
||||
@@ -2496,7 +2496,7 @@ execute_coproc (COMMAND *command, int pipe_in, int pipe_out, struct fd_bitmap *f
|
||||
/* Optional check -- could be relaxed */
|
||||
if (valid_identifier (name) == 0)
|
||||
{
|
||||
internal_error (_("`%s': not a valid identifier"), name);
|
||||
err_invalidid (name);
|
||||
free (name);
|
||||
return (invert ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
|
||||
}
|
||||
@@ -6256,8 +6256,21 @@ execute_intern_function (WORD_DESC *name, FUNCTION_DEF *funcdef)
|
||||
{
|
||||
SHELL_VAR *var;
|
||||
char *t;
|
||||
int pflags;
|
||||
|
||||
if (valid_function_word (name, posixly_correct) == 0)
|
||||
/* This is where we enforce any restrictions on the function name via the
|
||||
call to valid_function_word(). */
|
||||
pflags = 0;
|
||||
#if POSIX_RESTRICT_FUNCNAME
|
||||
if (posixly_correct)
|
||||
pflags |= 1; /* enforce posix function name restrictions */
|
||||
#endif
|
||||
if (posixly_correct)
|
||||
pflags |= 4; /* no special builtins */
|
||||
|
||||
/* We still allow functions with the same name as reserved words, so they
|
||||
can be called if quoted. */
|
||||
if (valid_function_word (name, pflags) == 0)
|
||||
{
|
||||
if (posixly_correct)
|
||||
{
|
||||
|
||||
@@ -357,12 +357,12 @@ check_identifier (WORD_DESC *word, int check_word)
|
||||
{
|
||||
if (word->flags & (W_HASDOLLAR|W_QUOTED)) /* XXX - HASDOLLAR? */
|
||||
{
|
||||
internal_error (_("`%s': not a valid identifier"), word->word);
|
||||
err_invalidid (word->word);
|
||||
return (0);
|
||||
}
|
||||
else if (check_word && (all_digits (word->word) || valid_identifier (word->word) == 0))
|
||||
{
|
||||
internal_error (_("`%s': not a valid identifier"), word->word);
|
||||
err_invalidid (word->word);
|
||||
return (0);
|
||||
}
|
||||
else
|
||||
@@ -431,10 +431,15 @@ valid_function_name (const char *name, int flags)
|
||||
/* Return 1 if this is an identifier that can be used as a function name
|
||||
when declaring a function. We don't allow `$' for historical reasons.
|
||||
We allow quotes (for now), slashes, and pretty much everything else.
|
||||
If FLAGS is non-zero (it's usually posixly_correct), we check the name
|
||||
for additional posix restrictions using valid_function_name(). We pass
|
||||
flags|2 to valid_function_name to suppress the check for an assignment
|
||||
word, since we want to allow those here. */
|
||||
If (FLAGS&4) is non-zero, we check that the name is not one of the POSIX
|
||||
special builtins (this is the shell enforcing a POSIX application
|
||||
requirement). We allow reserved words, even though it's unlikely anyone
|
||||
would use them.
|
||||
If (FLAGS&1) is non-zero (it's usually set by the caller from
|
||||
posixly_correct), we check the name for additional posix restrictions
|
||||
using valid_function_name().
|
||||
We pass flags|2 to valid_function_name to suppress the check for an
|
||||
assignment word, since we want to allow those here. */
|
||||
int
|
||||
valid_function_word (WORD_DESC *word, int flags)
|
||||
{
|
||||
@@ -443,18 +448,20 @@ valid_function_word (WORD_DESC *word, int flags)
|
||||
name = word->word;
|
||||
if ((word->flags & W_HASDOLLAR)) /* allow quotes for now */
|
||||
{
|
||||
internal_error (_("`%s': not a valid identifier"), name);
|
||||
err_invalidid (name);
|
||||
return (0);
|
||||
}
|
||||
/* POSIX interpretation 383 */
|
||||
if (flags && find_special_builtin (name))
|
||||
/* POSIX interpretation 383 -- this is an application requirement, but the
|
||||
shell should enforce it rather than allow a script to define a function
|
||||
that will never be called. */
|
||||
if ((flags & 4) && find_special_builtin (name))
|
||||
{
|
||||
internal_error (_("`%s': is a special builtin"), name);
|
||||
return (0);
|
||||
}
|
||||
if (flags && valid_function_name (name, flags|2) == 0)
|
||||
if ((flags & 1) && valid_function_name (name, flags|2) == 0)
|
||||
{
|
||||
internal_error (_("`%s': not a valid identifier"), name);
|
||||
err_invalidid (name);
|
||||
return (0);
|
||||
}
|
||||
return 1;
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
static bool is_colored (enum indicator_no type);
|
||||
static void restore_default_color (void);
|
||||
|
||||
#define RL_COLOR_PREFIX_EXTENSION ".readline-colored-completion-prefix"
|
||||
#define RL_COLOR_PREFIX_EXTENSION "readline-colored-completion-prefix"
|
||||
|
||||
COLOR_EXT_TYPE *_rl_color_ext_list = 0;
|
||||
|
||||
|
||||
@@ -478,7 +478,7 @@ common prefix of the set of possible completions using a different color.
|
||||
The color definitions are taken from the value of the \fBLS_COLORS\fP
|
||||
environment variable.
|
||||
If there is a color definition in \fB$LS_COLORS\fP for the custom suffix
|
||||
.Q .readline-colored-completion-prefix ,
|
||||
.Q readline-colored-completion-prefix ,
|
||||
\fBreadline\fP uses this color for
|
||||
the common prefix instead of its default.
|
||||
.TP
|
||||
|
||||
@@ -508,7 +508,7 @@ common prefix of the set of possible completions using a different color.
|
||||
The color definitions are taken from the value of the @env{LS_COLORS}
|
||||
environment variable.
|
||||
If there is a color definition in @env{LS_COLORS} for the custom suffix
|
||||
@samp{.readline-colored-completion-prefix}, Readline uses this color for
|
||||
@samp{readline-colored-completion-prefix}, Readline uses this color for
|
||||
the common prefix instead of its default.
|
||||
The default is @samp{off}.
|
||||
|
||||
|
||||
@@ -742,10 +742,11 @@ opcode_dispatch:
|
||||
/* Add character to search string and continue search. */
|
||||
default:
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
wlen = (cxt->mb[0] == 0 || cxt->mb[1] == 0) ? 1 : RL_STRLEN (cxt->mb);
|
||||
#else
|
||||
wlen = 1;
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
wlen = (cxt->mb[0] == 0 || cxt->mb[1] == 0) ? 1 : RL_STRLEN (cxt->mb);
|
||||
else
|
||||
#endif
|
||||
wlen = 1;
|
||||
if (cxt->search_string_index + wlen + 1 >= cxt->search_string_size)
|
||||
{
|
||||
cxt->search_string_size += 128; /* 128 much greater than MB_CUR_MAX */
|
||||
|
||||
@@ -343,8 +343,8 @@ static int two_tokens_ago;
|
||||
|
||||
/* Someday compoundcmd_lineno will be an array of these structs. */
|
||||
struct tokeninfo {
|
||||
int tok;
|
||||
int lineno;
|
||||
int tok;
|
||||
};
|
||||
|
||||
/* The line number in a script where a compound command begins. The
|
||||
@@ -6790,6 +6790,9 @@ report_syntax_error (const char *message)
|
||||
free (msg);
|
||||
msg = p;
|
||||
}
|
||||
if (shell_eof_token && current_token != shell_eof_token)
|
||||
parser_error (line_number, _("syntax error near unexpected token `%s' while looking for matching `%c'"), msg, shell_eof_token);
|
||||
else
|
||||
parser_error (line_number, _("syntax error near unexpected token `%s'"), msg);
|
||||
free (msg);
|
||||
|
||||
|
||||
+24
-3
@@ -1325,16 +1325,27 @@ print_function_def (FUNCTION_DEF *func)
|
||||
COMMAND *cmdcopy;
|
||||
REDIRECT *func_redirects;
|
||||
WORD_DESC *w;
|
||||
int pflags;
|
||||
|
||||
pflags = 0;
|
||||
if (posixly_correct)
|
||||
{
|
||||
pflags |= 4; /* no reserved words */
|
||||
#if POSIX_RESTRICT_FUNCNAME
|
||||
pflags |= 1; /* function names must be valid identifiers */
|
||||
#endif
|
||||
}
|
||||
|
||||
w = pretty_print_mode ? dequote_word (func->name) : func->name;
|
||||
/* we're just pretty-printing, so this can be destructive */
|
||||
|
||||
func_redirects = NULL;
|
||||
/* When in posix mode, print functions as posix specifies them, but prefix
|
||||
`function' to words that are not valid POSIX identifiers. */
|
||||
`function' to names that are not valid posix function names, as
|
||||
determined by valid_function_name(). */
|
||||
if (posixly_correct == 0)
|
||||
cprintf ("function %s () \n", w->word);
|
||||
else if (valid_function_name (w->word, posixly_correct) == 0)
|
||||
else if (valid_function_name (w->word, pflags) == 0)
|
||||
cprintf ("function %s () \n", w->word);
|
||||
else
|
||||
cprintf ("%s () \n", w->word);
|
||||
@@ -1392,6 +1403,16 @@ named_function_string (char *name, COMMAND *command, int flags)
|
||||
int old_indent, old_amount;
|
||||
COMMAND *cmdcopy;
|
||||
REDIRECT *func_redirects;
|
||||
int pflags;
|
||||
|
||||
pflags = 0;
|
||||
if (posixly_correct)
|
||||
{
|
||||
pflags |= 4; /* no reserved words */
|
||||
#if POSIX_RESTRICT_FUNCNAME
|
||||
pflags |= 1; /* function names must be valid identifiers */
|
||||
#endif
|
||||
}
|
||||
|
||||
old_indent = indentation;
|
||||
old_amount = indentation_amount;
|
||||
@@ -1401,7 +1422,7 @@ named_function_string (char *name, COMMAND *command, int flags)
|
||||
|
||||
if (name && *name)
|
||||
{
|
||||
if (valid_function_name (name, posixly_correct) == 0)
|
||||
if (valid_function_name (name, pflags) == 0)
|
||||
cprintf ("function ");
|
||||
cprintf ("%s ", name);
|
||||
}
|
||||
|
||||
@@ -76,22 +76,22 @@ swap32_posix ()
|
||||
));
|
||||
done
|
||||
}
|
||||
bash: -c: line 1: syntax error near unexpected token `done'
|
||||
bash: -c: line 1: syntax error near unexpected token `done' while looking for matching `)'
|
||||
bash: -c: line 1: `: $(case x in x) ;; x) done esac)'
|
||||
bash: -c: line 1: syntax error near unexpected token `done'
|
||||
bash: -c: line 1: syntax error near unexpected token `done' while looking for matching `)'
|
||||
bash: -c: line 1: `: $(case x in x) ;; x) done ;; esac)'
|
||||
bash: -c: line 1: syntax error near unexpected token `esac'
|
||||
bash: -c: line 1: syntax error near unexpected token `esac' while looking for matching `)'
|
||||
bash: -c: line 1: `: $(case x in x) (esac) esac)'
|
||||
bash: -c: line 1: syntax error near unexpected token `in'
|
||||
bash: -c: line 1: syntax error near unexpected token `in' while looking for matching `)'
|
||||
bash: -c: line 1: `: $(case x in esac|in) foo;; esac)'
|
||||
bash: -c: line 1: syntax error near unexpected token `done'
|
||||
bash: -c: line 1: syntax error near unexpected token `done' while looking for matching `)'
|
||||
bash: -c: line 1: `: $(case x in x) ;; x) done)'
|
||||
case: -c: line 3: syntax error near unexpected token `esac'
|
||||
case: -c: line 3: syntax error near unexpected token `esac' while looking for matching `)'
|
||||
case: -c: line 3: `$( esac ; bar=foo ; echo "$bar")) echo bad 2;;'
|
||||
ok 2
|
||||
inside outside
|
||||
ok 3
|
||||
syntax-error: -c: line 2: syntax error near unexpected token `done'
|
||||
syntax-error: -c: line 2: syntax error near unexpected token `done' while looking for matching `)'
|
||||
syntax-error: -c: line 2: `: $(case x in x) ;; x) done ;; esac)'
|
||||
yes
|
||||
|
||||
|
||||
+3
-3
@@ -68,7 +68,7 @@ umask: usage: umask [-p] [-S] [mode]
|
||||
./errors.tests: line 214: VAR: readonly variable
|
||||
comsub: -c: line 1: syntax error near unexpected token `)'
|
||||
comsub: -c: line 1: `: $( for z in 1 2 3; do )'
|
||||
comsub: -c: line 1: syntax error near unexpected token `done'
|
||||
comsub: -c: line 1: syntax error near unexpected token `done' while looking for matching `)'
|
||||
comsub: -c: line 1: `: $( for z in 1 2 3; done )'
|
||||
./errors.tests: line 221: cd: HOME not set
|
||||
./errors.tests: line 222: cd: /tmp/xyz.bash: No such file or directory
|
||||
@@ -130,7 +130,7 @@ kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill
|
||||
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
|
||||
./errors.tests: line 332: kill: SIGBAD: invalid signal specification
|
||||
./errors.tests: line 334: kill: BAD: invalid signal specification
|
||||
./errors.tests: line 336: kill: @12: arguments must be process or job IDs
|
||||
./errors.tests: line 336: kill: `@12': not a pid or valid job spec
|
||||
./errors.tests: line 339: unset: BASH_LINENO: cannot unset
|
||||
./errors.tests: line 339: unset: BASH_SOURCE: cannot unset
|
||||
./errors.tests: line 342: set: trackall: invalid option name
|
||||
@@ -343,4 +343,4 @@ sh: line 1: unset: `a-b': not a valid identifier
|
||||
sh: line 1: /nosuchfile: No such file or directory
|
||||
sh: line 1: trap: SIGNOSIG: invalid signal specification
|
||||
after trap
|
||||
./errors.tests: line 396: `!!': not a valid identifier
|
||||
end
|
||||
|
||||
+2
-4
@@ -388,10 +388,8 @@ ${THIS_SH} -o posix -c '. /nosuchfile ; echo after source' sh
|
||||
# but trap specifying a bad signal nunber is non-fatal
|
||||
${THIS_SH} -o posix -c 'trap "echo bad" SIGNOSIG; echo after trap' sh
|
||||
|
||||
# this must be last!
|
||||
# in posix mode, a function name must be a valid identifier
|
||||
# this can't go in posix2.tests, since it causes the shell to exit
|
||||
# immediately
|
||||
# in posix mode, this is no longer a fatal error
|
||||
# a function name does not have to be a valid identifier
|
||||
set -o posix
|
||||
function !! () { fc -s "$@" ; }
|
||||
set +o posix
|
||||
|
||||
+2
-3
@@ -175,7 +175,7 @@ function a=2 ()
|
||||
{
|
||||
printf "FUNCNAME: %s\n" $FUNCNAME
|
||||
}
|
||||
function 11111 ()
|
||||
11111 ()
|
||||
{
|
||||
printf "FUNCNAME: %s\n" $FUNCNAME
|
||||
}
|
||||
@@ -242,14 +242,13 @@ break ()
|
||||
execution
|
||||
inside function break
|
||||
./func5.sub: line 86: `break': is a special builtin
|
||||
./func5.sub: line 92: `!!': not a valid identifier
|
||||
!! is a function
|
||||
!! ()
|
||||
{
|
||||
fc -s "$@"
|
||||
}
|
||||
!! is a function
|
||||
function !! ()
|
||||
!! ()
|
||||
{
|
||||
fc -s "$@"
|
||||
}
|
||||
|
||||
+4
-4
@@ -85,15 +85,15 @@ break()
|
||||
echo after
|
||||
)
|
||||
|
||||
# in posix mode, functions whose names are invalid identifiers are fatal errors
|
||||
# in posix mode, functions whose names are invalid identifiers are
|
||||
# no longer fatal errors
|
||||
( set -o posix
|
||||
!! () { fc -s "$@" ; }
|
||||
type \!\!
|
||||
)
|
||||
|
||||
# but you can create such functions and print them in posix mode
|
||||
# you can create such functions and print them in posix mode
|
||||
set -o posix
|
||||
!! () { fc -s "$@" ; }
|
||||
type '!!'
|
||||
set -o posix
|
||||
type '!!'
|
||||
set +o posix
|
||||
|
||||
@@ -79,6 +79,7 @@ bg: usage: bg [job_spec ...]
|
||||
disown: usage: disown [-h] [-ar] [jobspec ... | pid ...]
|
||||
./jobs.tests: line 141: disown: %1: no such job
|
||||
./jobs.tests: line 144: disown: %2: no such job
|
||||
./jobs.tests: line 147: disown: warning: @12: job specification requires leading `%'
|
||||
./jobs.tests: line 147: disown: @12: no such job
|
||||
wait-for-non-child
|
||||
./jobs.tests: line 150: wait: pid 1 is not a child of this shell
|
||||
|
||||
Reference in New Issue
Block a user