mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-11 22:20:49 +02:00
changes to function printing; new trap -P option; posix mode changes for command builtin as a declaration utility; changes for compiling without multibyte code
This commit is contained in:
@@ -5129,3 +5129,57 @@ trap.c
|
||||
subst.c
|
||||
- do_assignment_internal: don't allocate new memory for NAME, just
|
||||
modify and restore it in place
|
||||
|
||||
1/25
|
||||
----
|
||||
lib/readline/histfile.c
|
||||
- history_write_slow: a fallback function that uses stdio to write the
|
||||
history list to a supplied file descriptor
|
||||
- history_do_write: call history_write_slow if ftrucate/mmap/malloc
|
||||
fail; hope the simpler approach works
|
||||
|
||||
1/27
|
||||
----
|
||||
general.[ch]
|
||||
- valid_function_name: new function, returns non-zero if the name
|
||||
can be used as a function name without the `function' prefix
|
||||
|
||||
print_cmd.c
|
||||
- named_function_string,print_function_def: use valid_function_name so
|
||||
the rules about when to use the `function' reserved word are
|
||||
consistent
|
||||
|
||||
builtins/trap.def
|
||||
- new option -P, which prints only the action associated with each
|
||||
signal spec argument
|
||||
|
||||
doc/{bash.1,bashref.texi}
|
||||
- trap: document new -P option, add note that trap -p or trap -P in a
|
||||
subshell can print the parent's traps
|
||||
|
||||
1/28
|
||||
----
|
||||
parse.y
|
||||
- shell_getc: make sure references to shell_input_line_property are
|
||||
protected by #ifdef HANDLE_MULTIBYTE. From
|
||||
https://savannah.gnu.org/patch/?10309
|
||||
|
||||
print_cmd.c
|
||||
- named_function_string,print_function_def: don't copy the function
|
||||
COMMAND * before printing it as text; unwind-protect any redirects
|
||||
attached to the function body
|
||||
|
||||
parse.y
|
||||
- PST_CMDBLTIN: new parser state, means the previous token word was
|
||||
`command' in a command position
|
||||
- read_token_word: in posix mode, "command" followed by a declaration
|
||||
utility preserves the declaration utility status of the following
|
||||
word, so we mark that state and then check a word for being an
|
||||
assignment builtin if in that state on the next call. This makes
|
||||
compound assignments to builtins that accept them (e.g., `declare')
|
||||
work as if `command' were not present. This is a POSIX issue 8
|
||||
requirement
|
||||
- read_token: turn off PST_CMDBLTIN state as appropriate
|
||||
|
||||
subst.c
|
||||
- use locale_mb_cur_max instead of MB_CUR_MAX consistently
|
||||
|
||||
@@ -229,6 +229,11 @@ static floatmax_t getfloatmax (void);
|
||||
|
||||
static intmax_t asciicode (void);
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
static wchar_t *getwidestr (size_t *);
|
||||
static wint_t getwidechar (void);
|
||||
#endif
|
||||
|
||||
static WORD_LIST *garglist, *orig_arglist;
|
||||
static int retval;
|
||||
static int conversion_error;
|
||||
@@ -1336,3 +1341,50 @@ asciicode (void)
|
||||
garglist = garglist->next;
|
||||
return (ch);
|
||||
}
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
static wchar_t *
|
||||
getwidestr (size_t *lenp)
|
||||
{
|
||||
wchar_t *ws;
|
||||
const char *mbs;
|
||||
size_t slen, mblength;
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
mbs = garglist->word->word;
|
||||
slen = strlen (mbs);
|
||||
ws = (wchar_t *)xmalloc ((slen + 1) * sizeof (wchar_t));
|
||||
mblength = mbsrtowcs (ws, &mbs, slen, &state);
|
||||
if (lenp)
|
||||
*lenp = mblength;
|
||||
|
||||
if (MB_INVALIDCH (mblength))
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < slen; i++)
|
||||
ws[i] = (wchar_t)garglist->word->word[i];
|
||||
ws[slen] = L'\0';
|
||||
if (lenp)
|
||||
*lenp = slen;
|
||||
}
|
||||
|
||||
garglist = garglist->next;
|
||||
return (ws);
|
||||
}
|
||||
|
||||
static wint_t
|
||||
getwidechar (void)
|
||||
{
|
||||
wchar_t wc;
|
||||
size_t slen, mblength;
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
wc = 0;
|
||||
mblength = mbrtowc (&wc, garglist->word->word, locale_mb_cur_max, &state);
|
||||
if (MB_INVALIDCH (mblength))
|
||||
wc = (wchar_t)garglist->word->word[0];
|
||||
|
||||
garglist = garglist->next;
|
||||
return (wc);
|
||||
}
|
||||
#endif
|
||||
|
||||
+53
-12
@@ -1,7 +1,7 @@
|
||||
This file is trap.def, from which is created trap.c.
|
||||
It implements the builtin "trap" in Bash.
|
||||
|
||||
Copyright (C) 1987-2022 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2023 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -22,7 +22,7 @@ $PRODUCES trap.c
|
||||
|
||||
$BUILTIN trap
|
||||
$FUNCTION trap_builtin
|
||||
$SHORT_DOC trap [-lp] [[action] signal_spec ...]
|
||||
$SHORT_DOC trap [-Plp] [[action] signal_spec ...]
|
||||
Trap signals and other events.
|
||||
|
||||
Defines and activates handlers to be run when the shell receives signals
|
||||
@@ -51,6 +51,9 @@ Options:
|
||||
-p display the trap commands associated with each SIGNAL_SPEC in a
|
||||
form that may be reused as shell input; or for all trapped
|
||||
signals if no arguments are supplied
|
||||
-P display the trap commands associated with each SIGNAL_SPEC. At least
|
||||
one SIGNAL_SPEC must be supplied. -P and -p cannot be used
|
||||
together.
|
||||
|
||||
Each SIGNAL_SPEC is either a signal name in <signal.h> or a signal number.
|
||||
Signal names are case insensitive and the SIG prefix is optional. A
|
||||
@@ -101,16 +104,21 @@ static int display_traps (WORD_LIST *, int);
|
||||
#define REVERT 1 /* Revert to this signals original value. */
|
||||
#define IGNORE 2 /* Ignore this signal. */
|
||||
|
||||
/* Flags saying how to display the trap list. */
|
||||
#define DISP_TRAPCMD 1
|
||||
#define DISP_ALLSIGS 2
|
||||
#define DISP_ACTIONONLY 4
|
||||
|
||||
int
|
||||
trap_builtin (WORD_LIST *list)
|
||||
{
|
||||
int list_signal_names, display, result, opt;
|
||||
int list_signal_names, result, opt, dflags;
|
||||
|
||||
list_signal_names = display = 0;
|
||||
list_signal_names = dflags = 0;
|
||||
result = EXECUTION_SUCCESS;
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "lp")) != -1)
|
||||
while ((opt = internal_getopt (list, "lpP")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
@@ -118,7 +126,10 @@ trap_builtin (WORD_LIST *list)
|
||||
list_signal_names++;
|
||||
break;
|
||||
case 'p':
|
||||
display++;
|
||||
dflags |= DISP_TRAPCMD;
|
||||
break;
|
||||
case 'P':
|
||||
dflags |= DISP_ACTIONONLY;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
@@ -130,13 +141,26 @@ trap_builtin (WORD_LIST *list)
|
||||
|
||||
opt = DSIG_NOCASE|DSIG_SIGPREFIX; /* flags for decode_signal */
|
||||
|
||||
if ((dflags & DISP_TRAPCMD) && (dflags & DISP_ACTIONONLY))
|
||||
{
|
||||
builtin_error ("cannot specify both -p and -P");
|
||||
return EX_USAGE;
|
||||
}
|
||||
if ((dflags & DISP_ACTIONONLY) && list == 0)
|
||||
{
|
||||
builtin_error ("-P requires at least one signal name");
|
||||
return EX_USAGE;
|
||||
}
|
||||
|
||||
if (list_signal_names)
|
||||
return (sh_chkwrite (display_signal_list ((WORD_LIST *)NULL, 1)));
|
||||
else if (display || list == 0)
|
||||
else if (dflags || list == 0)
|
||||
{
|
||||
initialize_terminating_signals ();
|
||||
get_all_original_signals ();
|
||||
return (sh_chkwrite (display_traps (list, display && posixly_correct)));
|
||||
if (dflags & DISP_TRAPCMD)
|
||||
dflags |= posixly_correct ? DISP_ALLSIGS : 0;
|
||||
return (sh_chkwrite (display_traps (list, dflags)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -294,11 +318,18 @@ showtrap (int i, int show_default)
|
||||
FREE (t);
|
||||
}
|
||||
|
||||
static int
|
||||
display_traps (WORD_LIST *list, int show_all)
|
||||
{
|
||||
int result, i;
|
||||
/* Flags saying how to display the trap list. */
|
||||
#define DISP_TRAPCMD 1
|
||||
#define DISP_ALLSIGS 2
|
||||
#define DISP_ACTIONONLY 4
|
||||
|
||||
|
||||
static int
|
||||
display_traps (WORD_LIST *list, int flags)
|
||||
{
|
||||
int result, i, show_all;
|
||||
|
||||
show_all = flags & DISP_ALLSIGS;
|
||||
if (list == 0)
|
||||
{
|
||||
for (i = 0; i < BASH_NSIG; i++)
|
||||
@@ -314,6 +345,16 @@ display_traps (WORD_LIST *list, int show_all)
|
||||
sh_invalidsig (list->word->word);
|
||||
result = EXECUTION_FAILURE;
|
||||
}
|
||||
else if (flags & DISP_ACTIONONLY)
|
||||
{
|
||||
char *t;
|
||||
t = trap_list[i];
|
||||
if (t == (char *)DEFAULT_SIG || signal_is_hard_ignored (i))
|
||||
continue;
|
||||
else if (t == (char *)IGNORE_SIG)
|
||||
t = "";
|
||||
printf ("%s\n", t);
|
||||
}
|
||||
else
|
||||
showtrap (i, show_all);
|
||||
}
|
||||
|
||||
+405
-398
File diff suppressed because it is too large
Load Diff
+16
-6
@@ -5,12 +5,12 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet.ramey@case.edu
|
||||
.\"
|
||||
.\" Last Change: Tue Dec 27 16:11:59 EST 2022
|
||||
.\" Last Change: Fri Jan 27 15:18:01 EST 2023
|
||||
.\"
|
||||
.\" bash_builtins, strip all but Built-Ins section
|
||||
.if \n(zZ=1 .ig zZ
|
||||
.if \n(zY=1 .ig zY
|
||||
.TH BASH 1 "2022 December 27" "GNU Bash 5.2"
|
||||
.TH BASH 1 "2023 January 27" "GNU Bash 5.2"
|
||||
.\"
|
||||
.\" There's some problem with having a `@'
|
||||
.\" in a tagged paragraph with the BSD man macros.
|
||||
@@ -50,8 +50,8 @@ bash \- GNU Bourne-Again SHell
|
||||
[options]
|
||||
[command_string | file]
|
||||
.SH COPYRIGHT
|
||||
.if n Bash is Copyright (C) 1989-2022 by the Free Software Foundation, Inc.
|
||||
.if t Bash is Copyright \(co 1989-2022 by the Free Software Foundation, Inc.
|
||||
.if n Bash is Copyright (C) 1989-2023 by the Free Software Foundation, Inc.
|
||||
.if t Bash is Copyright \(co 1989-2023 by the Free Software Foundation, Inc.
|
||||
.SH DESCRIPTION
|
||||
.B Bash
|
||||
is an \fBsh\fR-compatible command language interpreter that
|
||||
@@ -4953,8 +4953,8 @@ the exit status of the last command substitution performed. If there
|
||||
were no command substitutions, the command exits with a status of zero.
|
||||
.SH "COMMAND EXECUTION"
|
||||
After a command has been split into words, if it results in a
|
||||
simple command and an optional list of arguments, the following
|
||||
actions are taken.
|
||||
simple command and an optional list of arguments, the shell performs
|
||||
the following actions.
|
||||
.PP
|
||||
If the command name contains no slashes, the shell attempts to
|
||||
locate it. If there exists a shell function by that name, that
|
||||
@@ -10902,6 +10902,16 @@ or, if none are supplied, for all trapped signals,
|
||||
as a set of \fBtrap\fP commands
|
||||
that can be reused as shell input to
|
||||
restore the current signal dispositions.
|
||||
The
|
||||
.B \-P
|
||||
option behaves similarly, but displays only the actions
|
||||
associated with each \fIsigspec\fP argument.
|
||||
.B \-P
|
||||
requires at least one \fIsigspec\fP argument.
|
||||
The \fB\-P\fP or \fB\-p\fP options to \fBtrap\fP may be used
|
||||
in a subshell environment (e.g., command substitution) and, as
|
||||
long as they are used before \fBtrap\fP is used to change a signal's
|
||||
handling, will display the state of its parent's traps.
|
||||
.if t .sp 0.5
|
||||
.if n .sp 1
|
||||
The
|
||||
|
||||
+152
-146
@@ -2,12 +2,12 @@ This is bashref.info, produced by makeinfo version 6.8 from
|
||||
bashref.texi.
|
||||
|
||||
This text is a brief description of the features that are present in the
|
||||
Bash shell (version 5.2, 27 December 2022).
|
||||
Bash shell (version 5.2, 27 January 2023).
|
||||
|
||||
This is Edition 5.2, last updated 27 December 2022, of 'The GNU Bash
|
||||
This is Edition 5.2, last updated 27 January 2023, of 'The GNU Bash
|
||||
Reference Manual', for 'Bash', Version 5.2.
|
||||
|
||||
Copyright (C) 1988-2022 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-2023 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this
|
||||
document under the terms of the GNU Free Documentation License,
|
||||
@@ -27,10 +27,10 @@ Bash Features
|
||||
*************
|
||||
|
||||
This text is a brief description of the features that are present in the
|
||||
Bash shell (version 5.2, 27 December 2022). The Bash home page is
|
||||
Bash shell (version 5.2, 27 January 2023). The Bash home page is
|
||||
<http://www.gnu.org/software/bash/>.
|
||||
|
||||
This is Edition 5.2, last updated 27 December 2022, of 'The GNU Bash
|
||||
This is Edition 5.2, last updated 27 January 2023, of 'The GNU Bash
|
||||
Reference Manual', for 'Bash', Version 5.2.
|
||||
|
||||
Bash contains features that appear in other popular shells, and some
|
||||
@@ -2833,8 +2833,8 @@ File: bashref.info, Node: Command Search and Execution, Next: Command Executio
|
||||
----------------------------------
|
||||
|
||||
After a command has been split into words, if it results in a simple
|
||||
command and an optional list of arguments, the following actions are
|
||||
taken.
|
||||
command and an optional list of arguments, the shell performs the
|
||||
following actions.
|
||||
|
||||
1. If the command name contains no slashes, the shell attempts to
|
||||
locate it. If there exists a shell function by that name, that
|
||||
@@ -3565,7 +3565,7 @@ standard.
|
||||
children. The return status is zero.
|
||||
|
||||
'trap'
|
||||
trap [-lp] [ACTION] [SIGSPEC ...]
|
||||
trap [-Plp] [ACTION] [SIGSPEC ...]
|
||||
|
||||
The ACTION is a command that is read and executed when the shell
|
||||
receives signal SIGSPEC. If ACTION is absent (and there is a
|
||||
@@ -3581,7 +3581,13 @@ standard.
|
||||
displays the trap commands associated with each SIGSPEC, or, if no
|
||||
SIGSPECs are supplied, for all trapped signals, as a set of 'trap'
|
||||
commands that can be reused as shell input to restore the current
|
||||
signal dispositions.
|
||||
signal dispositions. The '-P' option behaves similarly, but
|
||||
displays only the actions associated with each SIGSPEC argument.
|
||||
'-P' requires at least one SIGSPEC argument. The '-P' or '-p'
|
||||
options to 'trap' may be used in a subshell environment (e.g.,
|
||||
command substitution) and, as long as they are used before 'trap'
|
||||
is used to change a signal's handling, will display the state of
|
||||
its parent's traps.
|
||||
|
||||
The '-l' option causes 'trap' to print a list of signal names and
|
||||
their corresponding numbers. Each SIGSPEC is either a signal name
|
||||
@@ -4639,9 +4645,9 @@ parameters, or to display the names and values of shell variables.
|
||||
'-x'
|
||||
Print a trace of simple commands, 'for' commands, 'case'
|
||||
commands, 'select' commands, and arithmetic 'for' commands and
|
||||
their arguments or associated word lists after they are
|
||||
expanded and before they are executed. The value of the 'PS4'
|
||||
variable is expanded and the resultant value is printed before
|
||||
their arguments or associated word lists to standard error
|
||||
after they are expanded and before they are executed. The
|
||||
shell prints the expanded value of the 'PS4' variable before
|
||||
the command and its expanded arguments.
|
||||
|
||||
'-B'
|
||||
@@ -11899,10 +11905,10 @@ D.1 Index of Shell Builtin Commands
|
||||
* typeset: Bash Builtins. (line 641)
|
||||
* ulimit: Bash Builtins. (line 647)
|
||||
* umask: Bourne Shell Builtins.
|
||||
(line 422)
|
||||
(line 428)
|
||||
* unalias: Bash Builtins. (line 753)
|
||||
* unset: Bourne Shell Builtins.
|
||||
(line 440)
|
||||
(line 446)
|
||||
* wait: Job Control Builtins.
|
||||
(line 76)
|
||||
|
||||
@@ -12566,138 +12572,138 @@ D.5 Concept Index
|
||||
|
||||
|
||||
Tag Table:
|
||||
Node: Top897
|
||||
Node: Introduction2817
|
||||
Node: What is Bash?3033
|
||||
Node: What is a shell?4147
|
||||
Node: Definitions6685
|
||||
Node: Basic Shell Features9636
|
||||
Node: Shell Syntax10855
|
||||
Node: Shell Operation11881
|
||||
Node: Quoting13174
|
||||
Node: Escape Character14478
|
||||
Node: Single Quotes14963
|
||||
Node: Double Quotes15311
|
||||
Node: ANSI-C Quoting16589
|
||||
Node: Locale Translation17899
|
||||
Node: Creating Internationalized Scripts19210
|
||||
Node: Comments23327
|
||||
Node: Shell Commands23945
|
||||
Node: Reserved Words24883
|
||||
Node: Simple Commands25639
|
||||
Node: Pipelines26293
|
||||
Node: Lists29292
|
||||
Node: Compound Commands31087
|
||||
Node: Looping Constructs32099
|
||||
Node: Conditional Constructs34594
|
||||
Node: Command Grouping49082
|
||||
Node: Coprocesses50560
|
||||
Node: GNU Parallel53223
|
||||
Node: Shell Functions54140
|
||||
Node: Shell Parameters62025
|
||||
Node: Positional Parameters66413
|
||||
Node: Special Parameters67315
|
||||
Node: Shell Expansions70529
|
||||
Node: Brace Expansion72656
|
||||
Node: Tilde Expansion75390
|
||||
Node: Shell Parameter Expansion78011
|
||||
Node: Command Substitution96413
|
||||
Node: Arithmetic Expansion97768
|
||||
Node: Process Substitution98736
|
||||
Node: Word Splitting99856
|
||||
Node: Filename Expansion101800
|
||||
Node: Pattern Matching104549
|
||||
Node: Quote Removal109551
|
||||
Node: Redirections109846
|
||||
Node: Executing Commands119506
|
||||
Node: Simple Command Expansion120176
|
||||
Node: Command Search and Execution122286
|
||||
Node: Command Execution Environment124664
|
||||
Node: Environment127699
|
||||
Node: Exit Status129362
|
||||
Node: Signals131146
|
||||
Node: Shell Scripts134595
|
||||
Node: Shell Builtin Commands137622
|
||||
Node: Bourne Shell Builtins139660
|
||||
Node: Bash Builtins161445
|
||||
Node: Modifying Shell Behavior192836
|
||||
Node: The Set Builtin193181
|
||||
Node: The Shopt Builtin203782
|
||||
Node: Special Builtins219694
|
||||
Node: Shell Variables220673
|
||||
Node: Bourne Shell Variables221110
|
||||
Node: Bash Variables223214
|
||||
Node: Bash Features256029
|
||||
Node: Invoking Bash257042
|
||||
Node: Bash Startup Files263055
|
||||
Node: Interactive Shells268186
|
||||
Node: What is an Interactive Shell?268597
|
||||
Node: Is this Shell Interactive?269246
|
||||
Node: Interactive Shell Behavior270061
|
||||
Node: Bash Conditional Expressions273690
|
||||
Node: Shell Arithmetic278332
|
||||
Node: Aliases281276
|
||||
Node: Arrays283889
|
||||
Node: The Directory Stack290280
|
||||
Node: Directory Stack Builtins291064
|
||||
Node: Controlling the Prompt295324
|
||||
Node: The Restricted Shell298289
|
||||
Node: Bash POSIX Mode300899
|
||||
Node: Shell Compatibility Mode313461
|
||||
Node: Job Control322028
|
||||
Node: Job Control Basics322488
|
||||
Node: Job Control Builtins327490
|
||||
Node: Job Control Variables333285
|
||||
Node: Command Line Editing334441
|
||||
Node: Introduction and Notation336112
|
||||
Node: Readline Interaction337735
|
||||
Node: Readline Bare Essentials338926
|
||||
Node: Readline Movement Commands340715
|
||||
Node: Readline Killing Commands341675
|
||||
Node: Readline Arguments343596
|
||||
Node: Searching344640
|
||||
Node: Readline Init File346826
|
||||
Node: Readline Init File Syntax348087
|
||||
Node: Conditional Init Constructs371673
|
||||
Node: Sample Init File375869
|
||||
Node: Bindable Readline Commands378993
|
||||
Node: Commands For Moving380197
|
||||
Node: Commands For History382248
|
||||
Node: Commands For Text387242
|
||||
Node: Commands For Killing390891
|
||||
Node: Numeric Arguments393924
|
||||
Node: Commands For Completion395063
|
||||
Node: Keyboard Macros399254
|
||||
Node: Miscellaneous Commands399942
|
||||
Node: Readline vi Mode405887
|
||||
Node: Programmable Completion406794
|
||||
Node: Programmable Completion Builtins414574
|
||||
Node: A Programmable Completion Example425326
|
||||
Node: Using History Interactively430574
|
||||
Node: Bash History Facilities431258
|
||||
Node: Bash History Builtins434263
|
||||
Node: History Interaction439287
|
||||
Node: Event Designators442907
|
||||
Node: Word Designators444261
|
||||
Node: Modifiers446021
|
||||
Node: Installing Bash447829
|
||||
Node: Basic Installation448966
|
||||
Node: Compilers and Options452688
|
||||
Node: Compiling For Multiple Architectures453429
|
||||
Node: Installation Names455121
|
||||
Node: Specifying the System Type457230
|
||||
Node: Sharing Defaults457947
|
||||
Node: Operation Controls458620
|
||||
Node: Optional Features459578
|
||||
Node: Reporting Bugs470797
|
||||
Node: Major Differences From The Bourne Shell472141
|
||||
Node: GNU Free Documentation License488990
|
||||
Node: Indexes514167
|
||||
Node: Builtin Index514621
|
||||
Node: Reserved Word Index521448
|
||||
Node: Variable Index523896
|
||||
Node: Function Index540670
|
||||
Node: Concept Index554454
|
||||
Node: Top895
|
||||
Node: Introduction2813
|
||||
Node: What is Bash?3029
|
||||
Node: What is a shell?4143
|
||||
Node: Definitions6681
|
||||
Node: Basic Shell Features9632
|
||||
Node: Shell Syntax10851
|
||||
Node: Shell Operation11877
|
||||
Node: Quoting13170
|
||||
Node: Escape Character14474
|
||||
Node: Single Quotes14959
|
||||
Node: Double Quotes15307
|
||||
Node: ANSI-C Quoting16585
|
||||
Node: Locale Translation17895
|
||||
Node: Creating Internationalized Scripts19206
|
||||
Node: Comments23323
|
||||
Node: Shell Commands23941
|
||||
Node: Reserved Words24879
|
||||
Node: Simple Commands25635
|
||||
Node: Pipelines26289
|
||||
Node: Lists29288
|
||||
Node: Compound Commands31083
|
||||
Node: Looping Constructs32095
|
||||
Node: Conditional Constructs34590
|
||||
Node: Command Grouping49078
|
||||
Node: Coprocesses50556
|
||||
Node: GNU Parallel53219
|
||||
Node: Shell Functions54136
|
||||
Node: Shell Parameters62021
|
||||
Node: Positional Parameters66409
|
||||
Node: Special Parameters67311
|
||||
Node: Shell Expansions70525
|
||||
Node: Brace Expansion72652
|
||||
Node: Tilde Expansion75386
|
||||
Node: Shell Parameter Expansion78007
|
||||
Node: Command Substitution96409
|
||||
Node: Arithmetic Expansion97764
|
||||
Node: Process Substitution98732
|
||||
Node: Word Splitting99852
|
||||
Node: Filename Expansion101796
|
||||
Node: Pattern Matching104545
|
||||
Node: Quote Removal109547
|
||||
Node: Redirections109842
|
||||
Node: Executing Commands119502
|
||||
Node: Simple Command Expansion120172
|
||||
Node: Command Search and Execution122282
|
||||
Node: Command Execution Environment124669
|
||||
Node: Environment127704
|
||||
Node: Exit Status129367
|
||||
Node: Signals131151
|
||||
Node: Shell Scripts134600
|
||||
Node: Shell Builtin Commands137627
|
||||
Node: Bourne Shell Builtins139665
|
||||
Node: Bash Builtins161863
|
||||
Node: Modifying Shell Behavior193254
|
||||
Node: The Set Builtin193599
|
||||
Node: The Shopt Builtin204197
|
||||
Node: Special Builtins220109
|
||||
Node: Shell Variables221088
|
||||
Node: Bourne Shell Variables221525
|
||||
Node: Bash Variables223629
|
||||
Node: Bash Features256444
|
||||
Node: Invoking Bash257457
|
||||
Node: Bash Startup Files263470
|
||||
Node: Interactive Shells268601
|
||||
Node: What is an Interactive Shell?269012
|
||||
Node: Is this Shell Interactive?269661
|
||||
Node: Interactive Shell Behavior270476
|
||||
Node: Bash Conditional Expressions274105
|
||||
Node: Shell Arithmetic278747
|
||||
Node: Aliases281691
|
||||
Node: Arrays284304
|
||||
Node: The Directory Stack290695
|
||||
Node: Directory Stack Builtins291479
|
||||
Node: Controlling the Prompt295739
|
||||
Node: The Restricted Shell298704
|
||||
Node: Bash POSIX Mode301314
|
||||
Node: Shell Compatibility Mode313876
|
||||
Node: Job Control322443
|
||||
Node: Job Control Basics322903
|
||||
Node: Job Control Builtins327905
|
||||
Node: Job Control Variables333700
|
||||
Node: Command Line Editing334856
|
||||
Node: Introduction and Notation336527
|
||||
Node: Readline Interaction338150
|
||||
Node: Readline Bare Essentials339341
|
||||
Node: Readline Movement Commands341130
|
||||
Node: Readline Killing Commands342090
|
||||
Node: Readline Arguments344011
|
||||
Node: Searching345055
|
||||
Node: Readline Init File347241
|
||||
Node: Readline Init File Syntax348502
|
||||
Node: Conditional Init Constructs372088
|
||||
Node: Sample Init File376284
|
||||
Node: Bindable Readline Commands379408
|
||||
Node: Commands For Moving380612
|
||||
Node: Commands For History382663
|
||||
Node: Commands For Text387657
|
||||
Node: Commands For Killing391306
|
||||
Node: Numeric Arguments394339
|
||||
Node: Commands For Completion395478
|
||||
Node: Keyboard Macros399669
|
||||
Node: Miscellaneous Commands400357
|
||||
Node: Readline vi Mode406302
|
||||
Node: Programmable Completion407209
|
||||
Node: Programmable Completion Builtins414989
|
||||
Node: A Programmable Completion Example425741
|
||||
Node: Using History Interactively430989
|
||||
Node: Bash History Facilities431673
|
||||
Node: Bash History Builtins434678
|
||||
Node: History Interaction439702
|
||||
Node: Event Designators443322
|
||||
Node: Word Designators444676
|
||||
Node: Modifiers446436
|
||||
Node: Installing Bash448244
|
||||
Node: Basic Installation449381
|
||||
Node: Compilers and Options453103
|
||||
Node: Compiling For Multiple Architectures453844
|
||||
Node: Installation Names455536
|
||||
Node: Specifying the System Type457645
|
||||
Node: Sharing Defaults458362
|
||||
Node: Operation Controls459035
|
||||
Node: Optional Features459993
|
||||
Node: Reporting Bugs471212
|
||||
Node: Major Differences From The Bourne Shell472556
|
||||
Node: GNU Free Documentation License489405
|
||||
Node: Indexes514582
|
||||
Node: Builtin Index515036
|
||||
Node: Reserved Word Index521863
|
||||
Node: Variable Index524311
|
||||
Node: Function Index541085
|
||||
Node: Concept Index554869
|
||||
|
||||
End Tag Table
|
||||
|
||||
|
||||
+11
-4
@@ -14,7 +14,7 @@ This is Edition @value{EDITION}, last updated @value{UPDATED},
|
||||
of @cite{The GNU Bash Reference Manual},
|
||||
for @code{Bash}, Version @value{VERSION}.
|
||||
|
||||
Copyright @copyright{} 1988--2022 Free Software Foundation, Inc.
|
||||
Copyright @copyright{} 1988--2023 Free Software Foundation, Inc.
|
||||
|
||||
@quotation
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
@@ -3330,8 +3330,8 @@ were no command substitutions, the command exits with a status of zero.
|
||||
@cindex command search
|
||||
|
||||
After a command has been split into words, if it results in a
|
||||
simple command and an optional list of arguments, the following
|
||||
actions are taken.
|
||||
simple command and an optional list of arguments, the shell performs
|
||||
the following actions.
|
||||
|
||||
@enumerate
|
||||
@item
|
||||
@@ -4224,7 +4224,7 @@ The return status is zero.
|
||||
@item trap
|
||||
@btindex trap
|
||||
@example
|
||||
trap [-lp] [@var{action}] [@var{sigspec} @dots{}]
|
||||
trap [-Plp] [@var{action}] [@var{sigspec} @dots{}]
|
||||
@end example
|
||||
|
||||
The @var{action} is a command that is read and executed when the
|
||||
@@ -4244,6 +4244,13 @@ If @var{action} is not present and @option{-p} has been supplied,
|
||||
or, if no @var{sigspec}s are supplied, for all trapped signals,
|
||||
as a set of @code{trap} commands that can be reused as shell input to
|
||||
restore the current signal dispositions.
|
||||
The @option{-P} option behaves similarly, but displays only the actions
|
||||
associated with each @var{sigspec} argument.
|
||||
@option{-P} requires at least one @var{sigspec} argument.
|
||||
The @option{-P} or @option{-p} options to @code{trap} may be
|
||||
used in a subshell environment (e.g., command substitution) and,
|
||||
as long as they are used before @code{trap} is used to change a
|
||||
signal's handling, will display the state of its parent's traps.
|
||||
|
||||
The @option{-l} option causes @code{trap} to print a list of signal names
|
||||
and their corresponding numbers.
|
||||
|
||||
+331
-316
@@ -932,23 +932,24 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
|
||||
output, character escape sequences, which are converted and
|
||||
copied to the standard output, and format specifications, each
|
||||
of which causes printing of the next successive _a_r_g_u_m_e_n_t. In
|
||||
addition to the standard _p_r_i_n_t_f(1) format specifications, pprriinnttff
|
||||
interprets the following extensions:
|
||||
addition to the standard _p_r_i_n_t_f(3) format characters ccssnnddiioouuxxXXee--
|
||||
EEffFFggGGaaAA, pprriinnttff interprets the following additional format spec-
|
||||
ifiers:
|
||||
%%bb causes pprriinnttff to expand backslash escape sequences in the
|
||||
corresponding _a_r_g_u_m_e_n_t in the same way as eecchhoo --ee.
|
||||
%%qq causes pprriinnttff to output the corresponding _a_r_g_u_m_e_n_t in a
|
||||
%%qq causes pprriinnttff to output the corresponding _a_r_g_u_m_e_n_t in a
|
||||
format that can be reused as shell input.
|
||||
%%QQ like %%qq, but applies any supplied precision to the _a_r_g_u_-
|
||||
%%QQ like %%qq, but applies any supplied precision to the _a_r_g_u_-
|
||||
_m_e_n_t before quoting it.
|
||||
%%((_d_a_t_e_f_m_t))TT
|
||||
causes pprriinnttff to output the date-time string resulting
|
||||
from using _d_a_t_e_f_m_t as a format string for _s_t_r_f_t_i_m_e(3).
|
||||
causes pprriinnttff to output the date-time string resulting
|
||||
from using _d_a_t_e_f_m_t as a format string for _s_t_r_f_t_i_m_e(3).
|
||||
The corresponding _a_r_g_u_m_e_n_t is an integer representing the
|
||||
number of seconds since the epoch. Two special argument
|
||||
values may be used: -1 represents the current time, and
|
||||
-2 represents the time the shell was invoked. If no ar-
|
||||
number of seconds since the epoch. Two special argument
|
||||
values may be used: -1 represents the current time, and
|
||||
-2 represents the time the shell was invoked. If no ar-
|
||||
gument is specified, conversion behaves as if -1 had been
|
||||
given. This is an exception to the usual pprriinnttff behav-
|
||||
given. This is an exception to the usual pprriinnttff behav-
|
||||
ior.
|
||||
|
||||
The %b, %q, and %T directives all use the field width and preci-
|
||||
@@ -956,6 +957,9 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
|
||||
bytes from (or use that wide a field for) the expanded argument,
|
||||
which usually contains more characters than the original.
|
||||
|
||||
The %n format specifier accepts a corresponding argument that is
|
||||
treated as a shell variable name.
|
||||
|
||||
Arguments to non-string format specifiers are treated as C con-
|
||||
stants, except that a leading plus or minus sign is allowed, and
|
||||
if the leading character is a single or double quote, the value
|
||||
@@ -965,95 +969,96 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
|
||||
_m_e_n_t_s. If the _f_o_r_m_a_t requires more _a_r_g_u_m_e_n_t_s than are supplied,
|
||||
the extra format specifications behave as if a zero value or
|
||||
null string, as appropriate, had been supplied. The return
|
||||
value is zero on success, non-zero on failure.
|
||||
value is zero on success, non-zero if an invalid option is sup-
|
||||
plied or a write or assignment error occurs.
|
||||
|
||||
ppuusshhdd [--nn] [+_n] [-_n]
|
||||
ppuusshhdd [--nn] [_d_i_r]
|
||||
Adds a directory to the top of the directory stack, or rotates
|
||||
the stack, making the new top of the stack the current working
|
||||
directory. With no arguments, ppuusshhdd exchanges the top two ele-
|
||||
ments of the directory stack. Arguments, if supplied, have the
|
||||
Adds a directory to the top of the directory stack, or rotates
|
||||
the stack, making the new top of the stack the current working
|
||||
directory. With no arguments, ppuusshhdd exchanges the top two ele-
|
||||
ments of the directory stack. Arguments, if supplied, have the
|
||||
following meanings:
|
||||
--nn Suppresses the normal change of directory when rotating
|
||||
or adding directories to the stack, so that only the
|
||||
--nn Suppresses the normal change of directory when rotating
|
||||
or adding directories to the stack, so that only the
|
||||
stack is manipulated.
|
||||
++_n Rotates the stack so that the _nth directory (counting
|
||||
from the left of the list shown by ddiirrss, starting with
|
||||
++_n Rotates the stack so that the _nth directory (counting
|
||||
from the left of the list shown by ddiirrss, starting with
|
||||
zero) is at the top.
|
||||
--_n Rotates the stack so that the _nth directory (counting
|
||||
from the right of the list shown by ddiirrss, starting with
|
||||
--_n Rotates the stack so that the _nth directory (counting
|
||||
from the right of the list shown by ddiirrss, starting with
|
||||
zero) is at the top.
|
||||
_d_i_r Adds _d_i_r to the directory stack at the top
|
||||
|
||||
After the stack has been modified, if the --nn option was not sup-
|
||||
plied, ppuusshhdd uses the ccdd builtin to change to the directory at
|
||||
plied, ppuusshhdd uses the ccdd builtin to change to the directory at
|
||||
the top of the stack. If the ccdd fails, ppuusshhdd returns a non-zero
|
||||
value.
|
||||
|
||||
Otherwise, if no arguments are supplied, ppuusshhdd returns 0 unless
|
||||
the directory stack is empty. When rotating the directory
|
||||
stack, ppuusshhdd returns 0 unless the directory stack is empty or a
|
||||
Otherwise, if no arguments are supplied, ppuusshhdd returns 0 unless
|
||||
the directory stack is empty. When rotating the directory
|
||||
stack, ppuusshhdd returns 0 unless the directory stack is empty or a
|
||||
non-existent directory stack element is specified.
|
||||
|
||||
If the ppuusshhdd command is successful, bash runs ddiirrss to show the
|
||||
If the ppuusshhdd command is successful, bash runs ddiirrss to show the
|
||||
final contents of the directory stack.
|
||||
|
||||
ppwwdd [--LLPP]
|
||||
Print the absolute pathname of the current working directory.
|
||||
Print the absolute pathname of the current working directory.
|
||||
The pathname printed contains no symbolic links if the --PP option
|
||||
is supplied or the --oo pphhyyssiiccaall option to the sseett builtin command
|
||||
is enabled. If the --LL option is used, the pathname printed may
|
||||
contain symbolic links. The return status is 0 unless an error
|
||||
is enabled. If the --LL option is used, the pathname printed may
|
||||
contain symbolic links. The return status is 0 unless an error
|
||||
occurs while reading the name of the current directory or an in-
|
||||
valid option is supplied.
|
||||
|
||||
rreeaadd [--eerrss] [--aa _a_n_a_m_e] [--dd _d_e_l_i_m] [--ii _t_e_x_t] [--nn _n_c_h_a_r_s] [--NN _n_c_h_a_r_s] [--pp
|
||||
_p_r_o_m_p_t] [--tt _t_i_m_e_o_u_t] [--uu _f_d] [_n_a_m_e ...]
|
||||
One line is read from the standard input, or from the file de-
|
||||
One line is read from the standard input, or from the file de-
|
||||
scriptor _f_d supplied as an argument to the --uu option, split into
|
||||
words as described in _b_a_s_h_(_1_) under WWoorrdd SSpplliittttiinngg, and the
|
||||
words as described in _b_a_s_h_(_1_) under WWoorrdd SSpplliittttiinngg, and the
|
||||
first word is assigned to the first _n_a_m_e, the second word to the
|
||||
second _n_a_m_e, and so on. If there are more words than names, the
|
||||
remaining words and their intervening delimiters are assigned to
|
||||
the last _n_a_m_e. If there are fewer words read from the input
|
||||
stream than names, the remaining names are assigned empty val-
|
||||
ues. The characters in IIFFSS are used to split the line into
|
||||
words using the same rules the shell uses for expansion (de-
|
||||
the last _n_a_m_e. If there are fewer words read from the input
|
||||
stream than names, the remaining names are assigned empty val-
|
||||
ues. The characters in IIFFSS are used to split the line into
|
||||
words using the same rules the shell uses for expansion (de-
|
||||
scribed in _b_a_s_h_(_1_) under WWoorrdd SSpplliittttiinngg). The backslash charac-
|
||||
ter (\\) may be used to remove any special meaning for the next
|
||||
ter (\\) may be used to remove any special meaning for the next
|
||||
character read and for line continuation. Options, if supplied,
|
||||
have the following meanings:
|
||||
--aa _a_n_a_m_e
|
||||
The words are assigned to sequential indices of the array
|
||||
variable _a_n_a_m_e, starting at 0. _a_n_a_m_e is unset before any
|
||||
new values are assigned. Other _n_a_m_e arguments are ig-
|
||||
new values are assigned. Other _n_a_m_e arguments are ig-
|
||||
nored.
|
||||
--dd _d_e_l_i_m
|
||||
The first character of _d_e_l_i_m is used to terminate the in-
|
||||
put line, rather than newline. If _d_e_l_i_m is the empty
|
||||
string, rreeaadd will terminate a line when it reads a NUL
|
||||
put line, rather than newline. If _d_e_l_i_m is the empty
|
||||
string, rreeaadd will terminate a line when it reads a NUL
|
||||
character.
|
||||
--ee If the standard input is coming from a terminal, rreeaaddlliinnee
|
||||
(see RREEAADDLLIINNEE in _b_a_s_h_(_1_)) is used to obtain the line.
|
||||
Readline uses the current (or default, if line editing
|
||||
was not previously active) editing settings, but uses
|
||||
(see RREEAADDLLIINNEE in _b_a_s_h_(_1_)) is used to obtain the line.
|
||||
Readline uses the current (or default, if line editing
|
||||
was not previously active) editing settings, but uses
|
||||
readline's default filename completion.
|
||||
--ii _t_e_x_t
|
||||
If rreeaaddlliinnee is being used to read the line, _t_e_x_t is
|
||||
If rreeaaddlliinnee is being used to read the line, _t_e_x_t is
|
||||
placed into the editing buffer before editing begins.
|
||||
--nn _n_c_h_a_r_s
|
||||
rreeaadd returns after reading _n_c_h_a_r_s characters rather than
|
||||
rreeaadd returns after reading _n_c_h_a_r_s characters rather than
|
||||
waiting for a complete line of input, but honors a delim-
|
||||
iter if fewer than _n_c_h_a_r_s characters are read before the
|
||||
iter if fewer than _n_c_h_a_r_s characters are read before the
|
||||
delimiter.
|
||||
--NN _n_c_h_a_r_s
|
||||
rreeaadd returns after reading exactly _n_c_h_a_r_s characters
|
||||
rather than waiting for a complete line of input, unless
|
||||
EOF is encountered or rreeaadd times out. Delimiter charac-
|
||||
ters encountered in the input are not treated specially
|
||||
and do not cause rreeaadd to return until _n_c_h_a_r_s characters
|
||||
are read. The result is not split on the characters in
|
||||
IIFFSS; the intent is that the variable is assigned exactly
|
||||
rreeaadd returns after reading exactly _n_c_h_a_r_s characters
|
||||
rather than waiting for a complete line of input, unless
|
||||
EOF is encountered or rreeaadd times out. Delimiter charac-
|
||||
ters encountered in the input are not treated specially
|
||||
and do not cause rreeaadd to return until _n_c_h_a_r_s characters
|
||||
are read. The result is not split on the characters in
|
||||
IIFFSS; the intent is that the variable is assigned exactly
|
||||
the characters read (with the exception of backslash; see
|
||||
the --rr option below).
|
||||
--pp _p_r_o_m_p_t
|
||||
@@ -1061,133 +1066,133 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
|
||||
line, before attempting to read any input. The prompt is
|
||||
displayed only if input is coming from a terminal.
|
||||
--rr Backslash does not act as an escape character. The back-
|
||||
slash is considered to be part of the line. In particu-
|
||||
lar, a backslash-newline pair may not then be used as a
|
||||
slash is considered to be part of the line. In particu-
|
||||
lar, a backslash-newline pair may not then be used as a
|
||||
line continuation.
|
||||
--ss Silent mode. If input is coming from a terminal, charac-
|
||||
ters are not echoed.
|
||||
--tt _t_i_m_e_o_u_t
|
||||
Cause rreeaadd to time out and return failure if a complete
|
||||
line of input (or a specified number of characters) is
|
||||
not read within _t_i_m_e_o_u_t seconds. _t_i_m_e_o_u_t may be a deci-
|
||||
mal number with a fractional portion following the deci-
|
||||
mal point. This option is only effective if rreeaadd is
|
||||
reading input from a terminal, pipe, or other special
|
||||
file; it has no effect when reading from regular files.
|
||||
Cause rreeaadd to time out and return failure if a complete
|
||||
line of input (or a specified number of characters) is
|
||||
not read within _t_i_m_e_o_u_t seconds. _t_i_m_e_o_u_t may be a deci-
|
||||
mal number with a fractional portion following the deci-
|
||||
mal point. This option is only effective if rreeaadd is
|
||||
reading input from a terminal, pipe, or other special
|
||||
file; it has no effect when reading from regular files.
|
||||
If rreeaadd times out, rreeaadd saves any partial input read into
|
||||
the specified variable _n_a_m_e. If _t_i_m_e_o_u_t is 0, rreeaadd re-
|
||||
turns immediately, without trying to read any data. The
|
||||
exit status is 0 if input is available on the specified
|
||||
file descriptor, or the read will return EOF, non-zero
|
||||
otherwise. The exit status is greater than 128 if the
|
||||
the specified variable _n_a_m_e. If _t_i_m_e_o_u_t is 0, rreeaadd re-
|
||||
turns immediately, without trying to read any data. The
|
||||
exit status is 0 if input is available on the specified
|
||||
file descriptor, or the read will return EOF, non-zero
|
||||
otherwise. The exit status is greater than 128 if the
|
||||
timeout is exceeded.
|
||||
--uu _f_d Read input from file descriptor _f_d.
|
||||
|
||||
If no _n_a_m_e_s are supplied, the line read, without the ending de-
|
||||
limiter but otherwise unmodified, is assigned to the variable
|
||||
RREEPPLLYY. The exit status is zero, unless end-of-file is encoun-
|
||||
tered, rreeaadd times out (in which case the status is greater than
|
||||
128), a variable assignment error (such as assigning to a read-
|
||||
If no _n_a_m_e_s are supplied, the line read, without the ending de-
|
||||
limiter but otherwise unmodified, is assigned to the variable
|
||||
RREEPPLLYY. The exit status is zero, unless end-of-file is encoun-
|
||||
tered, rreeaadd times out (in which case the status is greater than
|
||||
128), a variable assignment error (such as assigning to a read-
|
||||
only variable) occurs, or an invalid file descriptor is supplied
|
||||
as the argument to --uu.
|
||||
|
||||
rreeaaddoonnllyy [--aaAAff] [--pp] [_n_a_m_e[=_w_o_r_d] ...]
|
||||
The given _n_a_m_e_s are marked readonly; the values of these _n_a_m_e_s
|
||||
may not be changed by subsequent assignment. If the --ff option
|
||||
is supplied, the functions corresponding to the _n_a_m_e_s are so
|
||||
marked. The --aa option restricts the variables to indexed ar-
|
||||
rays; the --AA option restricts the variables to associative ar-
|
||||
The given _n_a_m_e_s are marked readonly; the values of these _n_a_m_e_s
|
||||
may not be changed by subsequent assignment. If the --ff option
|
||||
is supplied, the functions corresponding to the _n_a_m_e_s are so
|
||||
marked. The --aa option restricts the variables to indexed ar-
|
||||
rays; the --AA option restricts the variables to associative ar-
|
||||
rays. If both options are supplied, --AA takes precedence. If no
|
||||
_n_a_m_e arguments are given, or if the --pp option is supplied, a
|
||||
_n_a_m_e arguments are given, or if the --pp option is supplied, a
|
||||
list of all readonly names is printed. The other options may be
|
||||
used to restrict the output to a subset of the set of readonly
|
||||
names. The --pp option causes output to be displayed in a format
|
||||
that may be reused as input. If a variable name is followed by
|
||||
=_w_o_r_d, the value of the variable is set to _w_o_r_d. The return
|
||||
status is 0 unless an invalid option is encountered, one of the
|
||||
used to restrict the output to a subset of the set of readonly
|
||||
names. The --pp option causes output to be displayed in a format
|
||||
that may be reused as input. If a variable name is followed by
|
||||
=_w_o_r_d, the value of the variable is set to _w_o_r_d. The return
|
||||
status is 0 unless an invalid option is encountered, one of the
|
||||
_n_a_m_e_s is not a valid shell variable name, or --ff is supplied with
|
||||
a _n_a_m_e that is not a function.
|
||||
|
||||
rreettuurrnn [_n]
|
||||
Causes a function to stop executing and return the value speci-
|
||||
fied by _n to its caller. If _n is omitted, the return status is
|
||||
that of the last command executed in the function body. If rree--
|
||||
Causes a function to stop executing and return the value speci-
|
||||
fied by _n to its caller. If _n is omitted, the return status is
|
||||
that of the last command executed in the function body. If rree--
|
||||
ttuurrnn is executed by a trap handler, the last command used to de-
|
||||
termine the status is the last command executed before the trap
|
||||
handler. If rreettuurrnn is executed during a DDEEBBUUGG trap, the last
|
||||
command used to determine the status is the last command exe-
|
||||
cuted by the trap handler before rreettuurrnn was invoked. If rreettuurrnn
|
||||
is used outside a function, but during execution of a script by
|
||||
the .. (ssoouurrccee) command, it causes the shell to stop executing
|
||||
that script and return either _n or the exit status of the last
|
||||
command executed within the script as the exit status of the
|
||||
termine the status is the last command executed before the trap
|
||||
handler. If rreettuurrnn is executed during a DDEEBBUUGG trap, the last
|
||||
command used to determine the status is the last command exe-
|
||||
cuted by the trap handler before rreettuurrnn was invoked. If rreettuurrnn
|
||||
is used outside a function, but during execution of a script by
|
||||
the .. (ssoouurrccee) command, it causes the shell to stop executing
|
||||
that script and return either _n or the exit status of the last
|
||||
command executed within the script as the exit status of the
|
||||
script. If _n is supplied, the return value is its least signif-
|
||||
icant 8 bits. The return status is non-zero if rreettuurrnn is sup-
|
||||
plied a non-numeric argument, or is used outside a function and
|
||||
not during execution of a script by .. or ssoouurrccee. Any command
|
||||
icant 8 bits. The return status is non-zero if rreettuurrnn is sup-
|
||||
plied a non-numeric argument, or is used outside a function and
|
||||
not during execution of a script by .. or ssoouurrccee. Any command
|
||||
associated with the RREETTUURRNN trap is executed before execution re-
|
||||
sumes after the function or script.
|
||||
|
||||
sseett [--aabbeeffhhkkmmnnppttuuvvxxBBCCEEHHPPTT] [--oo _o_p_t_i_o_n_-_n_a_m_e] [----] [--] [_a_r_g ...]
|
||||
sseett [++aabbeeffhhkkmmnnppttuuvvxxBBCCEEHHPPTT] [++oo _o_p_t_i_o_n_-_n_a_m_e] [----] [--] [_a_r_g ...]
|
||||
Without options, display the name and value of each shell vari-
|
||||
able in a format that can be reused as input for setting or re-
|
||||
Without options, display the name and value of each shell vari-
|
||||
able in a format that can be reused as input for setting or re-
|
||||
setting the currently-set variables. Read-only variables cannot
|
||||
be reset. In _p_o_s_i_x _m_o_d_e, only shell variables are listed. The
|
||||
output is sorted according to the current locale. When options
|
||||
are specified, they set or unset shell attributes. Any argu-
|
||||
ments remaining after option processing are treated as values
|
||||
be reset. In _p_o_s_i_x _m_o_d_e, only shell variables are listed. The
|
||||
output is sorted according to the current locale. When options
|
||||
are specified, they set or unset shell attributes. Any argu-
|
||||
ments remaining after option processing are treated as values
|
||||
for the positional parameters and are assigned, in order, to $$11,
|
||||
$$22, ...... $$_n. Options, if specified, have the following mean-
|
||||
$$22, ...... $$_n. Options, if specified, have the following mean-
|
||||
ings:
|
||||
--aa Each variable or function that is created or modified is
|
||||
given the export attribute and marked for export to the
|
||||
given the export attribute and marked for export to the
|
||||
environment of subsequent commands.
|
||||
--bb Report the status of terminated background jobs immedi-
|
||||
--bb Report the status of terminated background jobs immedi-
|
||||
ately, rather than before the next primary prompt. This
|
||||
is effective only when job control is enabled.
|
||||
--ee Exit immediately if a _p_i_p_e_l_i_n_e (which may consist of a
|
||||
single _s_i_m_p_l_e _c_o_m_m_a_n_d), a _l_i_s_t, or a _c_o_m_p_o_u_n_d _c_o_m_m_a_n_d
|
||||
(see SSHHEELLLL GGRRAAMMMMAARR in _b_a_s_h_(_1_)), exits with a non-zero
|
||||
status. The shell does not exit if the command that
|
||||
fails is part of the command list immediately following
|
||||
--ee Exit immediately if a _p_i_p_e_l_i_n_e (which may consist of a
|
||||
single _s_i_m_p_l_e _c_o_m_m_a_n_d), a _l_i_s_t, or a _c_o_m_p_o_u_n_d _c_o_m_m_a_n_d
|
||||
(see SSHHEELLLL GGRRAAMMMMAARR in _b_a_s_h_(_1_)), exits with a non-zero
|
||||
status. The shell does not exit if the command that
|
||||
fails is part of the command list immediately following
|
||||
a wwhhiillee or uunnttiill keyword, part of the test following the
|
||||
iiff or eelliiff reserved words, part of any command executed
|
||||
in a &&&& or |||| list except the command following the fi-
|
||||
iiff or eelliiff reserved words, part of any command executed
|
||||
in a &&&& or |||| list except the command following the fi-
|
||||
nal &&&& or ||||, any command in a pipeline but the last, or
|
||||
if the command's return value is being inverted with !!.
|
||||
If a compound command other than a subshell returns a
|
||||
non-zero status because a command failed while --ee was
|
||||
being ignored, the shell does not exit. A trap on EERRRR,
|
||||
if the command's return value is being inverted with !!.
|
||||
If a compound command other than a subshell returns a
|
||||
non-zero status because a command failed while --ee was
|
||||
being ignored, the shell does not exit. A trap on EERRRR,
|
||||
if set, is executed before the shell exits. This option
|
||||
applies to the shell environment and each subshell envi-
|
||||
ronment separately (see CCOOMMMMAANNDD EEXXEECCUUTTIIOONN EENNVVIIRROONNMMEENNTT in
|
||||
_b_a_s_h_(_1_)), and may cause subshells to exit before execut-
|
||||
ing all the commands in the subshell.
|
||||
|
||||
If a compound command or shell function executes in a
|
||||
context where --ee is being ignored, none of the commands
|
||||
executed within the compound command or function body
|
||||
will be affected by the --ee setting, even if --ee is set
|
||||
and a command returns a failure status. If a compound
|
||||
command or shell function sets --ee while executing in a
|
||||
context where --ee is ignored, that setting will not have
|
||||
any effect until the compound command or the command
|
||||
If a compound command or shell function executes in a
|
||||
context where --ee is being ignored, none of the commands
|
||||
executed within the compound command or function body
|
||||
will be affected by the --ee setting, even if --ee is set
|
||||
and a command returns a failure status. If a compound
|
||||
command or shell function sets --ee while executing in a
|
||||
context where --ee is ignored, that setting will not have
|
||||
any effect until the compound command or the command
|
||||
containing the function call completes.
|
||||
--ff Disable pathname expansion.
|
||||
--hh Remember the location of commands as they are looked up
|
||||
--hh Remember the location of commands as they are looked up
|
||||
for execution. This is enabled by default.
|
||||
--kk All arguments in the form of assignment statements are
|
||||
placed in the environment for a command, not just those
|
||||
--kk All arguments in the form of assignment statements are
|
||||
placed in the environment for a command, not just those
|
||||
that precede the command name.
|
||||
--mm Monitor mode. Job control is enabled. This option is
|
||||
on by default for interactive shells on systems that
|
||||
support it (see JJOOBB CCOONNTTRROOLL in _b_a_s_h_(_1_)). All processes
|
||||
run in a separate process group. When a background job
|
||||
completes, the shell prints a line containing its exit
|
||||
--mm Monitor mode. Job control is enabled. This option is
|
||||
on by default for interactive shells on systems that
|
||||
support it (see JJOOBB CCOONNTTRROOLL in _b_a_s_h_(_1_)). All processes
|
||||
run in a separate process group. When a background job
|
||||
completes, the shell prints a line containing its exit
|
||||
status.
|
||||
--nn Read commands but do not execute them. This may be used
|
||||
to check a shell script for syntax errors. This is ig-
|
||||
to check a shell script for syntax errors. This is ig-
|
||||
nored by interactive shells.
|
||||
--oo _o_p_t_i_o_n_-_n_a_m_e
|
||||
The _o_p_t_i_o_n_-_n_a_m_e can be one of the following:
|
||||
@@ -1195,10 +1200,10 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
|
||||
Same as --aa.
|
||||
bbrraacceeeexxppaanndd
|
||||
Same as --BB.
|
||||
eemmaaccss Use an emacs-style command line editing inter-
|
||||
eemmaaccss Use an emacs-style command line editing inter-
|
||||
face. This is enabled by default when the shell
|
||||
is interactive, unless the shell is started with
|
||||
the ----nnooeeddiittiinngg option. This also affects the
|
||||
the ----nnooeeddiittiinngg option. This also affects the
|
||||
editing interface used for rreeaadd --ee.
|
||||
eerrrreexxiitt Same as --ee.
|
||||
eerrrrttrraaccee
|
||||
@@ -1208,12 +1213,12 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
|
||||
hhaasshhaallll Same as --hh.
|
||||
hhiisstteexxppaanndd
|
||||
Same as --HH.
|
||||
hhiissttoorryy Enable command history, as described in _b_a_s_h_(_1_)
|
||||
under HHIISSTTOORRYY. This option is on by default in
|
||||
hhiissttoorryy Enable command history, as described in _b_a_s_h_(_1_)
|
||||
under HHIISSTTOORRYY. This option is on by default in
|
||||
interactive shells.
|
||||
iiggnnoorreeeeooff
|
||||
The effect is as if the shell command ``IG-
|
||||
NOREEOF=10'' had been executed (see SShheellll VVaarrii--
|
||||
The effect is as if the shell command ``IG-
|
||||
NOREEOF=10'' had been executed (see SShheellll VVaarrii--
|
||||
aabblleess in _b_a_s_h_(_1_)).
|
||||
kkeeyywwoorrdd Same as --kk.
|
||||
mmoonniittoorr Same as --mm.
|
||||
@@ -1228,55 +1233,56 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
|
||||
pphhyyssiiccaall
|
||||
Same as --PP.
|
||||
ppiippeeffaaiill
|
||||
If set, the return value of a pipeline is the
|
||||
value of the last (rightmost) command to exit
|
||||
with a non-zero status, or zero if all commands
|
||||
in the pipeline exit successfully. This option
|
||||
If set, the return value of a pipeline is the
|
||||
value of the last (rightmost) command to exit
|
||||
with a non-zero status, or zero if all commands
|
||||
in the pipeline exit successfully. This option
|
||||
is disabled by default.
|
||||
ppoossiixx Change the behavior of bbaasshh where the default
|
||||
operation differs from the POSIX standard to
|
||||
match the standard (_p_o_s_i_x _m_o_d_e). See SSEEEE AALLSSOO
|
||||
in _b_a_s_h_(_1_) for a reference to a document that
|
||||
ppoossiixx Change the behavior of bbaasshh where the default
|
||||
operation differs from the POSIX standard to
|
||||
match the standard (_p_o_s_i_x _m_o_d_e). See SSEEEE AALLSSOO
|
||||
in _b_a_s_h_(_1_) for a reference to a document that
|
||||
details how posix mode affects bash's behavior.
|
||||
pprriivviilleeggeedd
|
||||
Same as --pp.
|
||||
vveerrbboossee Same as --vv.
|
||||
vvii Use a vi-style command line editing interface.
|
||||
vvii Use a vi-style command line editing interface.
|
||||
This also affects the editing interface used for
|
||||
rreeaadd --ee.
|
||||
xxttrraaccee Same as --xx.
|
||||
If --oo is supplied with no _o_p_t_i_o_n_-_n_a_m_e, the values of the
|
||||
current options are printed. If ++oo is supplied with no
|
||||
_o_p_t_i_o_n_-_n_a_m_e, a series of sseett commands to recreate the
|
||||
current option settings is displayed on the standard
|
||||
current options are printed. If ++oo is supplied with no
|
||||
_o_p_t_i_o_n_-_n_a_m_e, a series of sseett commands to recreate the
|
||||
current option settings is displayed on the standard
|
||||
output.
|
||||
--pp Turn on _p_r_i_v_i_l_e_g_e_d mode. In this mode, the $$EENNVV and
|
||||
$$BBAASSHH__EENNVV files are not processed, shell functions are
|
||||
not inherited from the environment, and the SSHHEELLLLOOPPTTSS,
|
||||
BBAASSHHOOPPTTSS, CCDDPPAATTHH, and GGLLOOBBIIGGNNOORREE variables, if they ap-
|
||||
pear in the environment, are ignored. If the shell is
|
||||
started with the effective user (group) id not equal to
|
||||
the real user (group) id, and the --pp option is not sup-
|
||||
--pp Turn on _p_r_i_v_i_l_e_g_e_d mode. In this mode, the $$EENNVV and
|
||||
$$BBAASSHH__EENNVV files are not processed, shell functions are
|
||||
not inherited from the environment, and the SSHHEELLLLOOPPTTSS,
|
||||
BBAASSHHOOPPTTSS, CCDDPPAATTHH, and GGLLOOBBIIGGNNOORREE variables, if they ap-
|
||||
pear in the environment, are ignored. If the shell is
|
||||
started with the effective user (group) id not equal to
|
||||
the real user (group) id, and the --pp option is not sup-
|
||||
plied, these actions are taken and the effective user id
|
||||
is set to the real user id. If the --pp option is sup-
|
||||
plied at startup, the effective user id is not reset.
|
||||
Turning this option off causes the effective user and
|
||||
is set to the real user id. If the --pp option is sup-
|
||||
plied at startup, the effective user id is not reset.
|
||||
Turning this option off causes the effective user and
|
||||
group ids to be set to the real user and group ids.
|
||||
--rr Enable restricted shell mode. This option cannot be un-
|
||||
set once it has been set.
|
||||
--tt Exit after reading and executing one command.
|
||||
--uu Treat unset variables and parameters other than the spe-
|
||||
cial parameters "@" and "*", or array variables sub-
|
||||
scripted with "@" or "*", as an error when performing
|
||||
parameter expansion. If expansion is attempted on an
|
||||
unset variable or parameter, the shell prints an error
|
||||
message, and, if not interactive, exits with a non-zero
|
||||
cial parameters "@" and "*", or array variables sub-
|
||||
scripted with "@" or "*", as an error when performing
|
||||
parameter expansion. If expansion is attempted on an
|
||||
unset variable or parameter, the shell prints an error
|
||||
message, and, if not interactive, exits with a non-zero
|
||||
status.
|
||||
--vv Print shell input lines as they are read.
|
||||
--xx After expanding each _s_i_m_p_l_e _c_o_m_m_a_n_d, ffoorr command, ccaassee
|
||||
--xx After expanding each _s_i_m_p_l_e _c_o_m_m_a_n_d, ffoorr command, ccaassee
|
||||
command, sseelleecctt command, or arithmetic ffoorr command, dis-
|
||||
play the expanded value of PPSS44, followed by the command
|
||||
and its expanded arguments or associated word list.
|
||||
play the expanded value of PPSS44, followed by the command
|
||||
and its expanded arguments or associated word list, to
|
||||
standard error.
|
||||
--BB The shell performs brace expansion (see BBrraaccee EExxppaannssiioonn
|
||||
in _b_a_s_h_(_1_)). This is on by default.
|
||||
--CC If set, bbaasshh does not overwrite an existing file with
|
||||
@@ -1773,7 +1779,13 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
|
||||
displays the actions associated with each _s_i_g_s_p_e_c or, if none
|
||||
are supplied, for all trapped signals, as a set of ttrraapp commands
|
||||
that can be reused as shell input to restore the current signal
|
||||
dispositions.
|
||||
dispositions. The --PP option behaves similarly, but displays
|
||||
only the actions associated with each _s_i_g_s_p_e_c argument. --PP re-
|
||||
quires at least one _s_i_g_s_p_e_c argument. The --PP or --pp options to
|
||||
ttrraapp may be used in a subshell environment (e.g., command sub-
|
||||
stitution) and, as long as they are used before ttrraapp is used to
|
||||
change a signal's handling, will display the state of its par-
|
||||
ent's traps.
|
||||
|
||||
The --ll option causes ttrraapp to print a list of signal names and
|
||||
their corresponding numbers. Each _s_i_g_s_p_e_c is either a signal
|
||||
@@ -1816,50 +1828,53 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
|
||||
used as a command name. If the --tt option is used, ttyyppee prints a
|
||||
string which is one of _a_l_i_a_s, _k_e_y_w_o_r_d, _f_u_n_c_t_i_o_n, _b_u_i_l_t_i_n, or
|
||||
_f_i_l_e if _n_a_m_e is an alias, shell reserved word, function,
|
||||
builtin, or disk file, respectively. If the _n_a_m_e is not found,
|
||||
then nothing is printed, and an exit status of false is re-
|
||||
turned. If the --pp option is used, ttyyppee either returns the name
|
||||
of the disk file that would be executed if _n_a_m_e were specified
|
||||
as a command name, or nothing if ``type -t name'' would not re-
|
||||
turn _f_i_l_e. The --PP option forces a PPAATTHH search for each _n_a_m_e,
|
||||
even if ``type -t name'' would not return _f_i_l_e. If a command is
|
||||
hashed, --pp and --PP print the hashed value, which is not necessar-
|
||||
ily the file that appears first in PPAATTHH. If the --aa option is
|
||||
used, ttyyppee prints all of the places that contain an executable
|
||||
named _n_a_m_e. This includes aliases and functions, if and only if
|
||||
the --pp option is not also used. The table of hashed commands is
|
||||
not consulted when using --aa. The --ff option suppresses shell
|
||||
function lookup, as with the ccoommmmaanndd builtin. ttyyppee returns true
|
||||
if all of the arguments are found, false if any are not found.
|
||||
builtin, or executable disk file, respectively. If the _n_a_m_e is
|
||||
not found, then nothing is printed, and ttyyppee returns a non-zero
|
||||
exit status. If the --pp option is used, ttyyppee either returns the
|
||||
name of the executable file that would be found by searching
|
||||
$$PPAATTHH if _n_a_m_e were specified as a command name, or nothing if
|
||||
``type -t name'' would not return _f_i_l_e. The --PP option forces a
|
||||
PPAATTHH search for each _n_a_m_e, even if ``type -t name'' would not
|
||||
return _f_i_l_e. If a command is hashed, --pp and --PP print the hashed
|
||||
value, which is not necessarily the file that appears first in
|
||||
PPAATTHH. If the --aa option is used, ttyyppee prints all of the places
|
||||
that contain a command named _n_a_m_e. This includes aliases, re-
|
||||
served words, functions, and builtins, but the path search op-
|
||||
tions (--pp and --PP) can be supplied to restrict the output to exe-
|
||||
cutable files. ttyyppee does not consult the table of hashed com-
|
||||
mands when using --aa with --pp, and only performs a PPAATTHH search for
|
||||
_n_a_m_e. The --ff option suppresses shell function lookup, as with
|
||||
the ccoommmmaanndd builtin. ttyyppee returns true if all of the arguments
|
||||
are found, false if any are not found.
|
||||
|
||||
uulliimmiitt [--HHSS] --aa
|
||||
uulliimmiitt [--HHSS] [--bbccddeeffiikkllmmnnppqqrrssttuuvvxxPPRRTT [_l_i_m_i_t]]
|
||||
Provides control over the resources available to the shell and
|
||||
to processes started by it, on systems that allow such control.
|
||||
Provides control over the resources available to the shell and
|
||||
to processes started by it, on systems that allow such control.
|
||||
The --HH and --SS options specify that the hard or soft limit is set
|
||||
for the given resource. A hard limit cannot be increased by a
|
||||
non-root user once it is set; a soft limit may be increased up
|
||||
to the value of the hard limit. If neither --HH nor --SS is speci-
|
||||
for the given resource. A hard limit cannot be increased by a
|
||||
non-root user once it is set; a soft limit may be increased up
|
||||
to the value of the hard limit. If neither --HH nor --SS is speci-
|
||||
fied, both the soft and hard limits are set. The value of _l_i_m_i_t
|
||||
can be a number in the unit specified for the resource or one of
|
||||
the special values hhaarrdd, ssoofftt, or uunnlliimmiitteedd, which stand for the
|
||||
current hard limit, the current soft limit, and no limit, re-
|
||||
spectively. If _l_i_m_i_t is omitted, the current value of the soft
|
||||
current hard limit, the current soft limit, and no limit, re-
|
||||
spectively. If _l_i_m_i_t is omitted, the current value of the soft
|
||||
limit of the resource is printed, unless the --HH option is given.
|
||||
When more than one resource is specified, the limit name and
|
||||
unit, if appropriate, are printed before the value. Other op-
|
||||
When more than one resource is specified, the limit name and
|
||||
unit, if appropriate, are printed before the value. Other op-
|
||||
tions are interpreted as follows:
|
||||
--aa All current limits are reported; no limits are set
|
||||
--bb The maximum socket buffer size
|
||||
--cc The maximum size of core files created
|
||||
--dd The maximum size of a process's data segment
|
||||
--ee The maximum scheduling priority ("nice")
|
||||
--ff The maximum size of files written by the shell and its
|
||||
--ff The maximum size of files written by the shell and its
|
||||
children
|
||||
--ii The maximum number of pending signals
|
||||
--kk The maximum number of kqueues that may be allocated
|
||||
--ll The maximum size that may be locked into memory
|
||||
--mm The maximum resident set size (many systems do not honor
|
||||
--mm The maximum resident set size (many systems do not honor
|
||||
this limit)
|
||||
--nn The maximum number of open file descriptors (most systems
|
||||
do not allow this value to be set)
|
||||
@@ -1868,134 +1883,134 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
|
||||
--rr The maximum real-time scheduling priority
|
||||
--ss The maximum stack size
|
||||
--tt The maximum amount of cpu time in seconds
|
||||
--uu The maximum number of processes available to a single
|
||||
--uu The maximum number of processes available to a single
|
||||
user
|
||||
--vv The maximum amount of virtual memory available to the
|
||||
--vv The maximum amount of virtual memory available to the
|
||||
shell and, on some systems, to its children
|
||||
--xx The maximum number of file locks
|
||||
--PP The maximum number of pseudoterminals
|
||||
--RR The maximum time a real-time process can run before
|
||||
--RR The maximum time a real-time process can run before
|
||||
blocking, in microseconds
|
||||
--TT The maximum number of threads
|
||||
|
||||
If _l_i_m_i_t is given, and the --aa option is not used, _l_i_m_i_t is the
|
||||
new value of the specified resource. If no option is given,
|
||||
then --ff is assumed. Values are in 1024-byte increments, except
|
||||
for --tt, which is in seconds; --RR, which is in microseconds; --pp,
|
||||
which is in units of 512-byte blocks; --PP, --TT, --bb, --kk, --nn, and
|
||||
--uu, which are unscaled values; and, when in posix mode, --cc and
|
||||
--ff, which are in 512-byte increments. The return status is 0
|
||||
unless an invalid option or argument is supplied, or an error
|
||||
If _l_i_m_i_t is given, and the --aa option is not used, _l_i_m_i_t is the
|
||||
new value of the specified resource. If no option is given,
|
||||
then --ff is assumed. Values are in 1024-byte increments, except
|
||||
for --tt, which is in seconds; --RR, which is in microseconds; --pp,
|
||||
which is in units of 512-byte blocks; --PP, --TT, --bb, --kk, --nn, and
|
||||
--uu, which are unscaled values; and, when in posix mode, --cc and
|
||||
--ff, which are in 512-byte increments. The return status is 0
|
||||
unless an invalid option or argument is supplied, or an error
|
||||
occurs while setting a new limit.
|
||||
|
||||
uummaasskk [--pp] [--SS] [_m_o_d_e]
|
||||
The user file-creation mask is set to _m_o_d_e. If _m_o_d_e begins with
|
||||
a digit, it is interpreted as an octal number; otherwise it is
|
||||
interpreted as a symbolic mode mask similar to that accepted by
|
||||
_c_h_m_o_d(1). If _m_o_d_e is omitted, the current value of the mask is
|
||||
printed. The --SS option causes the mask to be printed in sym-
|
||||
bolic form; the default output is an octal number. If the --pp
|
||||
a digit, it is interpreted as an octal number; otherwise it is
|
||||
interpreted as a symbolic mode mask similar to that accepted by
|
||||
_c_h_m_o_d(1). If _m_o_d_e is omitted, the current value of the mask is
|
||||
printed. The --SS option causes the mask to be printed in sym-
|
||||
bolic form; the default output is an octal number. If the --pp
|
||||
option is supplied, and _m_o_d_e is omitted, the output is in a form
|
||||
that may be reused as input. The return status is 0 if the mode
|
||||
was successfully changed or if no _m_o_d_e argument was supplied,
|
||||
was successfully changed or if no _m_o_d_e argument was supplied,
|
||||
and false otherwise.
|
||||
|
||||
uunnaalliiaass [-aa] [_n_a_m_e ...]
|
||||
Remove each _n_a_m_e from the list of defined aliases. If --aa is
|
||||
supplied, all alias definitions are removed. The return value
|
||||
Remove each _n_a_m_e from the list of defined aliases. If --aa is
|
||||
supplied, all alias definitions are removed. The return value
|
||||
is true unless a supplied _n_a_m_e is not a defined alias.
|
||||
|
||||
uunnsseett [-ffvv] [-nn] [_n_a_m_e ...]
|
||||
For each _n_a_m_e, remove the corresponding variable or function.
|
||||
For each _n_a_m_e, remove the corresponding variable or function.
|
||||
If the --vv option is given, each _n_a_m_e refers to a shell variable,
|
||||
and that variable is removed. Read-only variables may not be
|
||||
unset. If --ff is specified, each _n_a_m_e refers to a shell func-
|
||||
tion, and the function definition is removed. If the --nn option
|
||||
is supplied, and _n_a_m_e is a variable with the _n_a_m_e_r_e_f attribute,
|
||||
_n_a_m_e will be unset rather than the variable it references. --nn
|
||||
has no effect if the --ff option is supplied. If no options are
|
||||
supplied, each _n_a_m_e refers to a variable; if there is no vari-
|
||||
able by that name, a function with that name, if any, is unset.
|
||||
Each unset variable or function is removed from the environment
|
||||
passed to subsequent commands. If any of BBAASSHH__AALLIIAASSEESS,
|
||||
and that variable is removed. Read-only variables may not be
|
||||
unset. If --ff is specified, each _n_a_m_e refers to a shell func-
|
||||
tion, and the function definition is removed. If the --nn option
|
||||
is supplied, and _n_a_m_e is a variable with the _n_a_m_e_r_e_f attribute,
|
||||
_n_a_m_e will be unset rather than the variable it references. --nn
|
||||
has no effect if the --ff option is supplied. If no options are
|
||||
supplied, each _n_a_m_e refers to a variable; if there is no vari-
|
||||
able by that name, a function with that name, if any, is unset.
|
||||
Each unset variable or function is removed from the environment
|
||||
passed to subsequent commands. If any of BBAASSHH__AALLIIAASSEESS,
|
||||
BBAASSHH__AARRGGVV00, BBAASSHH__CCMMDDSS, BBAASSHH__CCOOMMMMAANNDD, BBAASSHH__SSUUBBSSHHEELLLL, BBAASSHHPPIIDD,
|
||||
CCOOMMPP__WWOORRDDBBRREEAAKKSS, DDIIRRSSTTAACCKK, EEPPOOCCHHRREEAALLTTIIMMEE, EEPPOOCCHHSSEECCOONNDDSS, FFUUNNCC--
|
||||
NNAAMMEE, GGRROOUUPPSS, HHIISSTTCCMMDD, LLIINNEENNOO, RRAANNDDOOMM, SSEECCOONNDDSS, or SSRRAANNDDOOMM are
|
||||
CCOOMMPP__WWOORRDDBBRREEAAKKSS, DDIIRRSSTTAACCKK, EEPPOOCCHHRREEAALLTTIIMMEE, EEPPOOCCHHSSEECCOONNDDSS, FFUUNNCC--
|
||||
NNAAMMEE, GGRROOUUPPSS, HHIISSTTCCMMDD, LLIINNEENNOO, RRAANNDDOOMM, SSEECCOONNDDSS, or SSRRAANNDDOOMM are
|
||||
unset, they lose their special properties, even if they are sub-
|
||||
sequently reset. The exit status is true unless a _n_a_m_e is read-
|
||||
only or may not be unset.
|
||||
|
||||
wwaaiitt [--ffnn] [--pp _v_a_r_n_a_m_e] [_i_d _._._.]
|
||||
Wait for each specified child process and return its termination
|
||||
status. Each _i_d may be a process ID or a job specification; if
|
||||
a job spec is given, all processes in that job's pipeline are
|
||||
waited for. If _i_d is not given, wwaaiitt waits for all running
|
||||
background jobs and the last-executed process substitution, if
|
||||
status. Each _i_d may be a process ID or a job specification; if
|
||||
a job spec is given, all processes in that job's pipeline are
|
||||
waited for. If _i_d is not given, wwaaiitt waits for all running
|
||||
background jobs and the last-executed process substitution, if
|
||||
its process id is the same as $$!!, and the return status is zero.
|
||||
If the --nn option is supplied, wwaaiitt waits for a single job from
|
||||
If the --nn option is supplied, wwaaiitt waits for a single job from
|
||||
the list of _i_ds or, if no _i_ds are supplied, any job, to complete
|
||||
and returns its exit status. If none of the supplied arguments
|
||||
and returns its exit status. If none of the supplied arguments
|
||||
is a child of the shell, or if no arguments are supplied and the
|
||||
shell has no unwaited-for children, the exit status is 127. If
|
||||
the --pp option is supplied, the process or job identifier of the
|
||||
job for which the exit status is returned is assigned to the
|
||||
variable _v_a_r_n_a_m_e named by the option argument. The variable
|
||||
will be unset initially, before any assignment. This is useful
|
||||
only when the --nn option is supplied. Supplying the --ff option,
|
||||
when job control is enabled, forces wwaaiitt to wait for _i_d to ter-
|
||||
shell has no unwaited-for children, the exit status is 127. If
|
||||
the --pp option is supplied, the process or job identifier of the
|
||||
job for which the exit status is returned is assigned to the
|
||||
variable _v_a_r_n_a_m_e named by the option argument. The variable
|
||||
will be unset initially, before any assignment. This is useful
|
||||
only when the --nn option is supplied. Supplying the --ff option,
|
||||
when job control is enabled, forces wwaaiitt to wait for _i_d to ter-
|
||||
minate before returning its status, instead of returning when it
|
||||
changes status. If _i_d specifies a non-existent process or job,
|
||||
the return status is 127. If wwaaiitt is interrupted by a signal,
|
||||
the return status will be greater than 128, as described under
|
||||
SSIIGGNNAALLSS in _b_a_s_h_(_1_). Otherwise, the return status is the exit
|
||||
changes status. If _i_d specifies a non-existent process or job,
|
||||
the return status is 127. If wwaaiitt is interrupted by a signal,
|
||||
the return status will be greater than 128, as described under
|
||||
SSIIGGNNAALLSS in _b_a_s_h_(_1_). Otherwise, the return status is the exit
|
||||
status of the last process or job waited for.
|
||||
|
||||
SSHHEELLLL CCOOMMPPAATTIIBBIILLIITTYY MMOODDEE
|
||||
Bash-4.0 introduced the concept of a _s_h_e_l_l _c_o_m_p_a_t_i_b_i_l_i_t_y _l_e_v_e_l, speci-
|
||||
fied as a set of options to the shopt builtin ( ccoommppaatt3311, ccoommppaatt3322,
|
||||
ccoommppaatt4400, ccoommppaatt4411, and so on). There is only one current compatibil-
|
||||
ity level -- each option is mutually exclusive. The compatibility
|
||||
level is intended to allow users to select behavior from previous ver-
|
||||
sions that is incompatible with newer versions while they migrate
|
||||
scripts to use current features and behavior. It's intended to be a
|
||||
Bash-4.0 introduced the concept of a _s_h_e_l_l _c_o_m_p_a_t_i_b_i_l_i_t_y _l_e_v_e_l, speci-
|
||||
fied as a set of options to the shopt builtin ( ccoommppaatt3311, ccoommppaatt3322,
|
||||
ccoommppaatt4400, ccoommppaatt4411, and so on). There is only one current compatibil-
|
||||
ity level -- each option is mutually exclusive. The compatibility
|
||||
level is intended to allow users to select behavior from previous ver-
|
||||
sions that is incompatible with newer versions while they migrate
|
||||
scripts to use current features and behavior. It's intended to be a
|
||||
temporary solution.
|
||||
|
||||
This section does not mention behavior that is standard for a particu-
|
||||
lar version (e.g., setting ccoommppaatt3322 means that quoting the rhs of the
|
||||
regexp matching operator quotes special regexp characters in the word,
|
||||
This section does not mention behavior that is standard for a particu-
|
||||
lar version (e.g., setting ccoommppaatt3322 means that quoting the rhs of the
|
||||
regexp matching operator quotes special regexp characters in the word,
|
||||
which is default behavior in bash-3.2 and subsequent versions).
|
||||
|
||||
If a user enables, say, ccoommppaatt3322, it may affect the behavior of other
|
||||
compatibility levels up to and including the current compatibility
|
||||
level. The idea is that each compatibility level controls behavior
|
||||
that changed in that version of bbaasshh, but that behavior may have been
|
||||
present in earlier versions. For instance, the change to use locale-
|
||||
based comparisons with the [[[[ command came in bash-4.1, and earlier
|
||||
If a user enables, say, ccoommppaatt3322, it may affect the behavior of other
|
||||
compatibility levels up to and including the current compatibility
|
||||
level. The idea is that each compatibility level controls behavior
|
||||
that changed in that version of bbaasshh, but that behavior may have been
|
||||
present in earlier versions. For instance, the change to use locale-
|
||||
based comparisons with the [[[[ command came in bash-4.1, and earlier
|
||||
versions used ASCII-based comparisons, so enabling ccoommppaatt3322 will enable
|
||||
ASCII-based comparisons as well. That granularity may not be suffi-
|
||||
cient for all uses, and as a result users should employ compatibility
|
||||
levels carefully. Read the documentation for a particular feature to
|
||||
ASCII-based comparisons as well. That granularity may not be suffi-
|
||||
cient for all uses, and as a result users should employ compatibility
|
||||
levels carefully. Read the documentation for a particular feature to
|
||||
find out the current behavior.
|
||||
|
||||
Bash-4.3 introduced a new shell variable: BBAASSHH__CCOOMMPPAATT. The value as-
|
||||
Bash-4.3 introduced a new shell variable: BBAASSHH__CCOOMMPPAATT. The value as-
|
||||
signed to this variable (a decimal version number like 4.2, or an inte-
|
||||
ger corresponding to the ccoommppaatt_N_N option, like 42) determines the com-
|
||||
ger corresponding to the ccoommppaatt_N_N option, like 42) determines the com-
|
||||
patibility level.
|
||||
|
||||
Starting with bash-4.4, Bash has begun deprecating older compatibility
|
||||
levels. Eventually, the options will be removed in favor of BBAASSHH__CCOOMM--
|
||||
Starting with bash-4.4, Bash has begun deprecating older compatibility
|
||||
levels. Eventually, the options will be removed in favor of BBAASSHH__CCOOMM--
|
||||
PPAATT.
|
||||
|
||||
Bash-5.0 is the final version for which there will be an individual
|
||||
shopt option for the previous version. Users should use BBAASSHH__CCOOMMPPAATT on
|
||||
Bash-5.0 is the final version for which there will be an individual
|
||||
shopt option for the previous version. Users should use BBAASSHH__CCOOMMPPAATT on
|
||||
bash-5.0 and later versions.
|
||||
|
||||
The following table describes the behavior changes controlled by each
|
||||
The following table describes the behavior changes controlled by each
|
||||
compatibility level setting. The ccoommppaatt_N_N tag is used as shorthand for
|
||||
setting the compatibility level to _N_N using one of the following mecha-
|
||||
nisms. For versions prior to bash-5.0, the compatibility level may be
|
||||
set using the corresponding ccoommppaatt_N_N shopt option. For bash-4.3 and
|
||||
later versions, the BBAASSHH__CCOOMMPPAATT variable is preferred, and it is re-
|
||||
nisms. For versions prior to bash-5.0, the compatibility level may be
|
||||
set using the corresponding ccoommppaatt_N_N shopt option. For bash-4.3 and
|
||||
later versions, the BBAASSHH__CCOOMMPPAATT variable is preferred, and it is re-
|
||||
quired for bash-5.1 and later versions.
|
||||
|
||||
ccoommppaatt3311
|
||||
@@ -2003,85 +2018,85 @@ SSHHEELLLL CCOOMMPPAATTIIBBIILLIITTYY MMOODDEE
|
||||
ator (=~) has no special effect
|
||||
|
||||
ccoommppaatt3322
|
||||
+o interrupting a command list such as "a ; b ; c" causes
|
||||
the execution of the next command in the list (in
|
||||
bash-4.0 and later versions, the shell acts as if it re-
|
||||
ceived the interrupt, so interrupting one command in a
|
||||
+o interrupting a command list such as "a ; b ; c" causes
|
||||
the execution of the next command in the list (in
|
||||
bash-4.0 and later versions, the shell acts as if it re-
|
||||
ceived the interrupt, so interrupting one command in a
|
||||
list aborts the execution of the entire list)
|
||||
|
||||
ccoommppaatt4400
|
||||
+o the << and >> operators to the [[[[ command do not consider
|
||||
+o the << and >> operators to the [[[[ command do not consider
|
||||
the current locale when comparing strings; they use ASCII
|
||||
ordering. Bash versions prior to bash-4.1 use ASCII col-
|
||||
lation and _s_t_r_c_m_p(3); bash-4.1 and later use the current
|
||||
lation and _s_t_r_c_m_p(3); bash-4.1 and later use the current
|
||||
locale's collation sequence and _s_t_r_c_o_l_l(3).
|
||||
|
||||
ccoommppaatt4411
|
||||
+o in _p_o_s_i_x mode, ttiimmee may be followed by options and still
|
||||
+o in _p_o_s_i_x mode, ttiimmee may be followed by options and still
|
||||
be recognized as a reserved word (this is POSIX interpre-
|
||||
tation 267)
|
||||
+o in _p_o_s_i_x mode, the parser requires that an even number of
|
||||
single quotes occur in the _w_o_r_d portion of a double-
|
||||
quoted parameter expansion and treats them specially, so
|
||||
that characters within the single quotes are considered
|
||||
single quotes occur in the _w_o_r_d portion of a double-
|
||||
quoted parameter expansion and treats them specially, so
|
||||
that characters within the single quotes are considered
|
||||
quoted (this is POSIX interpretation 221)
|
||||
|
||||
ccoommppaatt4422
|
||||
+o the replacement string in double-quoted pattern substitu-
|
||||
tion does not undergo quote removal, as it does in ver-
|
||||
tion does not undergo quote removal, as it does in ver-
|
||||
sions after bash-4.2
|
||||
+o in posix mode, single quotes are considered special when
|
||||
expanding the _w_o_r_d portion of a double-quoted parameter
|
||||
expansion and can be used to quote a closing brace or
|
||||
other special character (this is part of POSIX interpre-
|
||||
tation 221); in later versions, single quotes are not
|
||||
+o in posix mode, single quotes are considered special when
|
||||
expanding the _w_o_r_d portion of a double-quoted parameter
|
||||
expansion and can be used to quote a closing brace or
|
||||
other special character (this is part of POSIX interpre-
|
||||
tation 221); in later versions, single quotes are not
|
||||
special within double-quoted word expansions
|
||||
|
||||
ccoommppaatt4433
|
||||
+o the shell does not print a warning message if an attempt
|
||||
is made to use a quoted compound assignment as an argu-
|
||||
ment to declare (e.g., declare -a foo='(1 2)'). Later
|
||||
+o the shell does not print a warning message if an attempt
|
||||
is made to use a quoted compound assignment as an argu-
|
||||
ment to declare (e.g., declare -a foo='(1 2)'). Later
|
||||
versions warn that this usage is deprecated
|
||||
+o word expansion errors are considered non-fatal errors
|
||||
that cause the current command to fail, even in posix
|
||||
mode (the default behavior is to make them fatal errors
|
||||
+o word expansion errors are considered non-fatal errors
|
||||
that cause the current command to fail, even in posix
|
||||
mode (the default behavior is to make them fatal errors
|
||||
that cause the shell to exit)
|
||||
+o when executing a shell function, the loop state
|
||||
+o when executing a shell function, the loop state
|
||||
(while/until/etc.) is not reset, so bbrreeaakk or ccoonnttiinnuuee in
|
||||
that function will break or continue loops in the calling
|
||||
context. Bash-4.4 and later reset the loop state to pre-
|
||||
context. Bash-4.4 and later reset the loop state to pre-
|
||||
vent this
|
||||
|
||||
ccoommppaatt4444
|
||||
+o the shell sets up the values used by BBAASSHH__AARRGGVV and
|
||||
BBAASSHH__AARRGGCC so they can expand to the shell's positional
|
||||
+o the shell sets up the values used by BBAASSHH__AARRGGVV and
|
||||
BBAASSHH__AARRGGCC so they can expand to the shell's positional
|
||||
parameters even if extended debugging mode is not enabled
|
||||
+o a subshell inherits loops from its parent context, so
|
||||
bbrreeaakk or ccoonnttiinnuuee will cause the subshell to exit.
|
||||
Bash-5.0 and later reset the loop state to prevent the
|
||||
+o a subshell inherits loops from its parent context, so
|
||||
bbrreeaakk or ccoonnttiinnuuee will cause the subshell to exit.
|
||||
Bash-5.0 and later reset the loop state to prevent the
|
||||
exit
|
||||
+o variable assignments preceding builtins like eexxppoorrtt and
|
||||
+o variable assignments preceding builtins like eexxppoorrtt and
|
||||
rreeaaddoonnllyy that set attributes continue to affect variables
|
||||
with the same name in the calling environment even if the
|
||||
shell is not in posix mode
|
||||
|
||||
ccoommppaatt5500
|
||||
+o Bash-5.1 changed the way $$RRAANNDDOOMM is generated to intro-
|
||||
+o Bash-5.1 changed the way $$RRAANNDDOOMM is generated to intro-
|
||||
duce slightly more randomness. If the shell compatibility
|
||||
level is set to 50 or lower, it reverts to the method
|
||||
from bash-5.0 and previous versions, so seeding the ran-
|
||||
dom number generator by assigning a value to RRAANNDDOOMM will
|
||||
level is set to 50 or lower, it reverts to the method
|
||||
from bash-5.0 and previous versions, so seeding the ran-
|
||||
dom number generator by assigning a value to RRAANNDDOOMM will
|
||||
produce the same sequence as in bash-5.0
|
||||
+o If the command hash table is empty, bash versions prior
|
||||
to bash-5.1 printed an informational message to that ef-
|
||||
fect, even when producing output that can be reused as
|
||||
input. Bash-5.1 suppresses that message when the --ll op-
|
||||
+o If the command hash table is empty, bash versions prior
|
||||
to bash-5.1 printed an informational message to that ef-
|
||||
fect, even when producing output that can be reused as
|
||||
input. Bash-5.1 suppresses that message when the --ll op-
|
||||
tion is supplied.
|
||||
|
||||
ccoommppaatt5511
|
||||
+o The uunnsseett builtin treats attempts to unset array sub-
|
||||
scripts @@ and ** differently depending on whether the ar-
|
||||
ray is indexed or associative, and differently than in
|
||||
+o The uunnsseett builtin treats attempts to unset array sub-
|
||||
scripts @@ and ** differently depending on whether the ar-
|
||||
ray is indexed or associative, and differently than in
|
||||
previous versions.
|
||||
|
||||
SSEEEE AALLSSOO
|
||||
@@ -2089,4 +2104,4 @@ SSEEEE AALLSSOO
|
||||
|
||||
|
||||
|
||||
GNU Bash 5.2 2021 November 22 BASH_BUILTINS(1)
|
||||
GNU Bash 5.2 2023 January 27 BASH_BUILTINS(1)
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
.de FN
|
||||
\fI\|\\$1\|\fP
|
||||
..
|
||||
.TH BASH_BUILTINS 1 "2021 November 22" "GNU Bash 5.2"
|
||||
.TH BASH_BUILTINS 1 "2023 January 27" "GNU Bash 5.2"
|
||||
.SH NAME
|
||||
:, ., [, alias, bg, bind, break, builtin, caller,
|
||||
cd, command, compgen, complete, compopt,
|
||||
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
@ignore
|
||||
Copyright (C) 1988-2022 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-2023 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set LASTCHANGE Tue Dec 27 16:12:26 EST 2022
|
||||
@set LASTCHANGE Fri Jan 27 15:17:14 EST 2023
|
||||
|
||||
@set EDITION 5.2
|
||||
@set VERSION 5.2
|
||||
|
||||
@set UPDATED 27 December 2022
|
||||
@set UPDATED-MONTH December 2022
|
||||
@set UPDATED 27 January 2023
|
||||
@set UPDATED-MONTH January 2023
|
||||
|
||||
@@ -403,6 +403,21 @@ legal_alias_name (const char *string, int flags)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Return 1 if this is a valid identifer that can be used to declare a function
|
||||
without the `function' reserved word. FLAGS is currently unused; a
|
||||
placeholder for the future. */
|
||||
int
|
||||
valid_function_name (const char *name, int flags)
|
||||
{
|
||||
if (find_reserved_word (name) >= 0)
|
||||
return 0;
|
||||
if (posixly_correct && (all_digits (name) || legal_identifier (name) == 0))
|
||||
return 0;
|
||||
if (assignment (name, 0)) /* difference between WORD and ASSIGNMENT_WORD */
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Returns non-zero if STRING is an assignment statement. The returned value
|
||||
is the index of the `=' sign. If FLAGS&1 we are expecting a compound assignment
|
||||
and require an array subscript before the `=' to denote an assignment
|
||||
|
||||
@@ -321,6 +321,7 @@ extern int check_identifier (WORD_DESC *, int);
|
||||
extern int valid_nameref_value (const char *, int);
|
||||
extern int check_selfref (const char *, char *, int);
|
||||
extern int legal_alias_name (const char *, int);
|
||||
extern int valid_function_name (const char *, int);
|
||||
extern int line_isblank (const char *);
|
||||
extern int assignment (const char *, int);
|
||||
|
||||
|
||||
+39
-2
@@ -630,10 +630,10 @@ history_truncate_file (const char *fname, int lines)
|
||||
if (write (file, bp, chars_read - (bp - buffer)) < 0)
|
||||
rv = errno;
|
||||
|
||||
if (fstat (file, &nfinfo) < 0 && rv == 0)
|
||||
if (rv == 0 && fstat (file, &nfinfo) < 0)
|
||||
rv = errno;
|
||||
|
||||
if (close (file) < 0 && rv == 0)
|
||||
if (rv == 0 && close (file) < 0)
|
||||
rv = errno;
|
||||
}
|
||||
else
|
||||
@@ -670,6 +670,38 @@ history_truncate_file (const char *fname, int lines)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Use stdio to write the history file after mmap or malloc fails, on the
|
||||
assumption that the stdio library can allocate the smaller buffers it uses. */
|
||||
static int
|
||||
history_write_slow (int fd, HIST_ENTRY **the_history, int nelements, int overwrite)
|
||||
{
|
||||
FILE *fp;
|
||||
int i, j, e;
|
||||
|
||||
fp = fdopen (fd, overwrite ? "w" : "a");
|
||||
if (fp == 0)
|
||||
return -1;
|
||||
|
||||
for (j = 0, i = history_length - nelements; i < history_length; i++)
|
||||
{
|
||||
if (history_write_timestamps && the_history[i]->timestamp && the_history[i]->timestamp[0])
|
||||
fprintf (fp, "%s\n", the_history[i]->timestamp);
|
||||
if (fprintf (fp, "%s\n", the_history[i]->line) < 0)
|
||||
goto slow_write_error;
|
||||
}
|
||||
if (fflush (fp) < 0)
|
||||
{
|
||||
slow_write_error:
|
||||
e = errno;
|
||||
fclose (fp);
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
if (fclose (fp) < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Workhorse function for writing history. Writes the last NELEMENT entries
|
||||
from the history list to FILENAME. OVERWRITE is non-zero if you
|
||||
wish to replace FILENAME with the entries. */
|
||||
@@ -738,6 +770,8 @@ history_do_write (const char *filename, int nelements, int overwrite)
|
||||
if ((void *)buffer == MAP_FAILED)
|
||||
{
|
||||
mmap_error:
|
||||
if ((rv = history_write_slow (file, the_history, nelements, overwrite)) == 0)
|
||||
goto write_success;
|
||||
rv = errno;
|
||||
close (file);
|
||||
if (tempname)
|
||||
@@ -750,6 +784,8 @@ mmap_error:
|
||||
buffer = (char *)malloc (buffer_size);
|
||||
if (buffer == 0)
|
||||
{
|
||||
if ((rv = history_write_slow (file, the_history, nelements, overwrite)) == 0)
|
||||
goto write_success;
|
||||
rv = errno;
|
||||
close (file);
|
||||
if (tempname)
|
||||
@@ -788,6 +824,7 @@ mmap_error:
|
||||
if (close (file) < 0 && rv == 0)
|
||||
rv = errno;
|
||||
|
||||
write_success:
|
||||
if (rv == 0 && histname && tempname)
|
||||
rv = histfile_restore (tempname, histname);
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ typedef void *alias_t;
|
||||
# define MBTEST(x) ((x))
|
||||
#endif
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
#define EXTEND_SHELL_INPUT_LINE_PROPERTY() \
|
||||
do { \
|
||||
if (shell_input_line_len + 2 > shell_input_line_propsize) \
|
||||
@@ -128,6 +129,9 @@ do { \
|
||||
shell_input_line_propsize); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define EXTEND_SHELL_INPUT_LINE_PROPERTY()
|
||||
#endif
|
||||
|
||||
#if defined (EXTENDED_GLOB)
|
||||
extern int extended_glob, extglob_flag;
|
||||
@@ -2631,6 +2635,7 @@ next_alias_char:
|
||||
parser_state |= PST_ENDALIAS;
|
||||
/* We need to do this to make sure last_shell_getc_is_singlebyte returns
|
||||
true, since we are returning a single-byte space. */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (shell_input_line_index == shell_input_line_len && last_shell_getc_is_singlebyte == 0)
|
||||
{
|
||||
#if 0
|
||||
@@ -2644,6 +2649,7 @@ next_alias_char:
|
||||
shell_input_line_property[shell_input_line_index - 1] = 1;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return ' '; /* END_ALIAS */
|
||||
}
|
||||
#endif
|
||||
@@ -3390,6 +3396,7 @@ read_token (int command)
|
||||
#if defined (COND_COMMAND)
|
||||
if ((parser_state & (PST_CONDCMD|PST_CONDEXPR)) == PST_CONDCMD)
|
||||
{
|
||||
parser_state &= ~PST_CMDBLTIN;
|
||||
cond_lineno = line_number;
|
||||
parser_state |= PST_CONDEXPR;
|
||||
yylval.command = parse_cond_command ();
|
||||
@@ -3451,6 +3458,7 @@ read_token (int command)
|
||||
#endif /* ALIAS */
|
||||
|
||||
parser_state &= ~PST_ASSIGNOK;
|
||||
parser_state &= ~PST_CMDBLTIN;
|
||||
|
||||
return (character);
|
||||
}
|
||||
@@ -3468,6 +3476,7 @@ read_token (int command)
|
||||
#endif /* ALIAS */
|
||||
|
||||
parser_state &= ~PST_ASSIGNOK;
|
||||
parser_state &= ~PST_CMDBLTIN;
|
||||
|
||||
/* If we are parsing a command substitution and we have read a character
|
||||
that marks the end of it, don't bother to skip over quoted newlines
|
||||
@@ -3588,7 +3597,10 @@ read_token (int command)
|
||||
|
||||
/* Hack <&- (close stdin) case. Also <&N- (dup and close). */
|
||||
if MBTEST(character == '-' && (last_read_token == LESS_AND || last_read_token == GREATER_AND))
|
||||
return (character);
|
||||
{
|
||||
parser_state &= ~PST_CMDBLTIN;
|
||||
return (character);
|
||||
}
|
||||
|
||||
tokword:
|
||||
/* Okay, if we got this far, we have to read a word. Read one,
|
||||
@@ -4192,6 +4204,11 @@ dump_pflags (int flags)
|
||||
f &= ~PST_STRING;
|
||||
fprintf (stderr, "PST_STRING%s", f ? "|" : "");
|
||||
}
|
||||
if (f & PST_CMDBLTIN)
|
||||
{
|
||||
f &= ~PST_CMDBLTIN;
|
||||
fprintf (stderr, "PST_CMDBLTIN%s", f ? "|" : "");
|
||||
}
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
fflush (stderr);
|
||||
@@ -5408,7 +5425,7 @@ got_token:
|
||||
}
|
||||
}
|
||||
|
||||
if (command_token_position (last_read_token))
|
||||
if (command_token_position (last_read_token) || (parser_state & PST_CMDBLTIN))
|
||||
{
|
||||
struct builtin *b;
|
||||
b = builtin_address_internal (token, 0);
|
||||
@@ -5416,7 +5433,18 @@ got_token:
|
||||
parser_state |= PST_ASSIGNOK;
|
||||
else if (STREQ (token, "eval") || STREQ (token, "let"))
|
||||
parser_state |= PST_ASSIGNOK;
|
||||
/* If we don't want to allow multiple instances of `command' to act as
|
||||
declaration utilities as long as the last one is followed by a
|
||||
declaration utility, add back a check for command_token_position.
|
||||
subst.c:fix_assignment_words allows multiple instances of "command"
|
||||
but I don't think that POSIX requires this. */
|
||||
else if (posixly_correct && STREQ (token, "command"))
|
||||
parser_state |= PST_CMDBLTIN;
|
||||
else
|
||||
parser_state &= ~PST_CMDBLTIN;
|
||||
}
|
||||
else
|
||||
parser_state &= ~PST_CMDBLTIN;
|
||||
|
||||
yylval.word = the_word;
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#define PST_NOEXPAND 0x400000 /* don't expand anything in read_token_word; for command substitution */
|
||||
#define PST_NOERROR 0x800000 /* don't print error messages in yyerror */
|
||||
#define PST_STRING 0x1000000 /* parsing a string to a command or word list */
|
||||
#define PST_CMDBLTIN 0x2000000 /* last token was the `command' builtin */
|
||||
|
||||
/* Definition of the delimiter stack. Needed by parse.y and bashhist.c. */
|
||||
struct dstack {
|
||||
|
||||
+14
-19
@@ -1261,9 +1261,12 @@ print_function_def (FUNCTION_DEF *func)
|
||||
REDIRECT *func_redirects;
|
||||
|
||||
func_redirects = NULL;
|
||||
/* When in posix mode, print functions as posix specifies them. */
|
||||
/* When in posix mode, print functions as posix specifies them, but prefix
|
||||
`function' to words that are not valid POSIX identifiers. */
|
||||
if (posixly_correct == 0)
|
||||
cprintf ("function %s () \n", func->name->word);
|
||||
else if (valid_function_name (func->name->word, 0) == 0)
|
||||
cprintf ("function %s () \n", func->name->word);
|
||||
else
|
||||
cprintf ("%s () \n", func->name->word);
|
||||
add_unwind_protect (reset_locals, 0);
|
||||
@@ -1274,7 +1277,8 @@ print_function_def (FUNCTION_DEF *func)
|
||||
inside_function_def++;
|
||||
indentation += indentation_amount;
|
||||
|
||||
cmdcopy = copy_command (func->command);
|
||||
cmdcopy = func->command;
|
||||
unwind_protect_pointer (cmdcopy);
|
||||
if (cmdcopy->type == cm_group)
|
||||
{
|
||||
func_redirects = cmdcopy->redirects;
|
||||
@@ -1285,7 +1289,6 @@ print_function_def (FUNCTION_DEF *func)
|
||||
: cmdcopy);
|
||||
PRINT_DEFERRED_HEREDOCS ("");
|
||||
|
||||
remove_unwind_protect ();
|
||||
indentation -= indentation_amount;
|
||||
inside_function_def--;
|
||||
|
||||
@@ -1302,7 +1305,8 @@ print_function_def (FUNCTION_DEF *func)
|
||||
was_heredoc = 0; /* not printing any here-documents now */
|
||||
}
|
||||
|
||||
dispose_command (cmdcopy);
|
||||
remove_unwind_protect (); /* unwind_protect_pointer */
|
||||
remove_unwind_protect (); /* reset_locals */
|
||||
}
|
||||
|
||||
/* Return the string representation of the named function.
|
||||
@@ -1327,7 +1331,7 @@ named_function_string (char *name, COMMAND *command, int flags)
|
||||
|
||||
if (name && *name)
|
||||
{
|
||||
if (find_reserved_word (name) >= 0) /* check valid identifier too? */
|
||||
if (valid_function_name (name, 0) == 0)
|
||||
cprintf ("function ");
|
||||
cprintf ("%s ", name);
|
||||
}
|
||||
@@ -1349,7 +1353,9 @@ named_function_string (char *name, COMMAND *command, int flags)
|
||||
|
||||
cprintf ((flags & FUNC_MULTILINE) ? "{ \n" : "{ "); /* }} */
|
||||
|
||||
cmdcopy = copy_command (command);
|
||||
cmdcopy = command;
|
||||
unwind_protect_pointer (cmdcopy);
|
||||
|
||||
/* Take any redirections specified in the function definition (which should
|
||||
apply to the function as a whole) and save them for printing later. */
|
||||
func_redirects = (REDIRECT *)NULL;
|
||||
@@ -1379,26 +1385,15 @@ named_function_string (char *name, COMMAND *command, int flags)
|
||||
was_heredoc = 0;
|
||||
}
|
||||
|
||||
remove_unwind_protect (); /* unwind_protect_pointer */
|
||||
result = the_printed_command;
|
||||
|
||||
if ((flags & FUNC_MULTILINE) == 0)
|
||||
{
|
||||
#if 0
|
||||
register int i;
|
||||
for (i = 0; result[i]; i++)
|
||||
if (result[i] == '\n')
|
||||
{
|
||||
strcpy (result + i, result + i + 1);
|
||||
--i;
|
||||
}
|
||||
#else
|
||||
if (result[2] == '\n') /* XXX -- experimental */
|
||||
if (result[2] == '\n')
|
||||
memmove (result + 2, result + 3, strlen (result) - 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
dispose_command (cmdcopy);
|
||||
|
||||
if (flags & FUNC_EXTERNAL)
|
||||
result = remove_quoted_escapes (result);
|
||||
|
||||
|
||||
@@ -780,7 +780,7 @@ string_extract (const char *string, int *sindex, const char *charlist, int flags
|
||||
char *temp;
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
slen = (MB_CUR_MAX > 1) ? strlen (string + *sindex) + *sindex : 0;
|
||||
slen = (locale_mb_cur_max > 1) ? strlen (string + *sindex) + *sindex : 0;
|
||||
i = *sindex;
|
||||
found = 0;
|
||||
while (c = string[i])
|
||||
@@ -1074,7 +1074,7 @@ string_extract_single_quoted (const char *string, int *sindex, int allowesc)
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
/* Don't need slen for ADVANCE_CHAR unless multibyte chars possible. */
|
||||
slen = (MB_CUR_MAX > 1) ? strlen (string + *sindex) + *sindex : 0;
|
||||
slen = (locale_mb_cur_max > 1) ? strlen (string + *sindex) + *sindex : 0;
|
||||
i = *sindex;
|
||||
pass_next = 0;
|
||||
while (string[i])
|
||||
@@ -2842,7 +2842,7 @@ string_list_dollar_star (WORD_LIST *list, int quoted, int flags)
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
# if !defined (__GNUC__)
|
||||
sep = (char *)xmalloc (MB_CUR_MAX + 1);
|
||||
sep = (char *)xmalloc (locale_mb_cur_max + 1);
|
||||
# endif /* !__GNUC__ */
|
||||
if (ifs_firstc_len == 1)
|
||||
{
|
||||
@@ -2901,7 +2901,7 @@ string_list_dollar_at (WORD_LIST *list, int quoted, int flags)
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
# if !defined (__GNUC__)
|
||||
sep = (char *)xmalloc (MB_CUR_MAX + 1);
|
||||
sep = (char *)xmalloc (locale_mb_cur_max + 1);
|
||||
# endif /* !__GNUC__ */
|
||||
/* XXX - testing PF_ASSIGNRHS to make sure positional parameters are
|
||||
separated with a space even when word splitting will not occur. */
|
||||
@@ -3744,7 +3744,7 @@ expand_string_if_necessary (char *string, int quoted, EXPFUNC *func)
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
/* Don't need string length for ADVANCE_CHAR unless multibyte chars possible. */
|
||||
slen = (MB_CUR_MAX > 1) ? strlen (string) : 0;
|
||||
slen = (locale_mb_cur_max > 1) ? strlen (string) : 0;
|
||||
i = saw_quote = 0;
|
||||
while (string[i])
|
||||
{
|
||||
@@ -3918,7 +3918,7 @@ expand_arith_string (char *string, int quoted)
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
/* Don't need string length for ADVANCE_CHAR unless multibyte chars possible. */
|
||||
slen = (MB_CUR_MAX > 1) ? strlen (string) : 0;
|
||||
slen = (locale_mb_cur_max > 1) ? strlen (string) : 0;
|
||||
i = saw_quote = 0;
|
||||
while (string[i])
|
||||
{
|
||||
@@ -5137,7 +5137,7 @@ remove_pattern (char *param, char *pattern, int op)
|
||||
return (savestring (param));
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1)
|
||||
if (locale_mb_cur_max > 1)
|
||||
{
|
||||
wchar_t *ret, *oret;
|
||||
size_t n;
|
||||
@@ -5505,7 +5505,7 @@ match_pattern (char *string, char *pat, int mtype, char **sp, char **ep)
|
||||
return (0);
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1)
|
||||
if (locale_mb_cur_max > 1)
|
||||
{
|
||||
if (mbsmbchar (string) == 0 && mbsmbchar (pat) == 0)
|
||||
return (match_upattern (string, pat, mtype, sp, ep));
|
||||
@@ -6567,7 +6567,6 @@ read_comsub (int fd, int quoted, int flags, int *rflag)
|
||||
{
|
||||
char *istring, buf[COMSUB_PIPEBUF], *bufp;
|
||||
int c, tflag, skip_ctlesc, skip_ctlnul;
|
||||
int mb_cur_max;
|
||||
size_t istring_index;
|
||||
size_t istring_size;
|
||||
ssize_t bufn;
|
||||
@@ -6586,7 +6585,6 @@ read_comsub (int fd, int quoted, int flags, int *rflag)
|
||||
skip_ctlesc = ifs_cmap[CTLESC];
|
||||
skip_ctlnul = ifs_cmap[CTLNUL];
|
||||
|
||||
mb_cur_max = MB_CUR_MAX;
|
||||
nullbyte = 0;
|
||||
|
||||
/* Read the output of the command through the pipe. */
|
||||
@@ -6616,7 +6614,7 @@ read_comsub (int fd, int quoted, int flags, int *rflag)
|
||||
}
|
||||
|
||||
/* Add the character to ISTRING, possibly after resizing it. */
|
||||
RESIZE_MALLOCED_BUFFER (istring, istring_index, mb_cur_max+1, istring_size, 512);
|
||||
RESIZE_MALLOCED_BUFFER (istring, istring_index, locale_mb_cur_max+1, istring_size, 512);
|
||||
|
||||
/* This is essentially quote_string inline */
|
||||
if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) /* || c == CTLESC || c == CTLNUL */)
|
||||
@@ -6633,7 +6631,7 @@ read_comsub (int fd, int quoted, int flags, int *rflag)
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if ((locale_utf8locale && (c & 0x80)) ||
|
||||
(locale_utf8locale == 0 && mb_cur_max > 1 && (unsigned char)c > 127))
|
||||
(locale_utf8locale == 0 && locale_mb_cur_max > 1 && (unsigned char)c > 127))
|
||||
{
|
||||
/* read a multibyte character from buf */
|
||||
/* punt on the hard case for now */
|
||||
@@ -8510,7 +8508,7 @@ mb_substring (const char *string, int s, int e)
|
||||
|
||||
start = 0;
|
||||
/* Don't need string length in ADVANCE_CHAR unless multibyte chars possible. */
|
||||
slen = (MB_CUR_MAX > 1) ? STRLEN (string) : 0;
|
||||
slen = (locale_mb_cur_max > 1) ? STRLEN (string) : 0;
|
||||
|
||||
i = s;
|
||||
while (string[start] && i--)
|
||||
@@ -8567,7 +8565,7 @@ parameter_brace_substring (char *varname, char *value, array_eltstate_t *estatep
|
||||
case VT_VARIABLE:
|
||||
case VT_ARRAYMEMBER:
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1)
|
||||
if (locale_mb_cur_max > 1)
|
||||
tt = mb_substring (val, e1, e2);
|
||||
else
|
||||
#endif
|
||||
@@ -10683,7 +10681,6 @@ expand_word_internal (WORD_DESC *word, int quoted, int isexp, int *contains_doll
|
||||
int local_expanded;
|
||||
int tflag;
|
||||
int pflags; /* flags passed to param_expand */
|
||||
int mb_cur_max;
|
||||
|
||||
int assignoff; /* If assignment, offset of `=' */
|
||||
|
||||
@@ -10724,11 +10721,10 @@ expand_word_internal (WORD_DESC *word, int quoted, int isexp, int *contains_doll
|
||||
string = word->word;
|
||||
if (string == 0)
|
||||
goto finished_with_string;
|
||||
mb_cur_max = MB_CUR_MAX;
|
||||
|
||||
/* Don't need the string length for the SADD... and COPY_ macros unless
|
||||
multibyte characters are possible, but do need it for bounds checking. */
|
||||
string_size = (mb_cur_max > 1) ? strlen (string) : 1;
|
||||
string_size = (locale_mb_cur_max > 1) ? strlen (string) : 1;
|
||||
|
||||
if (contains_dollar_at)
|
||||
*contains_dollar_at = 0;
|
||||
@@ -10750,7 +10746,7 @@ expand_word_internal (WORD_DESC *word, int quoted, int isexp, int *contains_doll
|
||||
case CTLESC:
|
||||
sindex++;
|
||||
#if HANDLE_MULTIBYTE
|
||||
if (mb_cur_max > 1 && string[sindex])
|
||||
if (locale_mb_cur_max > 1 && string[sindex])
|
||||
{
|
||||
SADD_MBQCHAR_BODY(temp, string, sindex, string_size);
|
||||
}
|
||||
@@ -11367,10 +11363,10 @@ add_quoted_character:
|
||||
#if HANDLE_MULTIBYTE
|
||||
/* XXX - should make sure that c is actually multibyte,
|
||||
otherwise we can use the twochars branch */
|
||||
if (mb_cur_max > 1)
|
||||
if (locale_mb_cur_max > 1)
|
||||
sindex--;
|
||||
|
||||
if (mb_cur_max > 1)
|
||||
if (locale_mb_cur_max > 1)
|
||||
{
|
||||
SADD_MBQCHAR_BODY(temp, string, sindex, string_size);
|
||||
}
|
||||
@@ -11739,7 +11735,7 @@ setifs (SHELL_VAR *v)
|
||||
{
|
||||
size_t ifs_len;
|
||||
DECLARE_MBSTATE;
|
||||
ifs_len = strnlen (ifs_value, MB_CUR_MAX);
|
||||
ifs_len = strnlen (ifs_value, locale_mb_cur_max);
|
||||
ifs_firstc_len = MBRLEN (ifs_value, ifs_len, &state);
|
||||
}
|
||||
if (ifs_firstc_len == 1 || ifs_firstc_len == 0 || MB_INVALIDCH (ifs_firstc_len))
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ command: usage: command [-pVv] command [arg ...]
|
||||
./errors.tests: line 231: /bin/sh + 0: arithmetic syntax error: operand expected (error token is "/bin/sh + 0")
|
||||
./errors.tests: line 234: trap: NOSIG: invalid signal specification
|
||||
./errors.tests: line 237: trap: -s: invalid option
|
||||
trap: usage: trap [-lp] [[action] signal_spec ...]
|
||||
trap: usage: trap [-Plp] [[action] signal_spec ...]
|
||||
./errors.tests: line 243: return: can only `return' from a function or sourced script
|
||||
./errors.tests: line 247: break: 0: loop count out of range
|
||||
./errors.tests: line 251: continue: 0: loop count out of range
|
||||
|
||||
Reference in New Issue
Block a user