fix cd when user assigns a value to OLDPWD; fix android issue with blocked system calls; fix historical use of test -t; fix issue with foreground-TSTP async jobs

This commit is contained in:
Chet Ramey
2023-07-10 09:41:30 -04:00
parent 6cca378e82
commit 2f09fa19cf
17 changed files with 555 additions and 351 deletions
+49
View File
@@ -7075,3 +7075,52 @@ lib/readline/complete.c
From a report and patch by Grisha Levit <grishalevit@gmail.com>
back in May
7/6
---
builtins/cd.def
- cd_builtin: if $OLDPWD is set by the user or script to something
that's not a full pathname, allow it to use $CDPATH.
From a report by Dustin Boyd <chronokitsune3233@gmail.com>
7/7
---
shell.h
- user_info: add members for saved uid and saved gid
shell.c
- uidget: if we have setresuid/setresgid, get the saved uid and saved
gid so we can set them if we disable privileged mode
- disable_priv_mode: only call setuid/setresuid and setgid/setresgid
if the euid (egid) != uid (gid). If we have setresuid/setresgid,
add a check whether the saved uid (gid) isn't the same as the real
uid (gid). Potentially saves a couple of system calls.
Fixes Android issue, patch by Grisha Levit <grishalevit@gmail.com>
test.c
- unary_operator: only support historical handling of -t and its
optional argument when not in posix mode
- unary_test: print an error if the argument to -t is not a number
- unary_operator: only make the argument to -t optional if the
next argument is -a or -o and we are using the historical algorithm
(argc >= 5), otherwise force it to be a number and print an error
message if it's not
From a report by Stephane Chazelas <stephane@chazelas.org>
doc/bash.1,doc/bashref.texi
- added note about test/[ sorting using the current locale with the
`<' and `>' operators when in posix mode
- added note about the integer argument to test -t being required
when in posix mode
- added note recommending against the use of test with 5 or more
arguments in favor of combining multiple instances of test with
&& or ||
From a report by Stephane Chazelas <stephane@chazelas.org>
7/10
----
jobs.c
- start_job: turn off (on) the J_ASYNC flag depending on whether the
job is being started in the foreground (background). It matters now
that we use IS_ASYNC to determine whether to give the terminal
back to the shell's process group.
From a report by Grisha Levit <grishalevit@gmail.com>
+1
View File
@@ -849,6 +849,7 @@ examples/scripts/inpath f
#examples/scripts/scrollbar2 f
#examples/scripts/self-repro f
#examples/scripts/showperm.bash f
examples/scripts/secure-script f
examples/scripts/shprompt f
examples/scripts/spin.bash f
#examples/scripts/timeout f
+8 -15
View File
@@ -314,9 +314,9 @@ cd_builtin (WORD_LIST *list)
if (list == 0)
{
/* `cd' without arguments is equivalent to `cd $HOME' */
dirname = get_string_value ("HOME");
dirname = get_string_value ("HOME"); /* POSIX cd step 2 */
if (dirname == 0)
if (dirname == 0) /* POSIX cd step 1 */
{
builtin_error (_("HOME not set"));
return (EXECUTION_FAILURE);
@@ -333,7 +333,7 @@ cd_builtin (WORD_LIST *list)
#if 0
else if (list->word->word[0] == '\0')
{
builtin_error (_("null directory"));
builtin_error (_("null directory")); /* POSIX cd implementation defined */
return (EXECUTION_FAILURE);
}
#endif
@@ -347,19 +347,14 @@ cd_builtin (WORD_LIST *list)
builtin_error (_("OLDPWD not set"));
return (EXECUTION_FAILURE);
}
#if 0
lflag = interactive ? LCD_PRINTPATH : 0;
#else
lflag = LCD_PRINTPATH; /* According to SUSv3 */
#endif
lflag = LCD_PRINTPATH; /* POSIX cd `-' operand */
}
else if (absolute_pathname (list->word->word))
else
dirname = list->word->word;
else if (privileged_mode == 0 && (cdpath = get_string_value ("CDPATH")))
{
dirname = list->word->word;
/* Find directory in $CDPATH. */
if (privileged_mode == 0 && absolute_pathname (dirname) == 0 && (cdpath = get_string_value ("CDPATH")))
{
/* Find directory in $CDPATH, POSIX cd step 5. */
path_index = 0;
while (path = extract_colon_unit (cdpath, &path_index))
{
@@ -390,8 +385,6 @@ cd_builtin (WORD_LIST *list)
free (temp);
}
}
else
dirname = list->word->word;
/* When we get here, DIRNAME is the directory to change to. If we
chdir successfully, just return. */
+9 -5
View File
@@ -2720,8 +2720,10 @@ CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS
bolic links and operate on the target of the link, rather than the link
itself.
When used with [[[[, the << and >> operators sort lexicographically using
the current locale. The tteesstt command sorts using ASCII ordering.
When used with [[[[, or when the shell is in _p_o_s_i_x _m_o_d_e, the << and >> op-
erators sort lexicographically using the current locale. When the
shell is not in _p_o_s_i_x _m_o_d_e, the tteesstt command sorts using ASCII order-
ing.
--aa _f_i_l_e
True if _f_i_l_e exists.
@@ -6317,8 +6319,10 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS
The expression is parsed and evaluated according to
precedence using the rules listed above.
When used with tteesstt or [[, the << and >> operators sort lexico-
graphically using ASCII ordering.
If the shell is not in _p_o_s_i_x _m_o_d_e, when used with tteesstt or [[, the
<< and >> operators sort lexicographically using ASCII ordering.
When the shell is in _p_o_s_i_x _m_o_d_e, these operators sort using the
current locale.
ttiimmeess Print the accumulated user and system times for the shell and
for processes run from the shell. The return status is 0.
@@ -6800,4 +6804,4 @@ BBUUGGSS
GNU Bash 5.3 2023 June 28 BASH(1)
GNU Bash 5.3 2023 July 7 BASH(1)
+11 -5
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Wed Jun 28 14:06:27 EDT 2023
.\" Last Change: Fri Jul 7 15:07:53 EDT 2023
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2023 June 28" "GNU Bash 5.3"
.TH BASH 1 "2023 July 7" "GNU Bash 5.3"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -4874,9 +4874,12 @@ Unless otherwise specified, primaries that operate on files follow symbolic
links and operate on the target of the link, rather than the link itself.
.if t .sp 0.5
.if n .sp 1
When used with \fB[[\fP, the \fB<\fP and \fB>\fP operators sort
When used with \fB[[\fP,
or when the shell is in \fIposix mode\fP,
the \fB<\fP and \fB>\fP operators sort
lexicographically using the current locale.
The \fBtest\fP command sorts using ASCII ordering.
When the shell is not in \fIposix mode\fP,
the \fBtest\fP command sorts using ASCII ordering.
.sp 1
.PD 0
.TP
@@ -11028,8 +11031,11 @@ using the rules listed above.
.if t .sp 0.5
.if n .sp 1
.LP
When used with \fBtest\fP or \fB[\fP, the \fB<\fP and \fB>\fP operators
If the shell is not in \fIposix mode\fP,
when used with \fBtest\fP or \fB[\fP, the \fB<\fP and \fB>\fP operators
sort lexicographically using ASCII ordering.
When the shell is in \fIposix mode\fP, these operators sort using the
current locale.
.RE
.PD
.TP
+13 -7
View File
@@ -3,7 +3,7 @@
</HEAD>
<BODY><TABLE WIDTH=100%>
<TR>
<TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2023 June 28<TH ALIGN=RIGHT width=33%>BASH(1)
<TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2023 July 7<TH ALIGN=RIGHT width=33%>BASH(1)
</TR>
</TABLE>
<BR><A HREF="#index">Index</A>
@@ -6160,9 +6160,12 @@ links and operate on the target of the link, rather than the link itself.
<P>
When used with <B>[[</B>, the <B>&lt;</B> and <B>&gt;</B> operators sort
When used with <B>[[</B>,
or when the shell is in <I>posix mode</I>,
the <B>&lt;</B> and <B>&gt;</B> operators sort
lexicographically using the current locale.
The <B>test</B> command sorts using ASCII ordering.
When the shell is not in <I>posix mode</I>,
the <B>test</B> command sorts using ASCII ordering.
<P>
<DL COMPACT>
@@ -13849,8 +13852,11 @@ using the rules listed above.
</DL>
<P>
When used with <B>test</B> or <B>[</B>, the <B>&lt;</B> and <B>&gt;</B> operators
If the shell is not in <I>posix mode</I>,
when used with <B>test</B> or <B>[</B>, the <B>&lt;</B> and <B>&gt;</B> operators
sort lexicographically using ASCII ordering.
When the shell is in <I>posix mode</I>, these operators sort using the
current locale.
</DL>
@@ -15051,7 +15057,7 @@ There may be only one active coprocess at a time.
<HR>
<TABLE WIDTH=100%>
<TR>
<TH ALIGN=LEFT width=33%>GNU Bash 5.3<TH ALIGN=CENTER width=33%>2023 June 28<TH ALIGN=RIGHT width=33%>BASH(1)
<TH ALIGN=LEFT width=33%>GNU Bash 5.3<TH ALIGN=CENTER width=33%>2023 July 7<TH ALIGN=RIGHT width=33%>BASH(1)
</TR>
</TABLE>
<HR>
@@ -15157,7 +15163,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-20230703/doc/bash.1.<BR>
Time: 05 July 2023 11:27:18 EDT
This document was created by man2html from /usr/local/src/bash/bash-20230705/doc/bash.1.<BR>
Time: 07 July 2023 16:22:29 EDT
</BODY>
</HTML>
+166 -144
View File
@@ -1,9 +1,9 @@
This is bash.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.3, 29 June 2023).
Bash shell (version 5.3, 7 July 2023).
This is Edition 5.3, last updated 29 June 2023, of 'The GNU Bash
This is Edition 5.3, last updated 7 July 2023, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.3.
Copyright (C) 1988-2023 Free Software Foundation, Inc.
@@ -26,10 +26,10 @@ Bash Features
*************
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 29 June 2023). The Bash home page is
Bash shell (version 5.3, 7 July 2023). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.3, last updated 29 June 2023, of 'The GNU Bash
This is Edition 5.3, last updated 7 July 2023, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.3.
Bash contains features that appear in other popular shells, and some
@@ -3613,8 +3613,25 @@ standard.
The expression is parsed and evaluated according to precedence
using the rules listed above.
When used with 'test' or '[', the '<' and '>' operators sort
lexicographically using ASCII ordering.
If the shell is not in POSIX mode, when used with 'test' or '[',
the '<' and '>' operators sort lexicographically using ASCII
ordering. If the shell is in POSIX mode, these operators use the
current locale.
The historical operator-precedence parsing with 4 or more arguments
can lead to ambiguities when it encounters strings that look like
primaries. The POSIX standard has deprecated the '-a' and '-o'
primaries and enclosing expressions within parentheses. Scripts
should no longer use them. It's much more reliable to restrict
test invocations to a single primary, and to replace uses of '-a'
and '-o' with the shell's '&&' and '||' list operators. For
example, use
test -n string1 && test -n string2
instead of
test -n string1 -a -n string2
'times'
times
@@ -7493,7 +7510,12 @@ startup files.
66. The 'test' builtin compares strings using the current locale when
processing the '<' and '>' binary operators.
67. Command substitutions don't set the '?' special parameter. The
67. The 'test' builtin's '-t' unary primary requires an argument.
Historical versions of 'test' made the argument optional in certain
cases, and bash attempts to accommodate those for backwards
compatibility.
68. Command substitutions don't set the '?' special parameter. The
exit status of a simple command without a command word is still the
exit status of the last command substitution that occurred while
evaluating the variable assignments and redirections in that
@@ -12107,19 +12129,19 @@ D.1 Index of Shell Builtin Commands
* test: Bourne Shell Builtins.
(line 281)
* times: Bourne Shell Builtins.
(line 366)
(line 383)
* trap: Bourne Shell Builtins.
(line 372)
(line 389)
* true: Bourne Shell Builtins.
(line 434)
(line 451)
* type: Bash Builtins. (line 615)
* typeset: Bash Builtins. (line 653)
* ulimit: Bash Builtins. (line 659)
* umask: Bourne Shell Builtins.
(line 439)
(line 456)
* unalias: Bash Builtins. (line 765)
* unset: Bourne Shell Builtins.
(line 457)
(line 474)
* wait: Job Control Builtins.
(line 76)
@@ -12794,138 +12816,138 @@ D.5 Concept Index

Tag Table:
Node: Top886
Node: Introduction2795
Node: What is Bash?3008
Node: What is a shell?4119
Node: Definitions6654
Node: Basic Shell Features9602
Node: Shell Syntax10818
Node: Shell Operation11841
Node: Quoting13131
Node: Escape Character14432
Node: Single Quotes14914
Node: Double Quotes15259
Node: ANSI-C Quoting16534
Node: Locale Translation17843
Node: Creating Internationalized Scripts19151
Node: Comments23265
Node: Shell Commands23880
Node: Reserved Words24815
Node: Simple Commands25568
Node: Pipelines26219
Node: Lists29202
Node: Compound Commands30994
Node: Looping Constructs32003
Node: Conditional Constructs34495
Node: Command Grouping48980
Node: Coprocesses50455
Node: GNU Parallel53115
Node: Shell Functions54029
Node: Shell Parameters61911
Node: Positional Parameters66296
Node: Special Parameters67195
Node: Shell Expansions70406
Node: Brace Expansion72491
Node: Tilde Expansion75222
Node: Shell Parameter Expansion77840
Node: Command Substitution96239
Node: Arithmetic Expansion99700
Node: Process Substitution100665
Node: Word Splitting101782
Node: Filename Expansion103827
Node: Pattern Matching106757
Node: Quote Removal111756
Node: Redirections112048
Node: Executing Commands121738
Node: Simple Command Expansion122405
Node: Command Search and Execution124512
Node: Command Execution Environment126896
Node: Environment129928
Node: Exit Status131588
Node: Signals133369
Node: Shell Scripts136815
Node: Shell Builtin Commands139839
Node: Bourne Shell Builtins141874
Node: Bash Builtins164278
Node: Modifying Shell Behavior196274
Node: The Set Builtin196616
Node: The Shopt Builtin207211
Node: Special Builtins223215
Node: Shell Variables224191
Node: Bourne Shell Variables224625
Node: Bash Variables226726
Node: Bash Features261680
Node: Invoking Bash262690
Node: Bash Startup Files268700
Node: Interactive Shells273828
Node: What is an Interactive Shell?274236
Node: Is this Shell Interactive?274882
Node: Interactive Shell Behavior275694
Node: Bash Conditional Expressions279320
Node: Shell Arithmetic283959
Node: Aliases286917
Node: Arrays289808
Node: The Directory Stack296368
Node: Directory Stack Builtins297149
Node: Controlling the Prompt301406
Node: The Restricted Shell304368
Node: Bash POSIX Mode306975
Node: Shell Compatibility Mode322888
Node: Job Control331129
Node: Job Control Basics331586
Node: Job Control Builtins336585
Node: Job Control Variables342377
Node: Command Line Editing343530
Node: Introduction and Notation345198
Node: Readline Interaction346818
Node: Readline Bare Essentials348006
Node: Readline Movement Commands349792
Node: Readline Killing Commands350749
Node: Readline Arguments352667
Node: Searching353708
Node: Readline Init File355891
Node: Readline Init File Syntax357149
Node: Conditional Init Constructs380937
Node: Sample Init File385130
Node: Bindable Readline Commands388251
Node: Commands For Moving389452
Node: Commands For History391500
Node: Commands For Text396491
Node: Commands For Killing400137
Node: Numeric Arguments403167
Node: Commands For Completion404303
Node: Keyboard Macros408491
Node: Miscellaneous Commands409176
Node: Readline vi Mode415211
Node: Programmable Completion416115
Node: Programmable Completion Builtins423892
Node: A Programmable Completion Example435009
Node: Using History Interactively440254
Node: Bash History Facilities440935
Node: Bash History Builtins443937
Node: History Interaction448958
Node: Event Designators452575
Node: Word Designators453926
Node: Modifiers455683
Node: Installing Bash457488
Node: Basic Installation458622
Node: Compilers and Options462341
Node: Compiling For Multiple Architectures463079
Node: Installation Names464768
Node: Specifying the System Type466874
Node: Sharing Defaults467588
Node: Operation Controls468258
Node: Optional Features469213
Node: Reporting Bugs480429
Node: Major Differences From The Bourne Shell481760
Node: GNU Free Documentation License498606
Node: Indexes523780
Node: Builtin Index524231
Node: Reserved Word Index531329
Node: Variable Index533774
Node: Function Index550905
Node: Concept Index564686
Node: Top884
Node: Introduction2791
Node: What is Bash?3004
Node: What is a shell?4115
Node: Definitions6650
Node: Basic Shell Features9598
Node: Shell Syntax10814
Node: Shell Operation11837
Node: Quoting13127
Node: Escape Character14428
Node: Single Quotes14910
Node: Double Quotes15255
Node: ANSI-C Quoting16530
Node: Locale Translation17839
Node: Creating Internationalized Scripts19147
Node: Comments23261
Node: Shell Commands23876
Node: Reserved Words24811
Node: Simple Commands25564
Node: Pipelines26215
Node: Lists29198
Node: Compound Commands30990
Node: Looping Constructs31999
Node: Conditional Constructs34491
Node: Command Grouping48976
Node: Coprocesses50451
Node: GNU Parallel53111
Node: Shell Functions54025
Node: Shell Parameters61907
Node: Positional Parameters66292
Node: Special Parameters67191
Node: Shell Expansions70402
Node: Brace Expansion72487
Node: Tilde Expansion75218
Node: Shell Parameter Expansion77836
Node: Command Substitution96235
Node: Arithmetic Expansion99696
Node: Process Substitution100661
Node: Word Splitting101778
Node: Filename Expansion103823
Node: Pattern Matching106753
Node: Quote Removal111752
Node: Redirections112044
Node: Executing Commands121734
Node: Simple Command Expansion122401
Node: Command Search and Execution124508
Node: Command Execution Environment126892
Node: Environment129924
Node: Exit Status131584
Node: Signals133365
Node: Shell Scripts136811
Node: Shell Builtin Commands139835
Node: Bourne Shell Builtins141870
Node: Bash Builtins165003
Node: Modifying Shell Behavior196999
Node: The Set Builtin197341
Node: The Shopt Builtin207936
Node: Special Builtins223940
Node: Shell Variables224916
Node: Bourne Shell Variables225350
Node: Bash Variables227451
Node: Bash Features262405
Node: Invoking Bash263415
Node: Bash Startup Files269425
Node: Interactive Shells274553
Node: What is an Interactive Shell?274961
Node: Is this Shell Interactive?275607
Node: Interactive Shell Behavior276419
Node: Bash Conditional Expressions280045
Node: Shell Arithmetic284684
Node: Aliases287642
Node: Arrays290533
Node: The Directory Stack297093
Node: Directory Stack Builtins297874
Node: Controlling the Prompt302131
Node: The Restricted Shell305093
Node: Bash POSIX Mode307700
Node: Shell Compatibility Mode323840
Node: Job Control332081
Node: Job Control Basics332538
Node: Job Control Builtins337537
Node: Job Control Variables343329
Node: Command Line Editing344482
Node: Introduction and Notation346150
Node: Readline Interaction347770
Node: Readline Bare Essentials348958
Node: Readline Movement Commands350744
Node: Readline Killing Commands351701
Node: Readline Arguments353619
Node: Searching354660
Node: Readline Init File356843
Node: Readline Init File Syntax358101
Node: Conditional Init Constructs381889
Node: Sample Init File386082
Node: Bindable Readline Commands389203
Node: Commands For Moving390404
Node: Commands For History392452
Node: Commands For Text397443
Node: Commands For Killing401089
Node: Numeric Arguments404119
Node: Commands For Completion405255
Node: Keyboard Macros409443
Node: Miscellaneous Commands410128
Node: Readline vi Mode416163
Node: Programmable Completion417067
Node: Programmable Completion Builtins424844
Node: A Programmable Completion Example435961
Node: Using History Interactively441206
Node: Bash History Facilities441887
Node: Bash History Builtins444889
Node: History Interaction449910
Node: Event Designators453527
Node: Word Designators454878
Node: Modifiers456635
Node: Installing Bash458440
Node: Basic Installation459574
Node: Compilers and Options463293
Node: Compiling For Multiple Architectures464031
Node: Installation Names465720
Node: Specifying the System Type467826
Node: Sharing Defaults468540
Node: Operation Controls469210
Node: Optional Features470165
Node: Reporting Bugs481381
Node: Major Differences From The Bourne Shell482712
Node: GNU Free Documentation License499558
Node: Indexes524732
Node: Builtin Index525183
Node: Reserved Word Index532281
Node: Variable Index534726
Node: Function Index551857
Node: Concept Index565638

End Tag Table
+166 -144
View File
@@ -2,9 +2,9 @@ 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.3, 29 June 2023).
Bash shell (version 5.3, 7 July 2023).
This is Edition 5.3, last updated 29 June 2023, of 'The GNU Bash
This is Edition 5.3, last updated 7 July 2023, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.3.
Copyright (C) 1988-2023 Free Software Foundation, Inc.
@@ -27,10 +27,10 @@ Bash Features
*************
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 29 June 2023). The Bash home page is
Bash shell (version 5.3, 7 July 2023). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.3, last updated 29 June 2023, of 'The GNU Bash
This is Edition 5.3, last updated 7 July 2023, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.3.
Bash contains features that appear in other popular shells, and some
@@ -3614,8 +3614,25 @@ standard.
The expression is parsed and evaluated according to precedence
using the rules listed above.
When used with 'test' or '[', the '<' and '>' operators sort
lexicographically using ASCII ordering.
If the shell is not in POSIX mode, when used with 'test' or '[',
the '<' and '>' operators sort lexicographically using ASCII
ordering. If the shell is in POSIX mode, these operators use the
current locale.
The historical operator-precedence parsing with 4 or more arguments
can lead to ambiguities when it encounters strings that look like
primaries. The POSIX standard has deprecated the '-a' and '-o'
primaries and enclosing expressions within parentheses. Scripts
should no longer use them. It's much more reliable to restrict
test invocations to a single primary, and to replace uses of '-a'
and '-o' with the shell's '&&' and '||' list operators. For
example, use
test -n string1 && test -n string2
instead of
test -n string1 -a -n string2
'times'
times
@@ -7494,7 +7511,12 @@ startup files.
66. The 'test' builtin compares strings using the current locale when
processing the '<' and '>' binary operators.
67. Command substitutions don't set the '?' special parameter. The
67. The 'test' builtin's '-t' unary primary requires an argument.
Historical versions of 'test' made the argument optional in certain
cases, and bash attempts to accommodate those for backwards
compatibility.
68. Command substitutions don't set the '?' special parameter. The
exit status of a simple command without a command word is still the
exit status of the last command substitution that occurred while
evaluating the variable assignments and redirections in that
@@ -12108,19 +12130,19 @@ D.1 Index of Shell Builtin Commands
* test: Bourne Shell Builtins.
(line 281)
* times: Bourne Shell Builtins.
(line 366)
(line 383)
* trap: Bourne Shell Builtins.
(line 372)
(line 389)
* true: Bourne Shell Builtins.
(line 434)
(line 451)
* type: Bash Builtins. (line 615)
* typeset: Bash Builtins. (line 653)
* ulimit: Bash Builtins. (line 659)
* umask: Bourne Shell Builtins.
(line 439)
(line 456)
* unalias: Bash Builtins. (line 765)
* unset: Bourne Shell Builtins.
(line 457)
(line 474)
* wait: Job Control Builtins.
(line 76)
@@ -12795,138 +12817,138 @@ D.5 Concept Index

Tag Table:
Node: Top889
Node: Introduction2801
Node: What is Bash?3017
Node: What is a shell?4131
Node: Definitions6669
Node: Basic Shell Features9620
Node: Shell Syntax10839
Node: Shell Operation11865
Node: Quoting13158
Node: Escape Character14462
Node: Single Quotes14947
Node: Double Quotes15295
Node: ANSI-C Quoting16573
Node: Locale Translation17885
Node: Creating Internationalized Scripts19196
Node: Comments23313
Node: Shell Commands23931
Node: Reserved Words24869
Node: Simple Commands25625
Node: Pipelines26279
Node: Lists29265
Node: Compound Commands31060
Node: Looping Constructs32072
Node: Conditional Constructs34567
Node: Command Grouping49055
Node: Coprocesses50533
Node: GNU Parallel53196
Node: Shell Functions54113
Node: Shell Parameters61998
Node: Positional Parameters66386
Node: Special Parameters67288
Node: Shell Expansions70502
Node: Brace Expansion72590
Node: Tilde Expansion75324
Node: Shell Parameter Expansion77945
Node: Command Substitution96347
Node: Arithmetic Expansion99811
Node: Process Substitution100779
Node: Word Splitting101899
Node: Filename Expansion103947
Node: Pattern Matching106880
Node: Quote Removal111882
Node: Redirections112177
Node: Executing Commands121870
Node: Simple Command Expansion122540
Node: Command Search and Execution124650
Node: Command Execution Environment127037
Node: Environment130072
Node: Exit Status131735
Node: Signals133519
Node: Shell Scripts136968
Node: Shell Builtin Commands139995
Node: Bourne Shell Builtins142033
Node: Bash Builtins164440
Node: Modifying Shell Behavior196439
Node: The Set Builtin196784
Node: The Shopt Builtin207382
Node: Special Builtins223389
Node: Shell Variables224368
Node: Bourne Shell Variables224805
Node: Bash Variables226909
Node: Bash Features261866
Node: Invoking Bash262879
Node: Bash Startup Files268892
Node: Interactive Shells274023
Node: What is an Interactive Shell?274434
Node: Is this Shell Interactive?275083
Node: Interactive Shell Behavior275898
Node: Bash Conditional Expressions279527
Node: Shell Arithmetic284169
Node: Aliases287130
Node: Arrays290024
Node: The Directory Stack296587
Node: Directory Stack Builtins297371
Node: Controlling the Prompt301631
Node: The Restricted Shell304596
Node: Bash POSIX Mode307206
Node: Shell Compatibility Mode323122
Node: Job Control331366
Node: Job Control Basics331826
Node: Job Control Builtins336828
Node: Job Control Variables342623
Node: Command Line Editing343779
Node: Introduction and Notation345450
Node: Readline Interaction347073
Node: Readline Bare Essentials348264
Node: Readline Movement Commands350053
Node: Readline Killing Commands351013
Node: Readline Arguments352934
Node: Searching353978
Node: Readline Init File356164
Node: Readline Init File Syntax357425
Node: Conditional Init Constructs381216
Node: Sample Init File385412
Node: Bindable Readline Commands388536
Node: Commands For Moving389740
Node: Commands For History391791
Node: Commands For Text396785
Node: Commands For Killing400434
Node: Numeric Arguments403467
Node: Commands For Completion404606
Node: Keyboard Macros408797
Node: Miscellaneous Commands409485
Node: Readline vi Mode415523
Node: Programmable Completion416430
Node: Programmable Completion Builtins424210
Node: A Programmable Completion Example435330
Node: Using History Interactively440578
Node: Bash History Facilities441262
Node: Bash History Builtins444267
Node: History Interaction449291
Node: Event Designators452911
Node: Word Designators454265
Node: Modifiers456025
Node: Installing Bash457833
Node: Basic Installation458970
Node: Compilers and Options462692
Node: Compiling For Multiple Architectures463433
Node: Installation Names465125
Node: Specifying the System Type467234
Node: Sharing Defaults467951
Node: Operation Controls468624
Node: Optional Features469582
Node: Reporting Bugs480801
Node: Major Differences From The Bourne Shell482135
Node: GNU Free Documentation License498984
Node: Indexes524161
Node: Builtin Index524615
Node: Reserved Word Index531716
Node: Variable Index534164
Node: Function Index551298
Node: Concept Index565082
Node: Top887
Node: Introduction2797
Node: What is Bash?3013
Node: What is a shell?4127
Node: Definitions6665
Node: Basic Shell Features9616
Node: Shell Syntax10835
Node: Shell Operation11861
Node: Quoting13154
Node: Escape Character14458
Node: Single Quotes14943
Node: Double Quotes15291
Node: ANSI-C Quoting16569
Node: Locale Translation17881
Node: Creating Internationalized Scripts19192
Node: Comments23309
Node: Shell Commands23927
Node: Reserved Words24865
Node: Simple Commands25621
Node: Pipelines26275
Node: Lists29261
Node: Compound Commands31056
Node: Looping Constructs32068
Node: Conditional Constructs34563
Node: Command Grouping49051
Node: Coprocesses50529
Node: GNU Parallel53192
Node: Shell Functions54109
Node: Shell Parameters61994
Node: Positional Parameters66382
Node: Special Parameters67284
Node: Shell Expansions70498
Node: Brace Expansion72586
Node: Tilde Expansion75320
Node: Shell Parameter Expansion77941
Node: Command Substitution96343
Node: Arithmetic Expansion99807
Node: Process Substitution100775
Node: Word Splitting101895
Node: Filename Expansion103943
Node: Pattern Matching106876
Node: Quote Removal111878
Node: Redirections112173
Node: Executing Commands121866
Node: Simple Command Expansion122536
Node: Command Search and Execution124646
Node: Command Execution Environment127033
Node: Environment130068
Node: Exit Status131731
Node: Signals133515
Node: Shell Scripts136964
Node: Shell Builtin Commands139991
Node: Bourne Shell Builtins142029
Node: Bash Builtins165165
Node: Modifying Shell Behavior197164
Node: The Set Builtin197509
Node: The Shopt Builtin208107
Node: Special Builtins224114
Node: Shell Variables225093
Node: Bourne Shell Variables225530
Node: Bash Variables227634
Node: Bash Features262591
Node: Invoking Bash263604
Node: Bash Startup Files269617
Node: Interactive Shells274748
Node: What is an Interactive Shell?275159
Node: Is this Shell Interactive?275808
Node: Interactive Shell Behavior276623
Node: Bash Conditional Expressions280252
Node: Shell Arithmetic284894
Node: Aliases287855
Node: Arrays290749
Node: The Directory Stack297312
Node: Directory Stack Builtins298096
Node: Controlling the Prompt302356
Node: The Restricted Shell305321
Node: Bash POSIX Mode307931
Node: Shell Compatibility Mode324074
Node: Job Control332318
Node: Job Control Basics332778
Node: Job Control Builtins337780
Node: Job Control Variables343575
Node: Command Line Editing344731
Node: Introduction and Notation346402
Node: Readline Interaction348025
Node: Readline Bare Essentials349216
Node: Readline Movement Commands351005
Node: Readline Killing Commands351965
Node: Readline Arguments353886
Node: Searching354930
Node: Readline Init File357116
Node: Readline Init File Syntax358377
Node: Conditional Init Constructs382168
Node: Sample Init File386364
Node: Bindable Readline Commands389488
Node: Commands For Moving390692
Node: Commands For History392743
Node: Commands For Text397737
Node: Commands For Killing401386
Node: Numeric Arguments404419
Node: Commands For Completion405558
Node: Keyboard Macros409749
Node: Miscellaneous Commands410437
Node: Readline vi Mode416475
Node: Programmable Completion417382
Node: Programmable Completion Builtins425162
Node: A Programmable Completion Example436282
Node: Using History Interactively441530
Node: Bash History Facilities442214
Node: Bash History Builtins445219
Node: History Interaction450243
Node: Event Designators453863
Node: Word Designators455217
Node: Modifiers456977
Node: Installing Bash458785
Node: Basic Installation459922
Node: Compilers and Options463644
Node: Compiling For Multiple Architectures464385
Node: Installation Names466077
Node: Specifying the System Type468186
Node: Sharing Defaults468903
Node: Operation Controls469576
Node: Optional Features470534
Node: Reporting Bugs481753
Node: Major Differences From The Bourne Shell483087
Node: GNU Free Documentation License499936
Node: Indexes525113
Node: Builtin Index525567
Node: Reserved Word Index532668
Node: Variable Index535116
Node: Function Index552250
Node: Concept Index566034

End Tag Table
+28 -1
View File
@@ -4288,8 +4288,30 @@ The expression is parsed and evaluated according to precedence
using the rules listed above.
@end table
When used with @code{test} or @samp{[}, the @samp{<} and @samp{>}
If the shell is not in @sc{posix} mode,
when used with @code{test} or @samp{[}, the @samp{<} and @samp{>}
operators sort lexicographically using ASCII ordering.
If the shell is in @sc{posix} mode, these operators use the current locale.
The historical operator-precedence parsing with 4 or more arguments can
lead to ambiguities when it encounters strings that look like primaries.
The @sc{posix} standard has deprecated the @option{-a} and @option{-o}
primaries and enclosing expressions within parentheses.
Scripts should no longer use them.
It's much more reliable to restrict test invocations to a single primary,
and to replace uses of @option{-a} and @option{-o} with the shell's
@code{&&} and @code{||} list operators. For example, use
@example
test -n string1 && test -n string2
@end example
@noindent
instead of
@example
test -n string1 -a -n string2
@end example
@item times
@btindex times
@@ -8700,6 +8722,11 @@ character will escape it and the backslash will be removed.
The @code{test} builtin compares strings using the current locale when
processing the @samp{<} and @samp{>} binary operators.
@item
The @code{test} builtin's @option{-t} unary primary requires an argument.
Historical versions of @code{test} made the argument optional in certain
cases, and bash attempts to accommodate those for backwards compatibility.
@item
Command substitutions don't set the @samp{?} special parameter. The exit
status of a simple command without a command word is still the exit status
+3 -3
View File
@@ -2,10 +2,10 @@
Copyright (C) 1988-2023 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Thu Jun 29 16:25:08 EDT 2023
@set LASTCHANGE Fri Jul 7 15:07:53 EDT 2023
@set EDITION 5.3
@set VERSION 5.3
@set UPDATED 29 June 2023
@set UPDATED-MONTH June 2023
@set UPDATED 7 July 2023
@set UPDATED-MONTH July 2023
+31
View File
@@ -0,0 +1,31 @@
# if we are worried somehow about inheriting a function for unset or exec,
# set posix mode, then unset it later
POSIXLY_CORRECT=1
# make sure to run with bash -p to prevent inheriting functions. you can
# do this (if the script does not need to run setuid) or use the
# POSIXLY_CORRECT setting above (as long as you run set +o posix as done below)
#case $SHELLOPTS in
#*privileged*) ;;
#*) \exec /bin/bash -p $0 "$@" ;;
#esac
# unset is a special builtin and will be found before functions; quoting it
# will prevent alias expansion
# add any other shell builtins you're concerned about
\unset -f command builtin unset shopt set unalias hash
\unset -f read true exit echo printf
# remove all aliases and disable alias expansion
\unalias -a
\shopt -u expand_aliases
# and make sure we're no longer running in posix mode
set +o posix
# get rid of any hashed commands
hash -r
# if you're concerned about PATH spoofing, make sure to have a path that
# will find the standard utilities
#PATH=$(command getconf -p getconf PATH):$PATH
+5 -1
View File
@@ -3587,12 +3587,16 @@ start_job (int job, int foreground)
{
get_tty_state ();
save_stty = shell_tty_info;
jobs[job]->flags &= ~J_ASYNC; /* no longer async */
/* Give the terminal to this job. */
if (IS_JOBCONTROL (job))
give_terminal_to (jobs[job]->pgrp, 0);
}
else
jobs[job]->flags &= ~J_FOREGROUND;
{
jobs[job]->flags &= ~J_FOREGROUND;
jobs[job]->flags |= J_ASYNC; /* running in background now */
}
/* If the job is already running, then don't bother jump-starting it. */
if (already_running == 0)
+35 -11
View File
@@ -117,7 +117,8 @@ COMMAND *global_command = (COMMAND *)NULL;
/* Information about the current user. */
struct user_info current_user =
{
(uid_t)-1, (uid_t)-1, (gid_t)-1, (gid_t)-1,
(uid_t)-1, (uid_t)-1, (uid_t)-1,
(gid_t)-1, (gid_t)-1, (gid_t)-1,
(char *)NULL, (char *)NULL, (char *)NULL
};
@@ -1298,7 +1299,22 @@ uidget (void)
{
uid_t u;
u = getuid ();
u = current_user.uid;
#if HAVE_SETRESUID
(void) getresuid (&current_user.uid, &current_user.euid, &current_user.saveuid);
#else
current_user.uid = getuid ();
current_user.euid = geteuid ();
#endif
#if HAVE_SETRESGID
(void) getresgid (&current_user.gid, &current_user.egid, &current_user.savegid);
#else
current_user.gid = getgid ();
current_user.egid = getegid ();
#endif
if (current_user.uid != u)
{
FREE (current_user.user_name);
@@ -1306,10 +1322,6 @@ uidget (void)
FREE (current_user.home_dir);
current_user.user_name = current_user.shell = current_user.home_dir = NULL;
}
current_user.uid = u;
current_user.gid = getgid ();
current_user.euid = geteuid ();
current_user.egid = getegid ();
/* See whether or not we are running setuid or setgid. */
return (current_user.uid != current_user.euid) ||
@@ -1319,13 +1331,17 @@ uidget (void)
void
disable_priv_mode (void)
{
int e;
int e, r;
r = 0;
#if HAVE_SETRESUID
if (setresuid (current_user.uid, current_user.uid, current_user.uid) < 0)
if (current_user.euid != current_user.uid || current_user.saveuid != current_user.uid)
r = setresuid (current_user.uid, current_user.uid, current_user.uid) ;
#else
if (setuid (current_user.uid) < 0)
if (current_user.euid != current_user.uid)
r = setuid (current_user.uid);
#endif
if (r < 0)
{
e = errno;
sys_error (_("cannot set uid to %d: effective uid %d"), current_user.uid, current_user.euid);
@@ -1334,15 +1350,23 @@ disable_priv_mode (void)
exit (e);
#endif
}
r = 0;
#if HAVE_SETRESGID
if (setresgid (current_user.gid, current_user.gid, current_user.gid) < 0)
if (current_user.egid != current_user.gid || current_user.savegid != current_user.gid)
r = setresgid (current_user.gid, current_user.gid, current_user.gid);
#else
if (setgid (current_user.gid) < 0)
if (current_user.egid != current_user.gid)
r = setgid (current_user.gid);
#endif
if (r < 0)
sys_error (_("cannot set gid to %d: effective gid %d"), current_user.gid, current_user.egid);
current_user.euid = current_user.uid;
current_user.egid = current_user.gid;
current_user.saveuid = current_user.uid;
current_user.savegid = current_user.gid;
}
#if defined (WORDEXP_OPTION)
+2 -2
View File
@@ -148,8 +148,8 @@ struct fd_bitmap {
/* Information about the current user. */
struct user_info {
uid_t uid, euid;
gid_t gid, egid;
uid_t uid, euid, saveuid;
gid_t gid, egid, savegid;
char *user_name;
char *shell; /* shell from the password file */
char *home_dir;
+12 -7
View File
@@ -70,6 +70,10 @@ extern int errno;
#endif /* !STREQ */
#define STRCOLLEQ(a, b) ((a)[0] == (b)[0] && strcoll ((a), (b)) == 0)
/* Same as ISOPTION from builtins/common.h */
#define ISPRIMARY(s, c) (s[0] == '-' && s[1] == c && s[2] == '\0')
#define ANDOR(s) (s[0] == '-' && (s[1] == 'a' || s[1] == 'o') && s[2] == 0)
#if !defined (R_OK)
#define R_OK 4
#define W_OK 2
@@ -184,7 +188,7 @@ or (void)
int value, v2;
value = and ();
if (pos < argc && argv[pos][0] == '-' && argv[pos][1] == 'o' && !argv[pos][2])
if (pos < argc && ISPRIMARY (argv[pos], 'o'))
{
advance (0);
v2 = or ();
@@ -205,7 +209,7 @@ and (void)
int value, v2;
value = term ();
if (pos < argc && argv[pos][0] == '-' && argv[pos][1] == 'a' && !argv[pos][2])
if (pos < argc && ISPRIMARY (argv[pos], 'a'))
{
advance (0);
v2 = and ();
@@ -477,7 +481,7 @@ unary_operator (void)
return (FALSE);
/* the only tricky case is `-t', which may or may not take an argument. */
if (op[1] == 't')
if (posixly_correct == 0 && op[1] == 't')
{
advance (0);
if (pos < argc)
@@ -487,10 +491,13 @@ unary_operator (void)
advance (0);
return (unary_test (op, argv[pos - 1], 0));
}
else if (argc >= 5 && ANDOR (argv[pos]))
return (unary_test (op, "1", 0));
else
return (FALSE);
integer_expected_error (argv[pos]);
}
else
/* this is not called when pos == argc; the one-argument code is used */
return (unary_test (op, "1", 0));
}
@@ -603,7 +610,7 @@ unary_test (char *op, char *arg, int flags)
case 't': /* File fd is a terminal? */
if (legal_number (arg, &r) == 0)
return (FALSE);
integer_expected_error (arg);
return ((r == (int)r) && isatty ((int)r));
case 'n': /* True if arg has some length. */
@@ -762,8 +769,6 @@ two_arguments (void)
return (0);
}
#define ANDOR(s) (s[0] == '-' && (s[1] == 'a' || s[1] == 'o') && s[2] == 0)
/* This could be augmented to handle `-t' as equivalent to `-t 1', but
POSIX requires that `-t' be given an argument. */
#define ONE_ARG_TEST(s) ((s)[0] != '\0')
+12 -6
View File
@@ -279,18 +279,24 @@ b ( 1 = 2
./test.tests: line 26: test: (: unary operator expected
2
t -t a
1
./test.tests: line 26: test: a: integer expected
2
t -t addsds
1
./test.tests: line 26: test: addsds: integer expected
2
t -t 42
1
t -t /dev/tty
1
./test.tests: line 26: test: /dev/tty: integer expected
2
t -t /dev/tty4
1
./test.tests: line 26: test: /dev/tty4: integer expected
2
t -t /dev/tty4444444...
1
1
./test.tests: line 26: test: /dev/tty4444444...: integer expected
2
./test.tests: line 26: test: : integer expected
2
t -p /dev/fd/6
1
t -p /dev/fd/6
+4
View File
@@ -49,6 +49,10 @@ fff
x=10 fff
x=1 fff
x=4 fff2
# set this because variable assignments preceding functions should never
# persist after the function returns, no matter what a builtin inside the
# function does to them
x=4
x=11 fff3
echo after fff3: x=$x
x=12 fff4