changes to quoting for some globbing characters; regularize error behavior of builtins that take numeric arguments and complain about too many arguments

This commit is contained in:
Chet Ramey
2023-10-11 11:40:08 -04:00
parent 09c32bc946
commit 7a698806d1
31 changed files with 4563 additions and 4369 deletions
+47
View File
@@ -7778,3 +7778,50 @@ builtins/read.def
we need to free ifs_chars and free it before returning.
Reported by Robert Elz <kre@munnari.OZ.AU> in
https://www.austingroupbugs.net/view.php?id=1778#c6513
10/7
----
pathexp.c
- glob_char_p: add more of the extglob pattern characters; it doesn't
hurt to quote them
Report and patch from Grisha Levit <grishalevit@gmail.com>
- unquoted_glob_pattern_p: don't treat a `(' immediately following a
`/' as a potential globbing character
- unquoted_glob_pattern_p: only treat the extended glob characters
followed by a `(' as a glob pattern if extended_glob is enabled
- unquoted_glob_pattern_p: an unquoted backslash isn't treated
specially any more, but if it's followed by a CTLESC, you still
don't treat the next character as an unquoted globbing char
Report and patch from Grisha Levit <grishalevit@gmail.com>
10/9
----
builtins/common.c
- get_numeric_arg: if fatal > 0, set the exit status to EX_USAGE
and call jump_to_top_level with EXITPROG or DISCARD. We don't
need to do everything that throw_to_top_level() does here (it's
really meant for signals and other exceptional failure conditions).
builtins/cd.def
- cd_builtin: exit with EX_USAGE on too many arguments
builtins/shift.def
- shift_builtin: return EX_USAGE if get_numeric_arg returns 0,
indicating that the argument wasn't a valid number
builtins/history.def
- shift_builtin: return EX_USAGE if get_numeric_arg returns 0
builtins/exit.def
- exit_or_logout: if get_exitstat (which calls get_numeric_arg) returns
a value > EX_SHERRBASE, indicating an error, just return that to
the caller and let the caller deal with it. This means that
`exit xyz' is no longer a fatal error, but can potentially cause a
non-interactive posix-mode shell to exit because exit is a special
builtin
builtins/return.def
- return_builtin: if a non-interactive shell in posix mode gets an
invalid numeric arg from get_exitstat, return immediately and let
the caller deal with exiting
All prompted by a report by Martin Schulte <gnu@schrader-schulte.de>
+1
View File
@@ -1141,6 +1141,7 @@ tests/errors6.sub f
tests/errors7.sub f
tests/errors8.sub f
tests/errors9.sub f
tests/errors10.sub f
tests/execscript f
tests/exec.right f
tests/exec1.sub f 755
+4 -2
View File
@@ -69,7 +69,8 @@ break_builtin (WORD_LIST *list)
if (check_loop_level () == 0)
return (EXECUTION_SUCCESS);
(void)get_numeric_arg (list, 1, &newbreak);
/* This will not return if an error is encountered. */
(void)get_numeric_arg (list, interactive_shell ? 2 : 1, &newbreak);
if (newbreak <= 0)
{
@@ -113,7 +114,8 @@ continue_builtin (WORD_LIST *list)
if (check_loop_level () == 0)
return (EXECUTION_SUCCESS);
(void)get_numeric_arg (list, 1, &newcont);
/* This will not return if an error is encountered. */
(void)get_numeric_arg (list, interactive_shell ? 2 : 1, &newcont);
if (newcont <= 0)
{
+1 -1
View File
@@ -327,7 +327,7 @@ cd_builtin (WORD_LIST *list)
else if (list->next)
{
builtin_error (_("too many arguments"));
return (EXECUTION_FAILURE);
return (EX_USAGE);
}
#endif
#if 0
+14 -12
View File
@@ -136,13 +136,18 @@ builtin_usage (void)
/* Return if LIST is NULL else barf and jump to top_level. Used by some
builtins that do not accept arguments. */
void
no_args (WORD_LIST *list)
no_args (WORD_LIST *list, int fatal)
{
if (list)
{
builtin_error (_("too many arguments"));
top_level_cleanup ();
jump_to_top_level (DISCARD);
set_exit_status (EX_BADUSAGE);
/* for now, the caller determines whether this is a fatal error */
if (interactive_shell == 0 && fatal)
jump_to_top_level (EXITPROG);
else
jump_to_top_level (DISCARD);
}
}
@@ -491,15 +496,12 @@ get_numeric_arg (WORD_LIST *list, int fatal, intmax_t *count)
sh_neednumarg (list->word->word ? list->word->word : "`'");
if (fatal == 0)
return 0;
else if (fatal == 1) /* fatal == 1; abort */
throw_to_top_level ();
else /* fatal == 2; discard current command */
{
top_level_cleanup ();
jump_to_top_level (DISCARD);
}
set_exit_status (EX_BADUSAGE);
/* fatal == 1: abort; fatal == 2: discard current command */
top_level_cleanup ();
jump_to_top_level ((fatal == 1) ? EXITPROG : DISCARD);
}
no_args (list->next);
no_args (list->next, 0);
}
return (1);
@@ -536,9 +538,9 @@ get_exitstat (WORD_LIST *list)
if (arg == 0 || legal_number (arg, &sval) == 0)
{
sh_neednumarg (list->word->word ? list->word->word : "`'");
return EX_BADUSAGE;
return EX_USAGE;
}
no_args (list->next);
no_args (list->next, 0);
status = sval & 255;
return status;
+1 -1
View File
@@ -84,7 +84,7 @@ do { \
extern void builtin_error (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
extern void builtin_warning (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
extern void builtin_usage (void);
extern void no_args (WORD_LIST *);
extern void no_args (WORD_LIST *, int);
extern int no_options (WORD_LIST *);
/* common error message functions */
+3 -1
View File
@@ -1,7 +1,7 @@
This file is exit.def, from which is created exit.c.
It implements the builtins "exit", and "logout" 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.
@@ -140,6 +140,8 @@ exit_or_logout (WORD_LIST *list)
(list == 0), use the exit status we saved before running the trap
commands (trap_saved_exit_value). */
exit_value = (running_trap == 1 && list == 0) ? trap_saved_exit_value : get_exitstat (list);
if (exit_value > EX_SHERRBASE) /* some kind of error */
return (exit_value);
bash_logout ();
+1 -1
View File
@@ -362,7 +362,7 @@ display_history (WORD_LIST *list)
if (list)
{
if (get_numeric_arg (list, 0, &limit) == 0)
return (EXECUTION_FAILURE);
return (EX_USAGE);
if (limit < 0)
limit = -limit;
+7 -1
View File
@@ -1,7 +1,7 @@
This file is return.def, from which is created return.c.
It implements the builtin "return" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -59,6 +59,12 @@ return_builtin (WORD_LIST *list)
CHECK_HELPOPT (list);
return_catch_value = get_exitstat (list);
/* return is a special builtin, so non-interactive shells in posix mode
exit on an invalid numeric argument. We have to do it this way because
the return_catch targets aren't set up to deal with EXITSHELL, so we
just jump_to_top_level directly. */
if (interactive_shell == 0 && posixly_correct && executing_command_builtin == 0 && return_catch_value > EX_SHERRBASE)
return (return_catch_value);
if (return_catch_flag)
sh_longjmp (return_catch, 1);
+1 -1
View File
@@ -62,7 +62,7 @@ shift_builtin (WORD_LIST *list)
CHECK_HELPOPT (list);
if (get_numeric_arg (list, 0, &times) == 0)
return (EXECUTION_FAILURE);
return (EX_USAGE);
if (times == 0)
return (EXECUTION_SUCCESS);
+1 -1
View File
@@ -96,7 +96,7 @@ suspend_builtin (WORD_LIST *list)
}
list = loptend;
no_args (list);
no_args (list, 0);
if (force == 0)
{
+3086 -3049
View File
File diff suppressed because it is too large Load Diff
+7 -16
View File
@@ -5,13 +5,8 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Fri Oct 6 16:41:20 EDT 2023
.\" Last Change: Wed Oct 11 10:23:34 EDT 2023
.\"
.\" suggested by Bjarni Ingi Gislason <bjarniig@simnet.is>
.if n \{\
.kern 0
.ss 12 0
.\}
.\" bash_builtins, strip all but Built-Ins section
.\" avoid a warning about an undefined register
.\" .if !rzY .nr zY 0
@@ -518,11 +513,7 @@ command (only \fBin\fP and \fBdo\fP are valid):
.B
.if n ! case coproc do done elif else esac fi for function if in select \
then until while { } time [[ ]]
.if t \{\
.lg 0
! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]]
.lg 1
.\}
.if t ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]]
.if t .RE
.SH "SHELL GRAMMAR"
This section describes the syntax of the various forms of shell commands.
@@ -4375,9 +4366,9 @@ This is semantically equivalent to
(see \fBDuplicating File Descriptors\fP below).
.SS Here Documents
This type of redirection instructs the shell to read input from the
current source until a line containing only
current source until it reads a line containing only
.I delimiter
(with no trailing blanks) is seen.
(with no trailing blanks).
All of the lines read up to that point are then used as the standard
input (or file descriptor \fIn\fP if \fIn\fP is specified) for a command.
.PP
@@ -11638,7 +11629,7 @@ specified as a set of options to the shopt builtin (
.BR compat41 ,
and so on).
There is only one current
compatibility level \(en each option is mutually exclusive.
compatibility level \(em each option is mutually exclusive.
The compatibility level is intended to allow users to select behavior
from previous versions that is incompatible with newer versions
while they migrate scripts to use current features and
@@ -11980,10 +11971,10 @@ script.
.TP
\fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
.TP
\fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE --
\fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE \(em
http://pubs.opengroup.org/onlinepubs/9699919799/
.TP
http://tiswww.case.edu/\(tichet/bash/POSIX \(en a description of posix mode
http://tiswww.case.edu/\(tichet/bash/POSIX \(em a description of posix mode
.TP
\fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1)
.TP
+8 -14
View File
@@ -680,13 +680,7 @@ command (only <B>in</B> and <B>do</B> are valid):
<B>
</B>
<BR>&nbsp;!&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;&nbsp;&nbsp;&nbsp;coproc&nbsp;&nbsp;&nbsp;&nbsp;do&nbsp;&nbsp;&nbsp;&nbsp;done&nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;&nbsp;&nbsp;&nbsp;esac&nbsp;&nbsp;&nbsp;&nbsp;fi&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;&nbsp;&nbsp;&nbsp;in&nbsp;&nbsp;&nbsp;&nbsp;select&nbsp;&nbsp;&nbsp;&nbsp;then&nbsp;&nbsp;&nbsp;&nbsp;until&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;time&nbsp;&nbsp;&nbsp;&nbsp;[[&nbsp;&nbsp;&nbsp;&nbsp;]]
! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]]
</DL>
@@ -5497,10 +5491,10 @@ This is semantically equivalent to
<H4>Here Documents</H4>
This type of redirection instructs the shell to read input from the
current source until a line containing only
current source until it reads a line containing only
<I>delimiter</I>
(with no trailing blanks) is seen.
(with no trailing blanks).
All of the lines read up to that point are then used as the standard
input (or file descriptor <I>n</I> if <I>n</I> is specified) for a command.
<P>
@@ -14605,7 +14599,7 @@ specified as a set of options to the shopt builtin (
and so on).
There is only one current
compatibility level en each option is mutually exclusive.
compatibility level - each option is mutually exclusive.
The compatibility level is intended to allow users to select behavior
from previous versions that is incompatible with newer versions
while they migrate scripts to use current features and
@@ -15007,9 +15001,9 @@ script.
<DT><I>Bash Reference Manual</I>, Brian Fox and Chet Ramey<DD>
<DT><I>The Gnu Readline Library</I>, Brian Fox and Chet Ramey<DD>
<DT><I>The Gnu History Library</I>, Brian Fox and Chet Ramey<DD>
<DT><I>Portable Operating System Interface (POSIX) Part 2: Shell and Utilities</I>, IEEE --<DD>
<DT><I>Portable Operating System Interface (POSIX) Part 2: Shell and Utilities</I>, IEEE -<DD>
<A HREF="http://pubs.opengroup.org/onlinepubs/9699919799/">http://pubs.opengroup.org/onlinepubs/9699919799/</A>
<DT><A HREF="http://tiswww.case.edu/tichet/bash/POSIX">http://tiswww.case.edu/tichet/bash/POSIX</A> en a description of posix mode<DD>
<DT><A HREF="http://tiswww.case.edu/tichet/bash/POSIX">http://tiswww.case.edu/tichet/bash/POSIX</A> - a description of posix mode<DD>
<DT><I>sh</I>(1), <I>ksh</I>(1), <I>csh</I>(1)<DD>
<DT><I>emacs</I>(1), <I>vi</I>(1)<DD>
<DT><I>readline</I>(3)<DD>
@@ -15273,7 +15267,7 @@ There may be only one active coprocess at a time.
<DT><A HREF="#lbDI">BUGS</A><DD>
</DL>
<HR>
This document was created by man2html from /usr/local/src/bash/bash-20231004/doc/bash.1.<BR>
Time: 06 October 2023 16:59:04 EDT
This document was created by man2html from /usr/local/src/bash/bash-20231007/doc/bash.1.<BR>
Time: 11 October 2023 10:25:11 EDT
</BODY>
</HTML>
+91 -91
View File
@@ -2737,8 +2737,8 @@ This is semantically equivalent to
--------------------
This type of redirection instructs the shell to read input from the
current source until a line containing only DELIMITER (with no trailing
blanks) is seen. All of the lines read up to that point are then used
current source until it reads a line containing only DELIMITER (with no
trailing blanks). All of the lines read up to that point are then used
as the standard input (or file descriptor N if N is specified) for a
command.
@@ -12918,95 +12918,95 @@ Node: Filename Expansion104026
Node: Pattern Matching106956
Node: Quote Removal111955
Node: Redirections112247
Node: Executing Commands121937
Node: Simple Command Expansion122604
Node: Command Search and Execution124711
Node: Command Execution Environment127095
Node: Environment130127
Node: Exit Status131787
Node: Signals133568
Node: Shell Scripts137014
Node: Shell Builtin Commands140038
Node: Bourne Shell Builtins142073
Node: Bash Builtins165462
Node: Modifying Shell Behavior198398
Node: The Set Builtin198740
Node: The Shopt Builtin209711
Node: Special Builtins225846
Node: Shell Variables226822
Node: Bourne Shell Variables227256
Node: Bash Variables229357
Node: Bash Features264422
Node: Invoking Bash265432
Node: Bash Startup Files271468
Node: Interactive Shells276596
Node: What is an Interactive Shell?277004
Node: Is this Shell Interactive?277650
Node: Interactive Shell Behavior278462
Node: Bash Conditional Expressions282088
Node: Shell Arithmetic286998
Node: Aliases289956
Node: Arrays292847
Node: The Directory Stack299478
Node: Directory Stack Builtins300259
Node: Controlling the Prompt304516
Node: The Restricted Shell307478
Node: Bash POSIX Mode310085
Node: Shell Compatibility Mode326339
Node: Job Control334584
Node: Job Control Basics335041
Node: Job Control Builtins340040
Node: Job Control Variables345832
Node: Command Line Editing346985
Node: Introduction and Notation348653
Node: Readline Interaction350273
Node: Readline Bare Essentials351461
Node: Readline Movement Commands353247
Node: Readline Killing Commands354204
Node: Readline Arguments356122
Node: Searching357163
Node: Readline Init File359346
Node: Readline Init File Syntax360604
Node: Conditional Init Constructs384626
Node: Sample Init File388819
Node: Bindable Readline Commands391940
Node: Commands For Moving393141
Node: Commands For History395189
Node: Commands For Text400180
Node: Commands For Killing404155
Node: Numeric Arguments406856
Node: Commands For Completion407992
Node: Keyboard Macros412180
Node: Miscellaneous Commands412865
Node: Readline vi Mode418900
Node: Programmable Completion419804
Node: Programmable Completion Builtins427581
Node: A Programmable Completion Example438698
Node: Using History Interactively443943
Node: Bash History Facilities444624
Node: Bash History Builtins447632
Node: History Interaction452720
Node: Event Designators456530
Node: Word Designators458065
Node: Modifiers459927
Node: Installing Bash461732
Node: Basic Installation462866
Node: Compilers and Options466585
Node: Compiling For Multiple Architectures467323
Node: Installation Names469012
Node: Specifying the System Type471118
Node: Sharing Defaults471832
Node: Operation Controls472502
Node: Optional Features473457
Node: Reporting Bugs484673
Node: Major Differences From The Bourne Shell486004
Node: GNU Free Documentation License502859
Node: Indexes528033
Node: Builtin Index528484
Node: Reserved Word Index535582
Node: Variable Index538027
Node: Function Index555158
Node: Concept Index568876
Node: Executing Commands121938
Node: Simple Command Expansion122605
Node: Command Search and Execution124712
Node: Command Execution Environment127096
Node: Environment130128
Node: Exit Status131788
Node: Signals133569
Node: Shell Scripts137015
Node: Shell Builtin Commands140039
Node: Bourne Shell Builtins142074
Node: Bash Builtins165463
Node: Modifying Shell Behavior198399
Node: The Set Builtin198741
Node: The Shopt Builtin209712
Node: Special Builtins225847
Node: Shell Variables226823
Node: Bourne Shell Variables227257
Node: Bash Variables229358
Node: Bash Features264423
Node: Invoking Bash265433
Node: Bash Startup Files271469
Node: Interactive Shells276597
Node: What is an Interactive Shell?277005
Node: Is this Shell Interactive?277651
Node: Interactive Shell Behavior278463
Node: Bash Conditional Expressions282089
Node: Shell Arithmetic286999
Node: Aliases289957
Node: Arrays292848
Node: The Directory Stack299479
Node: Directory Stack Builtins300260
Node: Controlling the Prompt304517
Node: The Restricted Shell307479
Node: Bash POSIX Mode310086
Node: Shell Compatibility Mode326340
Node: Job Control334585
Node: Job Control Basics335042
Node: Job Control Builtins340041
Node: Job Control Variables345833
Node: Command Line Editing346986
Node: Introduction and Notation348654
Node: Readline Interaction350274
Node: Readline Bare Essentials351462
Node: Readline Movement Commands353248
Node: Readline Killing Commands354205
Node: Readline Arguments356123
Node: Searching357164
Node: Readline Init File359347
Node: Readline Init File Syntax360605
Node: Conditional Init Constructs384627
Node: Sample Init File388820
Node: Bindable Readline Commands391941
Node: Commands For Moving393142
Node: Commands For History395190
Node: Commands For Text400181
Node: Commands For Killing404156
Node: Numeric Arguments406857
Node: Commands For Completion407993
Node: Keyboard Macros412181
Node: Miscellaneous Commands412866
Node: Readline vi Mode418901
Node: Programmable Completion419805
Node: Programmable Completion Builtins427582
Node: A Programmable Completion Example438699
Node: Using History Interactively443944
Node: Bash History Facilities444625
Node: Bash History Builtins447633
Node: History Interaction452721
Node: Event Designators456531
Node: Word Designators458066
Node: Modifiers459928
Node: Installing Bash461733
Node: Basic Installation462867
Node: Compilers and Options466586
Node: Compiling For Multiple Architectures467324
Node: Installation Names469013
Node: Specifying the System Type471119
Node: Sharing Defaults471833
Node: Operation Controls472503
Node: Optional Features473458
Node: Reporting Bugs484674
Node: Major Differences From The Bourne Shell486005
Node: GNU Free Documentation License502860
Node: Indexes528034
Node: Builtin Index528485
Node: Reserved Word Index535583
Node: Variable Index538028
Node: Function Index555159
Node: Concept Index568877

End Tag Table
BIN
View File
Binary file not shown.
+2 -2
View File
@@ -3716,8 +3716,8 @@ expansion of <var>word</var>.
<div class="subsection" id="Here-Documents">
<h4 class="subsection">3.6.6 Here Documents</h4>
<p>This type of redirection instructs the shell to read input from the
current source until a line containing only <var>delimiter</var>
(with no trailing blanks) is seen.
current source until it reads a line containing only <var>delimiter</var>
(with no trailing blanks).
All of the lines read up to that point are then used as the standard
input (or file descriptor <var>n</var> if <var>n</var> is specified) for a command.
</p>
+91 -91
View File
@@ -2738,8 +2738,8 @@ This is semantically equivalent to
--------------------
This type of redirection instructs the shell to read input from the
current source until a line containing only DELIMITER (with no trailing
blanks) is seen. All of the lines read up to that point are then used
current source until it reads a line containing only DELIMITER (with no
trailing blanks). All of the lines read up to that point are then used
as the standard input (or file descriptor N if N is specified) for a
command.
@@ -12919,95 +12919,95 @@ Node: Filename Expansion104146
Node: Pattern Matching107079
Node: Quote Removal112081
Node: Redirections112376
Node: Executing Commands122069
Node: Simple Command Expansion122739
Node: Command Search and Execution124849
Node: Command Execution Environment127236
Node: Environment130271
Node: Exit Status131934
Node: Signals133718
Node: Shell Scripts137167
Node: Shell Builtin Commands140194
Node: Bourne Shell Builtins142232
Node: Bash Builtins165624
Node: Modifying Shell Behavior198563
Node: The Set Builtin198908
Node: The Shopt Builtin209882
Node: Special Builtins226020
Node: Shell Variables226999
Node: Bourne Shell Variables227436
Node: Bash Variables229540
Node: Bash Features264608
Node: Invoking Bash265621
Node: Bash Startup Files271660
Node: Interactive Shells276791
Node: What is an Interactive Shell?277202
Node: Is this Shell Interactive?277851
Node: Interactive Shell Behavior278666
Node: Bash Conditional Expressions282295
Node: Shell Arithmetic287208
Node: Aliases290169
Node: Arrays293063
Node: The Directory Stack299697
Node: Directory Stack Builtins300481
Node: Controlling the Prompt304741
Node: The Restricted Shell307706
Node: Bash POSIX Mode310316
Node: Shell Compatibility Mode326573
Node: Job Control334821
Node: Job Control Basics335281
Node: Job Control Builtins340283
Node: Job Control Variables346078
Node: Command Line Editing347234
Node: Introduction and Notation348905
Node: Readline Interaction350528
Node: Readline Bare Essentials351719
Node: Readline Movement Commands353508
Node: Readline Killing Commands354468
Node: Readline Arguments356389
Node: Searching357433
Node: Readline Init File359619
Node: Readline Init File Syntax360880
Node: Conditional Init Constructs384905
Node: Sample Init File389101
Node: Bindable Readline Commands392225
Node: Commands For Moving393429
Node: Commands For History395480
Node: Commands For Text400474
Node: Commands For Killing404452
Node: Numeric Arguments407156
Node: Commands For Completion408295
Node: Keyboard Macros412486
Node: Miscellaneous Commands413174
Node: Readline vi Mode419212
Node: Programmable Completion420119
Node: Programmable Completion Builtins427899
Node: A Programmable Completion Example439019
Node: Using History Interactively444267
Node: Bash History Facilities444951
Node: Bash History Builtins447962
Node: History Interaction453053
Node: Event Designators456866
Node: Word Designators458404
Node: Modifiers460269
Node: Installing Bash462077
Node: Basic Installation463214
Node: Compilers and Options466936
Node: Compiling For Multiple Architectures467677
Node: Installation Names469369
Node: Specifying the System Type471478
Node: Sharing Defaults472195
Node: Operation Controls472868
Node: Optional Features473826
Node: Reporting Bugs485045
Node: Major Differences From The Bourne Shell486379
Node: GNU Free Documentation License503237
Node: Indexes528414
Node: Builtin Index528868
Node: Reserved Word Index535969
Node: Variable Index538417
Node: Function Index555551
Node: Concept Index569272
Node: Executing Commands122070
Node: Simple Command Expansion122740
Node: Command Search and Execution124850
Node: Command Execution Environment127237
Node: Environment130272
Node: Exit Status131935
Node: Signals133719
Node: Shell Scripts137168
Node: Shell Builtin Commands140195
Node: Bourne Shell Builtins142233
Node: Bash Builtins165625
Node: Modifying Shell Behavior198564
Node: The Set Builtin198909
Node: The Shopt Builtin209883
Node: Special Builtins226021
Node: Shell Variables227000
Node: Bourne Shell Variables227437
Node: Bash Variables229541
Node: Bash Features264609
Node: Invoking Bash265622
Node: Bash Startup Files271661
Node: Interactive Shells276792
Node: What is an Interactive Shell?277203
Node: Is this Shell Interactive?277852
Node: Interactive Shell Behavior278667
Node: Bash Conditional Expressions282296
Node: Shell Arithmetic287209
Node: Aliases290170
Node: Arrays293064
Node: The Directory Stack299698
Node: Directory Stack Builtins300482
Node: Controlling the Prompt304742
Node: The Restricted Shell307707
Node: Bash POSIX Mode310317
Node: Shell Compatibility Mode326574
Node: Job Control334822
Node: Job Control Basics335282
Node: Job Control Builtins340284
Node: Job Control Variables346079
Node: Command Line Editing347235
Node: Introduction and Notation348906
Node: Readline Interaction350529
Node: Readline Bare Essentials351720
Node: Readline Movement Commands353509
Node: Readline Killing Commands354469
Node: Readline Arguments356390
Node: Searching357434
Node: Readline Init File359620
Node: Readline Init File Syntax360881
Node: Conditional Init Constructs384906
Node: Sample Init File389102
Node: Bindable Readline Commands392226
Node: Commands For Moving393430
Node: Commands For History395481
Node: Commands For Text400475
Node: Commands For Killing404453
Node: Numeric Arguments407157
Node: Commands For Completion408296
Node: Keyboard Macros412487
Node: Miscellaneous Commands413175
Node: Readline vi Mode419213
Node: Programmable Completion420120
Node: Programmable Completion Builtins427900
Node: A Programmable Completion Example439020
Node: Using History Interactively444268
Node: Bash History Facilities444952
Node: Bash History Builtins447963
Node: History Interaction453054
Node: Event Designators456867
Node: Word Designators458405
Node: Modifiers460270
Node: Installing Bash462078
Node: Basic Installation463215
Node: Compilers and Options466937
Node: Compiling For Multiple Architectures467678
Node: Installation Names469370
Node: Specifying the System Type471479
Node: Sharing Defaults472196
Node: Operation Controls472869
Node: Optional Features473827
Node: Reporting Bugs485046
Node: Major Differences From The Bourne Shell486380
Node: GNU Free Documentation License503238
Node: Indexes528415
Node: Builtin Index528869
Node: Reserved Word Index535970
Node: Variable Index538418
Node: Function Index555552
Node: Concept Index569273

End Tag Table
+14 -14
View File
@@ -1,12 +1,12 @@
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021/MacPorts 2021.58693_0) (preloaded format=pdfetex 2021.8.30) 6 OCT 2023 16:58
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021/MacPorts 2021.58693_0) (preloaded format=pdfetex 2021.8.30) 11 OCT 2023 10:24
entering extended mode
restricted \write18 enabled.
file:line:error style messages enabled.
%&-line parsing enabled.
**\input /usr/local/src/bash/bash-20231004/doc/bashref.texi \input /usr/local/s
rc/bash/bash-20231004/doc/bashref.texi
(/usr/local/src/bash/bash-20231004/doc/bashref.texi
(/usr/local/src/bash/bash-20231004/doc/texinfo.tex
**\input /usr/local/src/bash/bash-20231007/doc/bashref.texi \input /usr/local/s
rc/bash/bash-20231007/doc/bashref.texi
(/usr/local/src/bash/bash-20231007/doc/bashref.texi
(/usr/local/src/bash/bash-20231007/doc/texinfo.tex
Loading texinfo [version 2015-11-22.14]:
\outerhsize=\dimen16
\outervsize=\dimen17
@@ -162,15 +162,15 @@ This is `epsf.tex' v2.7.4 <14 February 2011>
texinfo.tex: doing @include of version.texi
(/usr/local/src/bash/bash-20231004/doc/version.texi) [1{/opt/local/var/db/texmf
(/usr/local/src/bash/bash-20231007/doc/version.texi) [1{/opt/local/var/db/texmf
/fonts/map/pdftex/updmap/pdftex.map}] [2]
(/usr/local/build/bash/bash-20231004/doc/bashref.toc [-1] [-2] [-3]) [-4]
(/usr/local/build/bash/bash-20231004/doc/bashref.toc)
(/usr/local/build/bash/bash-20231004/doc/bashref.toc) Chapter 1
(/usr/local/build/bash/bash-20231007/doc/bashref.toc [-1] [-2] [-3]) [-4]
(/usr/local/build/bash/bash-20231007/doc/bashref.toc)
(/usr/local/build/bash/bash-20231007/doc/bashref.toc) Chapter 1
\openout0 = `bashref.toc'.
(/usr/local/build/bash/bash-20231004/doc/bashref.aux)
(/usr/local/build/bash/bash-20231007/doc/bashref.aux)
\openout1 = `bashref.aux'.
Chapter 2 [1] [2]
@@ -262,7 +262,7 @@ Overfull \hbox (38.26585pt too wide) in paragraph at lines 5413--5413
[119] [120]
texinfo.tex: doing @include of rluser.texi
(/usr/local/src/bash/bash-20231004/lib/readline/doc/rluser.texi
(/usr/local/src/bash/bash-20231007/lib/readline/doc/rluser.texi
Chapter 8 [121] [122] [123] [124] [125] [126] [127] [128] [129] [130] [131]
[132]
Underfull \hbox (badness 7540) in paragraph at lines 878--884
@@ -312,7 +312,7 @@ gnored[]
texinfo.tex: doing @include of hsuser.texi
(/usr/local/src/bash/bash-20231004/lib/readline/doc/hsuser.texi Chapter 9
(/usr/local/src/bash/bash-20231007/lib/readline/doc/hsuser.texi Chapter 9
[158] [159] [160] [161] [162] [163]) Chapter 10 [164] [165] [166] [167]
[168]
Underfull \hbox (badness 10000) in paragraph at lines 9749--9758
@@ -344,7 +344,7 @@ extrm '[], `@texttt strict-posix-default[]@textrm '[], and
[178] [179] Appendix C [180]
texinfo.tex: doing @include of fdl.texi
(/usr/local/src/bash/bash-20231004/doc/fdl.texi
(/usr/local/src/bash/bash-20231007/doc/fdl.texi
[181] [182] [183] [184] [185] [186] [187]) Appendix D [188] [189] [190]
[191] [192] [193] [194] [195] [196] [197] )
Here is how much of TeX's memory you used:
@@ -372,7 +372,7 @@ texlive/fonts/type1/public/amsfonts/cm/cmtt12.pfb></opt/local/share/texmf-texli
ve/fonts/type1/public/amsfonts/cm/cmtt9.pfb></opt/local/share/texmf-texlive/fon
ts/type1/public/cm-super/sfrm1095.pfb></opt/local/share/texmf-texlive/fonts/typ
e1/public/cm-super/sfrm1440.pfb>
Output written on bashref.pdf (203 pages, 813995 bytes).
Output written on bashref.pdf (203 pages, 813993 bytes).
PDF statistics:
2824 PDF objects out of 2984 (max. 8388607)
2574 compressed objects within 26 object streams
BIN
View File
Binary file not shown.
+2 -2
View File
@@ -3227,8 +3227,8 @@ This is semantically equivalent to
@subsection Here Documents
This type of redirection instructs the shell to read input from the
current source until a line containing only @var{delimiter}
(with no trailing blanks) is seen.
current source until it reads a line containing only @var{delimiter}
(with no trailing blanks).
All of the lines read up to that point are then used as the standard
input (or file descriptor @var{n} if @var{n} is specified) for a command.
+1039 -1031
View File
File diff suppressed because it is too large Load Diff
+19 -30
View File
@@ -67,11 +67,11 @@ unquoted_glob_pattern_p (char *string)
{
register int c;
char *send;
int open, bsquote;
int open;
DECLARE_MBSTATE;
open = bsquote = 0;
open = 0;
send = string + strlen (string);
while (c = *string++)
@@ -94,33 +94,23 @@ unquoted_glob_pattern_p (char *string)
case '/':
if (open)
open = 0;
continue;
case '+':
case '@':
case '!':
if (*string == '(') /*)*/
if (extended_glob && *string == '(') /*)*/
return (1);
continue;
/* A pattern can't end with a backslash, but a backslash in the pattern
can be special to the matching engine, so we note it in case we
need it later. */
case '\\':
if (*string != '\0' && *string != '/')
{
bsquote = 1;
string++;
continue;
}
else if (open && *string == '/')
{
string++; /* quoted slashes in bracket expressions are ok */
continue;
}
else if (*string == 0)
return (0);
case CTLESC:
/* Even after an unquoted backslash, CTLESC either quotes the next
char or escapes a CTLESC or CTLNUL. Either way, the character
after it is not an unquoted globbing char. */
if (*string == CTLESC)
string++;
/*FALLTHROUGH*/
case CTLESC:
if (*string++ == '\0')
return (0);
}
@@ -136,11 +126,7 @@ unquoted_glob_pattern_p (char *string)
#endif
}
#if 0
return (bsquote ? 2 : 0);
#else
return (0);
#endif
}
/* Return 1 if C is a character that is `special' in a POSIX ERE and needs to
@@ -175,6 +161,14 @@ glob_char_p (const char *s)
{
switch (*s)
{
#if defined (EXTENDED_GLOB)
case '+':
case '@':
return (s[1] == '('); /*)*/
case '(':
case '|':
case ')':
#endif
case '!':
case '^':
case '-':
@@ -187,11 +181,6 @@ glob_char_p (const char *s)
case '?':
case '\\':
return 1;
case '+':
case '@':
if (s[1] == '(') /*(*/
return 1;
break;
}
return 0;
}
+2 -1
View File
@@ -467,7 +467,7 @@ unlimited
./builtins11.sub: line 27: ulimit: +1999: invalid number
0
0
./builtins11.sub: line 37: ulimit: -q: invalid option
./builtins11.sub: line 37: ulimit: -g: invalid option
ulimit: usage: ulimit [-SHabcdefiklmnpqrstuvxPRT] [limit]
./builtins11.sub: line 39: ulimit: max user processes: cannot modify limit: Operation not permitted
/tmp /bin
@@ -490,3 +490,4 @@ popd: usage: popd [-n] [+N | -N]
/tmp /
/
./builtins.tests: line 322: exit: status: numeric argument required
after non-numeric arg to exit: 2
+2 -3
View File
@@ -318,7 +318,6 @@ shift 0 # succeeds silently
options=$(set -o -B 2>&1 | wc -l)
[[ $options -gt 3 ]] || echo 'set: bad -o option name parsing'
# this must be last -- it is a fatal error
# this no longer must be last -- it is no longer a fatal error
exit status
echo after bad exit
echo after non-numeric arg to exit: $?
+1 -1
View File
@@ -34,7 +34,7 @@ ulimit -c
ulimit -a >/dev/null # just make sure we have no errors
# these are errors
ulimit -q
ulimit -g
# have to see about this one
ulimit -u $(( 2**31 - 1 ))
+40 -1
View File
@@ -269,6 +269,45 @@ DEBUG
./errors9.sub: line 8: ((: -- : arithmetic syntax error: operand expected (error token is "- ")
DEBUG
./errors9.sub: line 10: ((: -- : arithmetic syntax error: operand expected (error token is "- ")
invalid numeric argument
bash: line 1: exit: abcde: numeric argument required
after exit: 2
bash: line 1: break: abcde: numeric argument required
bash: line 1: continue: abcde: numeric argument required
bash: line 1: shift: abcde: numeric argument required
after shift: 2
bash: line 1: return: abcde: numeric argument required
after return: 2
bash: line 1: exit: abcde: numeric argument required
bash: line 1: break: abcde: numeric argument required
bash: line 1: continue: abcde: numeric argument required
bash: line 1: shift: abcde: numeric argument required
bash: line 1: return: abcde: numeric argument required
./errors10.sub: line 38: history: abcde: numeric argument required
after history: 2
./errors10.sub: line 40: history: too many arguments
after history: 2
too many arguments
errors: line 3: exit: too many arguments
after exit: 2
errors: line 3: return: too many arguments
after return: 2
errors: line 3: shift: too many arguments
after shift: 2
errors: line 3: break: too many arguments
after break: 2
errors: line 3: continue: too many arguments
after continue: 2
errors: line 3: exit: too many arguments
after exit: 2
errors: line 3: return: too many arguments
after return: 2
errors: line 3: shift: too many arguments
after shift: 2
errors: line 3: break: too many arguments
after break: 2
errors: line 3: continue: too many arguments
after continue: 2
bash: line 1: return: can only `return' from a function or sourced script
after return
bash: line 1: return: can only `return' from a function or sourced script
@@ -277,4 +316,4 @@ sh: line 1: unset: `a-b': not a valid identifier
sh: line 1: /nosuchfile: No such file or directory
sh: line 1: trap: SIGNOSIG: invalid signal specification
after trap
./errors.tests: line 395: `!!': not a valid identifier
./errors.tests: line 398: `!!': not a valid identifier
+3
View File
@@ -373,6 +373,9 @@ ${THIS_SH} -o posix ./errors7.sub
${THIS_SH} ./errors8.sub
${THIS_SH} ./errors9.sub
# invalid numeric arguments and too many arguments
${THIS_SH} ./errors10.sub
${THIS_SH} -c 'return ; echo after return' bash
${THIS_SH} -o posix -c 'return ; echo after return' bash
+70
View File
@@ -0,0 +1,70 @@
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
: ${THIS_SH:=$PWD/bash} ${TMPDIR:=/tmp}
POSIX_SH="${THIS_SH} -o posix"
# these are the posix special builtins that take a numeric argument
echo invalid numeric argument
# default mode
for b in exit break continue shift; do
BUILTIN=$b ${THIS_SH} -c 'set -- a b c; (exit 45); for f in _; do $BUILTIN abcde; done; echo after $BUILTIN: $?' bash
done
${THIS_SH} -c 'func() { return abcde; echo in func: $?; }; func; echo after return: $?' bash
# posix mode
for b in exit break continue shift; do
BUILTIN=$b ${POSIX_SH} -c 'set -- a b c; (exit 45); for f in _; do $BUILTIN abcde; done; echo after $BUILTIN: $?' bash
done
${POSIX_SH} -c 'func() { return abcde; echo in func: $?; }; func; echo after return: $?' bash
# non-special builtins, no difference
set -o history
HISTFILE=/dev/null
echo a >/dev/null
echo b >/dev/null
echo c >/dev/null
history abcde
echo after history: $?
history 10 42
echo after history: $?
set +o history
# too many arguments
echo too many arguments
TDIR=$TMPDIR/errors-$$
TFILE=errors
mkdir $TDIR || exit 1
cd $TDIR
cat <<\EOF >$TFILE
set -- a b c
(exit 45)
for f in _; do $BUILTIN 42 abcde; done
echo after $BUILTIN: $?
EOF
# default mode
for b in exit return shift break continue; do
BUILTIN=$b ${THIS_SH} $TFILE # TFILE for consistent error messages
done
# posix mode
for b in exit return shift break continue; do
BUILTIN=$b ${POSIX_SH} $TFILE # TFILE for consistent error messages
done
cd $OLDPWD
rm -rf $TDIR
+1
View File
@@ -96,6 +96,7 @@ do
echo $(( 2**$i ));
done
this is bash_logout
a
a
bad-interp
+4 -2
View File
@@ -41,13 +41,15 @@ ${THIS_SH} ./invocation2.sub
# rudimentary pretty-print tests
${THIS_SH} ./invocation3.sub
${THIS_SH} --login -c 'logout'
: ${TMPDIR:=/tmp}
TDIR=$TMPDIR/invocation-$$
mkdir $TDIR || exit 1
SAVEPWD=$PWD
echo 'echo this is bash_logout' > $TDIR/.bash_logout
HOME=$TDIR ${THIS_SH} --login -c 'logout'
rm -f $TDIR/.bash_logout
# script that ends with a comment and no newline
printf 'echo a # comment' > $TDIR/x23.in
${THIS_SH} $TDIR/x23.in