fix obscure macOS issue where the Apple locale is set to something setlocale(3) doesn't understand; don't source .bash_logout if the shell is running setuid; fix for macOS issue with pipe size throttling and here-documents

This commit is contained in:
Chet Ramey
2026-07-14 09:29:04 -04:00
parent 0e16a4e4b1
commit 03e7298d1e
24 changed files with 2806 additions and 2336 deletions
+52
View File
@@ -13072,3 +13072,55 @@ lib/readline/display.c
local_prompt_newlines into the inv_lbreaks array in case the
prompt consumes more lines than the initial 256 inv_lbreaks size
Report from Ben Kallus <benjamin.p.kallus.gr@dartmouth.edu>
6/29
----
lib/intl/setlocale.c
- new version from gettext-1.0, fixes obscure macOS problem with the
Apple locale set to something setlocale() doesn't like
From https://savannah.gnu.org/bugs/?68453
lib/intl/localename.h,lib/intl/setlocale-fixes.h
- new files from gettext-1.0, to support new setlocale.c
7/1
---
general.c,general.h
- printable_filename: now takes a const char * as the first argument
builtins/help.def,builtins/history.def
- remove casts of first argument to printable_filename to char * now
that it takes a const char *
builtins/exit.def,shell.c
- bash_logout: move from exit.def to shell.c to localize startup and
logout file sourcing
- bash_logout: don't source ~/.bash_logout if the shell is running
setuid in the same way that we don't source startup files
externs.h
- bash_logout: extern declaration
doc/bash.1,doc/bashref.texi
- rewrote the section on startup behavior with euid != uid to avoid
the passive voice and add note that ~/.bash_logout isn't sourced
7/7
---
general.c,general.h
- sh_setnodelay: inverse of sh_unset_nodelay_mode, sets the file
descriptor argument to O_NONBLOCK/O_NDELAY mode
redir.c
- here_document_to_fd: if PIPESIZE_DYNAMIC is defined, we can't count
on the pipe capacity determined at compile time to be consistent
across systems, so we set the pipe's write end to O_NONBLOCK and
fall back to a temp file if the write fails
Report and patch from Ethan Pini <ethan@pini.dev>
configure.ac
- darwin: add PIPESIZE_DYNAMIC to LOCAL_CFLAGS, since macOS throttles
the pipe capacity down to 512 if the system as a whole is using too
much pipe capacity (16 MB by default)
+2
View File
@@ -277,6 +277,7 @@ lib/intl/localcharset.c f
lib/intl/localealias.c f
lib/intl/localename-table.c f
lib/intl/localename.c f
lib/intl/localename.h f
lib/intl/lock.c f
lib/intl/log.c f
lib/intl/ngettext.c f
@@ -292,6 +293,7 @@ lib/intl/relocatable.c f
lib/intl/setlocale-lock.c f
lib/intl/setlocale.c f
lib/intl/setlocale_null.c f
lib/intl/setlocale-fixes.h f
lib/intl/textdomain.c f
lib/intl/threadlib.c f
lib/intl/tsearch.c f
+1 -15
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-2024 Free Software Foundation, Inc.
Copyright (C) 1987-2026 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -49,7 +49,6 @@ $END
#include "builtext.h" /* for jobs_builtin */
static int exit_or_logout (WORD_LIST *);
static int sourced_logout;
int
exit_builtin (WORD_LIST *list)
@@ -152,16 +151,3 @@ exit_or_logout (WORD_LIST *list)
jump_to_top_level (EXITBLTIN);
/*NOTREACHED*/
}
void
bash_logout (void)
{
/* Run our `~/.bash_logout' file if it exists, and this is a login shell. */
if (login_shell && sourced_logout++ == 0 && subshell_environment == 0)
{
maybe_execute_file ("~/.bash_logout", 1);
#ifdef SYS_BASH_LOGOUT
maybe_execute_file (SYS_BASH_LOGOUT, 1);
#endif
}
}
+1 -1
View File
@@ -366,7 +366,7 @@ history_error (const char *filename, int e, int r)
#if defined (EACCES)
case EACCES:
#endif
newfn = printable_filename ((char *)filename, 0);
newfn = printable_filename (filename, 0);
if (r)
builtin_error ("%s: %s: %s", newfn, _("read error"), strerror (e));
else
Vendored
+2 -2
View File
@@ -1,5 +1,5 @@
#! /bin/sh
# From configure.ac for Bash 5.3, version 5.082.
# From configure.ac for Bash 5.3, version 5.083.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.72 for bash 5.3-maint.
#
@@ -23260,7 +23260,7 @@ hpux*) LOCAL_CFLAGS="-DHPUX -DTGETENT_BROKEN -DTGETFLAG_BROKEN" ;;
dgux*) LOCAL_CFLAGS=-D_DGUX_SOURCE; LOCAL_LIBS=-ldgc ;;
isc*) LOCAL_CFLAGS=-Disc386 ;;
rhapsody*) LOCAL_CFLAGS=-DRHAPSODY ;;
darwin*) LOCAL_CFLAGS=-DMACOSX ;;
darwin*) LOCAL_CFLAGS="-DMACOSX -DPIPESIZE_DYNAMIC" ;;
sco3.2v5*) LOCAL_CFLAGS="-b elf -DWAITPID_BROKEN -DPATH_MAX=1024" ;;
sco3.2v4*) LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DPATH_MAX=1024" ;;
sco3.2*) LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
+2 -2
View File
@@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_REVISION([for Bash 5.3, version 5.082])dnl
AC_REVISION([for Bash 5.3, version 5.083])dnl
define(bashvers, 5.3)
define(relstatus, maint)
@@ -1211,7 +1211,7 @@ hpux*) LOCAL_CFLAGS="-DHPUX -DTGETENT_BROKEN -DTGETFLAG_BROKEN" ;;
dgux*) LOCAL_CFLAGS=-D_DGUX_SOURCE; LOCAL_LIBS=-ldgc ;;
isc*) LOCAL_CFLAGS=-Disc386 ;;
rhapsody*) LOCAL_CFLAGS=-DRHAPSODY ;;
darwin*) LOCAL_CFLAGS=-DMACOSX ;;
darwin*) LOCAL_CFLAGS="-DMACOSX -DPIPESIZE_DYNAMIC" ;;
sco3.2v5*) LOCAL_CFLAGS="-b elf -DWAITPID_BROKEN -DPATH_MAX=1024" ;;
sco3.2v4*) LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DPATH_MAX=1024" ;;
sco3.2*) LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
+1960 -1958
View File
File diff suppressed because it is too large Load Diff
+21 -13
View File
@@ -5,7 +5,7 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Mon May 18 11:35:35 EDT 2026
.\" Last Change: Thu Jul 9 09:19:19 EDT 2026
.\"
.\" For bash_builtins, strip all but "SHELL BUILTIN COMMANDS" section
.\" For rbash, strip all but "RESTRICTED SHELL" section
@@ -22,7 +22,7 @@
.ds zX \" empty
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2026 May 18" "GNU Bash 5.3"
.TH BASH 1 "2026 July 1" "GNU Bash 5.3"
.\"
.ie \n(.g \{\
.ds ' \(aq
@@ -539,8 +539,12 @@ but neither
or allow them to be specified.
.PP
If the shell is started with the effective user (group) id not equal to the
real user (group) id, and the \fB\-p\fP option is not supplied, no startup
files are read, shell functions are not inherited from the environment, the
real user (group) id,
and the \fB\-p\fP option is not supplied,
bash does not attempt to read any startup files or
.FN \*~/.bash_logout ,
does not inherit shell functions from the environment,
ignores the
.SM
.BR SHELLOPTS ,
.SM
@@ -550,8 +554,8 @@ files are read, shell functions are not inherited from the environment, the
and
.SM
.B GLOBIGNORE
variables, if they appear in the environment, are ignored,
and the effective user id is set to the real user id.
variables, if they appear in the environment,
and sets the effective user id to the real user id.
If the \fB\-p\fP option is supplied at invocation, the startup behavior is
the same, but \fBbash\fP does not reset the effective user id.
.SH DEFINITIONS
@@ -7787,7 +7791,7 @@ the previous command.
Once the argument \fIn\fP is computed,
this uses the history expansion facilities to extract the
\fIn\fPth word, as if the
.Q !\fIn\fP
.Q !!:\fIn\fP
history expansion had been specified.
.TP
.B
@@ -11853,14 +11857,16 @@ on the standard output.
.B \-p
Turn on
.I privileged
mode. In this mode, the shell does not read the
mode.
In this mode, the shell does not read the
.SM
.B $ENV
and
.SM
.B $BASH_ENV
files, shell functions are not inherited from the
environment, and the
files,
does not inherit shell functions from the environment,
and ignores the
.SM
.BR SHELLOPTS ,
.SM
@@ -11870,10 +11876,12 @@ environment, and the
and
.SM
.B GLOBIGNORE
variables, if they appear in the environment, are ignored.
variables, if they appear in the environment.
If the shell is started with the effective user (group) id not equal to the
real user (group) id, and the \fB\-p\fP option is not supplied, these actions
are taken and the effective user id is set to the real user id.
real user (group) id,
and the \fB\-p\fP option is not supplied,
these actions are taken and the effective user id is set to the real user id
(see \fBINVOCATION\fP above for more details).
If the \fB\-p\fP option is supplied at startup, the effective user id is
not reset.
Turning this option off causes the effective user
+129 -126
View File
@@ -1,9 +1,9 @@
This is bash.info, produced by makeinfo version 7.3 from bashref.texi.
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 18 May 2026).
Bash shell (version 5.3, 1 July 2026).
This is Edition 5.3, last updated 18 May 2026, of The GNU Bash
This is Edition 5.3, last updated 1 July 2026, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Copyright © 1988-2026 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, 18 May 2026). The Bash home page is
Bash shell (version 5.3, 1 July 2026). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.3, last updated 18 May 2026, of The GNU Bash
This is Edition 5.3, last updated 1 July 2026, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Bash contains features that appear in other popular shells, and some
@@ -5083,18 +5083,18 @@ parameters, or to display the names and values of shell variables.
Same as -x.
-p
Turn on privileged mode. In this mode, the $BASH_ENV and
$ENV files are not processed, shell functions are not
inherited from the environment, and the SHELLOPTS,
Turn on privileged mode. In this mode, Bash does not process
the $BASH_ENV and $ENV files, does not inherit shell
functions from the environment, and ignores the SHELLOPTS,
BASHOPTS, CDPATH and GLOBIGNORE variables, if they
appear 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 -p option is not supplied,
these actions are taken and the effective user id is set to
the real user id. If the -p option is supplied 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.
appear in the environment. If the shell is started with the
effective user (group) id not equal to the real user (group)
id, and the -p option is not supplied, these actions are
taken and the effective user id is set to the real user id
(*note Bash Startup Files:: for details). If the -p option
is supplied 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.
-r
Enable restricted shell mode (*note The Restricted Shell::).
@@ -6808,13 +6808,13 @@ Invoked with unequal effective and real UID/GIDs
................................................
If Bash is started with the effective user (group) id not equal to the
real user (group) id, and the -p option is not supplied, no startup
files are read, shell functions are not inherited from the environment,
the SHELLOPTS, BASHOPTS, CDPATH, and GLOBIGNORE variables, if
they appear in the environment, are ignored, and the effective user id
is set to the real user id. If the -p option is supplied at
invocation, the startup behavior is the same, but Bash does not reset
the effective user id.
real user (group) id, and the -p option is not supplied, Bash does not
attempt to read any startup files or ~/.bash_logout, does not inherit
shell functions from the environment, ignores the SHELLOPTS,
BASHOPTS, CDPATH, and GLOBIGNORE variables, if they appear in the
environment, and sets the effective user id to the real user id. If the
-p option is supplied at invocation, the startup behavior is the same,
but Bash does not reset the effective user id.

File: bash.info, Node: Interactive Shells, Next: Bash Conditional Expressions, Prev: Bash Startup Files, Up: Bash Features
@@ -7623,9 +7623,9 @@ can appear in the prompt variables PS0, PS1, PS2, and PS4
\[
Begin a sequence of non-printing characters. This could be used to
embed a terminal control sequence into the prompt. This escape is
only useful when the prompt will be supplied to Readline, so it
shouldn't be used in PS0 or PS4, or when line editing is not
enabled.
only useful when the prompt will be supplied to Readline, and is
ignored and removed otherwise, so it shouldn't be used in PS0 or
PS4, or when line editing is not enabled.
\]
End a sequence of non-printing characters begun with \[
@@ -7984,100 +7984,103 @@ startup files.
supplied as an argument exceeds PATH_MAX when canonicalized, cd
will attempt to use the supplied directory name.
52. When the xpg_echo option is enabled, Bash does not attempt to
52. The command builtin prints command name arguments containing a
slash as full pathnames when the -v option is supplied.
53. When the xpg_echo option is enabled, Bash does not attempt to
interpret any arguments to echo as options. echo displays each
argument after converting escape sequences.
53. The export and readonly builtin commands display their output
54. The export and readonly builtin commands display their output
in the format required by POSIX.
54. When listing the history, the fc builtin does not include an
55. When listing the history, the fc builtin does not include an
indication of whether or not a history entry has been modified.
55. The default editor used by fc is ed.
56. The default editor used by fc is ed.
56. fc treats extra arguments as an error instead of ignoring them.
57. fc treats extra arguments as an error instead of ignoring them.
57. If there are too many arguments supplied to fc -s, fc prints
58. If there are too many arguments supplied to fc -s, fc prints
an error message and returns failure.
58. The output of kill -l prints all the signal names on a single
59. The output of kill -l prints all the signal names on a single
line, separated by spaces, without the SIG prefix.
59. The kill builtin does not accept signal names with a SIG
60. The kill builtin does not accept signal names with a SIG
prefix.
60. The kill builtin returns a failure status if any of the pid or
61. The kill builtin returns a failure status if any of the pid or
job arguments are invalid or if sending the specified signal to any
of them fails. In default mode, kill returns success if the
signal was successfully sent to any of the specified processes.
61. The printf builtin uses double (via strtod) to convert
62. The printf builtin uses double (via strtod) to convert
arguments corresponding to floating point conversion specifiers,
instead of long double if it's available. The L length
modifier forces printf to use long double if it's available.
62. The pwd builtin verifies that the value it prints is the same as
63. The pwd builtin verifies that the value it prints is the same as
the current directory, even if it is not asked to check the file
system with the -P option.
63. The read builtin may be interrupted by a signal for which a trap
64. The read builtin may be interrupted by a signal for which a trap
has been set. If Bash receives a trapped signal while executing
read, the trap handler executes and read returns an exit status
greater than 128.
64. When the set builtin is invoked without options, it does not
65. When the set builtin is invoked without options, it does not
display shell function names and definitions.
65. When the set builtin is invoked without options, it displays
66. When the set builtin is invoked without options, it displays
variable values without quotes, unless they contain shell
metacharacters, even if the result contains nonprinting characters.
66. The test builtin compares strings using the current locale when
67. The test builtin compares strings using the current locale when
evaluating the < and > binary operators.
67. The test builtin's -t unary primary requires an argument.
68. 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. The trap builtin displays signal names without the leading
69. The trap builtin displays signal names without the leading
SIG.
69. The trap builtin doesn't check the first argument for a possible
70. The trap builtin doesn't check the first argument for a possible
signal specification and revert the signal handling to the original
disposition if it is, unless that argument consists solely of
digits and is a valid signal number. If users want to reset the
handler for a given signal to the original disposition, they should
use - as the first argument.
70. trap -p without arguments displays signals whose dispositions
71. trap -p without arguments displays signals whose dispositions
are set to SIG_DFL and those that were ignored when the shell
started, not just trapped signals.
71. The type and command builtins will not report a non-executable
72. The type and command builtins will not report a non-executable
file as having been found, though the shell will attempt to execute
such a file if it is the only so-named file found in $PATH.
72. The ulimit builtin uses a block size of 512 bytes for the -c
73. The ulimit builtin uses a block size of 512 bytes for the -c
and -f options.
73. The unset builtin with the -v option specified returns a fatal
74. The unset builtin with the -v option specified returns a fatal
error if it attempts to unset a readonly or non-unsettable
variable, which causes a non-interactive shell to exit.
74. When asked to unset a variable that appears in an assignment
75. When asked to unset a variable that appears in an assignment
statement preceding the command, the unset builtin attempts to
unset a variable of the same name in the current or previous scope
as well. This implements the required "if an assigned variable is
further modified by the utility, the modifications made by the
utility shall persist" behavior.
75. The arrival of SIGCHLD when a trap is set on SIGCHLD does not
76. The arrival of SIGCHLD when a trap is set on SIGCHLD does not
interrupt the wait builtin and cause it to return immediately.
The trap command is run once for each child that exits.
76. Bash removes an exited background process's status from the list
77. Bash removes an exited background process's status from the list
of such statuses after the wait builtin returns it.
There is additional POSIX behavior that Bash does not implement by
@@ -13824,82 +13827,82 @@ Node: Bourne Shell Builtins155613
Node: Bash Builtins182332
Node: Modifying Shell Behavior220067
Node: The Set Builtin220409
Node: The Shopt Builtin232403
Node: Special Builtins249456
Node: Shell Variables250445
Node: Bourne Shell Variables250879
Node: Bash Variables253387
Node: Bash Features292671
Node: Invoking Bash293685
Node: Bash Startup Files300915
Node: Interactive Shells306237
Node: What is an Interactive Shell?306645
Node: Is this Shell Interactive?307307
Node: Interactive Shell Behavior308131
Node: Bash Conditional Expressions311892
Node: Shell Arithmetic317309
Node: Aliases320636
Node: Arrays323770
Node: The Directory Stack331472
Node: Directory Stack Builtins332269
Node: Controlling the Prompt336714
Node: The Restricted Shell339795
Node: Bash POSIX Mode342888
Node: Shell Compatibility Mode362704
Node: Job Control371711
Node: Job Control Basics372168
Node: Job Control Builtins378536
Node: Job Control Variables385324
Node: Command Line Editing386555
Node: Introduction and Notation388258
Node: Readline Interaction390610
Node: Readline Bare Essentials391798
Node: Readline Movement Commands393606
Node: Readline Killing Commands394602
Node: Readline Arguments396625
Node: Searching397715
Node: Readline Init File399958
Node: Readline Init File Syntax401261
Node: Conditional Init Constructs428212
Node: Sample Init File432597
Node: Bindable Readline Commands435717
Node: Commands For Moving437255
Node: Commands For History439719
Node: Commands For Text445110
Node: Commands For Killing449235
Node: Numeric Arguments452023
Node: Commands For Completion453175
Node: Keyboard Macros458871
Node: Miscellaneous Commands459572
Node: Readline vi Mode467115
Node: Programmable Completion468092
Node: Programmable Completion Builtins477828
Node: A Programmable Completion Example489565
Node: Using History Interactively494910
Node: Bash History Facilities495591
Node: Bash History Builtins499326
Node: History Interaction506921
Node: Event Designators511871
Node: Word Designators513449
Node: Modifiers515841
Node: Installing Bash517778
Node: Basic Installation518894
Node: Compilers and Options522770
Node: Compiling For Multiple Architectures523520
Node: Installation Names525273
Node: Specifying the System Type527507
Node: Sharing Defaults528253
Node: Operation Controls528967
Node: Optional Features529986
Node: Reporting Bugs542709
Node: Major Differences From The Bourne Shell544066
Node: GNU Free Documentation License565493
Node: Indexes590670
Node: Builtin Index591121
Node: Reserved Word Index598219
Node: Variable Index600664
Node: Function Index618077
Node: Concept Index632210
Node: The Shopt Builtin232441
Node: Special Builtins249494
Node: Shell Variables250483
Node: Bourne Shell Variables250917
Node: Bash Variables253425
Node: Bash Features292709
Node: Invoking Bash293723
Node: Bash Startup Files300953
Node: Interactive Shells306313
Node: What is an Interactive Shell?306721
Node: Is this Shell Interactive?307383
Node: Interactive Shell Behavior308207
Node: Bash Conditional Expressions311968
Node: Shell Arithmetic317385
Node: Aliases320712
Node: Arrays323846
Node: The Directory Stack331548
Node: Directory Stack Builtins332345
Node: Controlling the Prompt336790
Node: The Restricted Shell339909
Node: Bash POSIX Mode343002
Node: Shell Compatibility Mode362961
Node: Job Control371968
Node: Job Control Basics372425
Node: Job Control Builtins378793
Node: Job Control Variables385581
Node: Command Line Editing386812
Node: Introduction and Notation388515
Node: Readline Interaction390867
Node: Readline Bare Essentials392055
Node: Readline Movement Commands393863
Node: Readline Killing Commands394859
Node: Readline Arguments396882
Node: Searching397972
Node: Readline Init File400215
Node: Readline Init File Syntax401518
Node: Conditional Init Constructs428469
Node: Sample Init File432854
Node: Bindable Readline Commands435974
Node: Commands For Moving437512
Node: Commands For History439976
Node: Commands For Text445367
Node: Commands For Killing449492
Node: Numeric Arguments452280
Node: Commands For Completion453432
Node: Keyboard Macros459128
Node: Miscellaneous Commands459829
Node: Readline vi Mode467372
Node: Programmable Completion468349
Node: Programmable Completion Builtins478085
Node: A Programmable Completion Example489822
Node: Using History Interactively495167
Node: Bash History Facilities495848
Node: Bash History Builtins499583
Node: History Interaction507178
Node: Event Designators512128
Node: Word Designators513706
Node: Modifiers516098
Node: Installing Bash518035
Node: Basic Installation519151
Node: Compilers and Options523027
Node: Compiling For Multiple Architectures523777
Node: Installation Names525530
Node: Specifying the System Type527764
Node: Sharing Defaults528510
Node: Operation Controls529224
Node: Optional Features530243
Node: Reporting Bugs542966
Node: Major Differences From The Bourne Shell544323
Node: GNU Free Documentation License565750
Node: Indexes590927
Node: Builtin Index591378
Node: Reserved Word Index598476
Node: Variable Index600921
Node: Function Index618334
Node: Concept Index632467

End Tag Table
+129 -126
View File
@@ -2,9 +2,9 @@ This is bashref.info, produced by makeinfo version 7.3 from
bashref.texi.
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 18 May 2026).
Bash shell (version 5.3, 1 July 2026).
This is Edition 5.3, last updated 18 May 2026, of The GNU Bash
This is Edition 5.3, last updated 1 July 2026, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Copyright © 1988-2026 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, 18 May 2026). The Bash home page is
Bash shell (version 5.3, 1 July 2026). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.3, last updated 18 May 2026, of The GNU Bash
This is Edition 5.3, last updated 1 July 2026, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Bash contains features that appear in other popular shells, and some
@@ -5084,18 +5084,18 @@ parameters, or to display the names and values of shell variables.
Same as -x.
-p
Turn on privileged mode. In this mode, the $BASH_ENV and
$ENV files are not processed, shell functions are not
inherited from the environment, and the SHELLOPTS,
Turn on privileged mode. In this mode, Bash does not process
the $BASH_ENV and $ENV files, does not inherit shell
functions from the environment, and ignores the SHELLOPTS,
BASHOPTS, CDPATH and GLOBIGNORE variables, if they
appear 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 -p option is not supplied,
these actions are taken and the effective user id is set to
the real user id. If the -p option is supplied 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.
appear in the environment. If the shell is started with the
effective user (group) id not equal to the real user (group)
id, and the -p option is not supplied, these actions are
taken and the effective user id is set to the real user id
(*note Bash Startup Files:: for details). If the -p option
is supplied 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.
-r
Enable restricted shell mode (*note The Restricted Shell::).
@@ -6809,13 +6809,13 @@ Invoked with unequal effective and real UID/GIDs
................................................
If Bash is started with the effective user (group) id not equal to the
real user (group) id, and the -p option is not supplied, no startup
files are read, shell functions are not inherited from the environment,
the SHELLOPTS, BASHOPTS, CDPATH, and GLOBIGNORE variables, if
they appear in the environment, are ignored, and the effective user id
is set to the real user id. If the -p option is supplied at
invocation, the startup behavior is the same, but Bash does not reset
the effective user id.
real user (group) id, and the -p option is not supplied, Bash does not
attempt to read any startup files or ~/.bash_logout, does not inherit
shell functions from the environment, ignores the SHELLOPTS,
BASHOPTS, CDPATH, and GLOBIGNORE variables, if they appear in the
environment, and sets the effective user id to the real user id. If the
-p option is supplied at invocation, the startup behavior is the same,
but Bash does not reset the effective user id.

File: bashref.info, Node: Interactive Shells, Next: Bash Conditional Expressions, Prev: Bash Startup Files, Up: Bash Features
@@ -7624,9 +7624,9 @@ can appear in the prompt variables PS0, PS1, PS2, and PS4
\[
Begin a sequence of non-printing characters. This could be used to
embed a terminal control sequence into the prompt. This escape is
only useful when the prompt will be supplied to Readline, so it
shouldn't be used in PS0 or PS4, or when line editing is not
enabled.
only useful when the prompt will be supplied to Readline, and is
ignored and removed otherwise, so it shouldn't be used in PS0 or
PS4, or when line editing is not enabled.
\]
End a sequence of non-printing characters begun with \[
@@ -7985,100 +7985,103 @@ startup files.
supplied as an argument exceeds PATH_MAX when canonicalized, cd
will attempt to use the supplied directory name.
52. When the xpg_echo option is enabled, Bash does not attempt to
52. The command builtin prints command name arguments containing a
slash as full pathnames when the -v option is supplied.
53. When the xpg_echo option is enabled, Bash does not attempt to
interpret any arguments to echo as options. echo displays each
argument after converting escape sequences.
53. The export and readonly builtin commands display their output
54. The export and readonly builtin commands display their output
in the format required by POSIX.
54. When listing the history, the fc builtin does not include an
55. When listing the history, the fc builtin does not include an
indication of whether or not a history entry has been modified.
55. The default editor used by fc is ed.
56. The default editor used by fc is ed.
56. fc treats extra arguments as an error instead of ignoring them.
57. fc treats extra arguments as an error instead of ignoring them.
57. If there are too many arguments supplied to fc -s, fc prints
58. If there are too many arguments supplied to fc -s, fc prints
an error message and returns failure.
58. The output of kill -l prints all the signal names on a single
59. The output of kill -l prints all the signal names on a single
line, separated by spaces, without the SIG prefix.
59. The kill builtin does not accept signal names with a SIG
60. The kill builtin does not accept signal names with a SIG
prefix.
60. The kill builtin returns a failure status if any of the pid or
61. The kill builtin returns a failure status if any of the pid or
job arguments are invalid or if sending the specified signal to any
of them fails. In default mode, kill returns success if the
signal was successfully sent to any of the specified processes.
61. The printf builtin uses double (via strtod) to convert
62. The printf builtin uses double (via strtod) to convert
arguments corresponding to floating point conversion specifiers,
instead of long double if it's available. The L length
modifier forces printf to use long double if it's available.
62. The pwd builtin verifies that the value it prints is the same as
63. The pwd builtin verifies that the value it prints is the same as
the current directory, even if it is not asked to check the file
system with the -P option.
63. The read builtin may be interrupted by a signal for which a trap
64. The read builtin may be interrupted by a signal for which a trap
has been set. If Bash receives a trapped signal while executing
read, the trap handler executes and read returns an exit status
greater than 128.
64. When the set builtin is invoked without options, it does not
65. When the set builtin is invoked without options, it does not
display shell function names and definitions.
65. When the set builtin is invoked without options, it displays
66. When the set builtin is invoked without options, it displays
variable values without quotes, unless they contain shell
metacharacters, even if the result contains nonprinting characters.
66. The test builtin compares strings using the current locale when
67. The test builtin compares strings using the current locale when
evaluating the < and > binary operators.
67. The test builtin's -t unary primary requires an argument.
68. 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. The trap builtin displays signal names without the leading
69. The trap builtin displays signal names without the leading
SIG.
69. The trap builtin doesn't check the first argument for a possible
70. The trap builtin doesn't check the first argument for a possible
signal specification and revert the signal handling to the original
disposition if it is, unless that argument consists solely of
digits and is a valid signal number. If users want to reset the
handler for a given signal to the original disposition, they should
use - as the first argument.
70. trap -p without arguments displays signals whose dispositions
71. trap -p without arguments displays signals whose dispositions
are set to SIG_DFL and those that were ignored when the shell
started, not just trapped signals.
71. The type and command builtins will not report a non-executable
72. The type and command builtins will not report a non-executable
file as having been found, though the shell will attempt to execute
such a file if it is the only so-named file found in $PATH.
72. The ulimit builtin uses a block size of 512 bytes for the -c
73. The ulimit builtin uses a block size of 512 bytes for the -c
and -f options.
73. The unset builtin with the -v option specified returns a fatal
74. The unset builtin with the -v option specified returns a fatal
error if it attempts to unset a readonly or non-unsettable
variable, which causes a non-interactive shell to exit.
74. When asked to unset a variable that appears in an assignment
75. When asked to unset a variable that appears in an assignment
statement preceding the command, the unset builtin attempts to
unset a variable of the same name in the current or previous scope
as well. This implements the required "if an assigned variable is
further modified by the utility, the modifications made by the
utility shall persist" behavior.
75. The arrival of SIGCHLD when a trap is set on SIGCHLD does not
76. The arrival of SIGCHLD when a trap is set on SIGCHLD does not
interrupt the wait builtin and cause it to return immediately.
The trap command is run once for each child that exits.
76. Bash removes an exited background process's status from the list
77. Bash removes an exited background process's status from the list
of such statuses after the wait builtin returns it.
There is additional POSIX behavior that Bash does not implement by
@@ -13825,82 +13828,82 @@ Node: Bourne Shell Builtins155772
Node: Bash Builtins182494
Node: Modifying Shell Behavior220232
Node: The Set Builtin220577
Node: The Shopt Builtin232574
Node: Special Builtins249630
Node: Shell Variables250622
Node: Bourne Shell Variables251059
Node: Bash Variables253570
Node: Bash Features292857
Node: Invoking Bash293874
Node: Bash Startup Files301107
Node: Interactive Shells306432
Node: What is an Interactive Shell?306843
Node: Is this Shell Interactive?307508
Node: Interactive Shell Behavior308335
Node: Bash Conditional Expressions312099
Node: Shell Arithmetic317519
Node: Aliases320849
Node: Arrays323986
Node: The Directory Stack331691
Node: Directory Stack Builtins332491
Node: Controlling the Prompt336939
Node: The Restricted Shell340023
Node: Bash POSIX Mode343119
Node: Shell Compatibility Mode362938
Node: Job Control371948
Node: Job Control Basics372408
Node: Job Control Builtins378779
Node: Job Control Variables385570
Node: Command Line Editing386804
Node: Introduction and Notation388510
Node: Readline Interaction390865
Node: Readline Bare Essentials392056
Node: Readline Movement Commands393867
Node: Readline Killing Commands394866
Node: Readline Arguments396892
Node: Searching397985
Node: Readline Init File400231
Node: Readline Init File Syntax401537
Node: Conditional Init Constructs428491
Node: Sample Init File432879
Node: Bindable Readline Commands436002
Node: Commands For Moving437543
Node: Commands For History440010
Node: Commands For Text445404
Node: Commands For Killing449532
Node: Numeric Arguments452323
Node: Commands For Completion453478
Node: Keyboard Macros459177
Node: Miscellaneous Commands459881
Node: Readline vi Mode467427
Node: Programmable Completion468407
Node: Programmable Completion Builtins478146
Node: A Programmable Completion Example489886
Node: Using History Interactively495234
Node: Bash History Facilities495918
Node: Bash History Builtins499656
Node: History Interaction507254
Node: Event Designators512207
Node: Word Designators513788
Node: Modifiers516183
Node: Installing Bash518123
Node: Basic Installation519242
Node: Compilers and Options523121
Node: Compiling For Multiple Architectures523874
Node: Installation Names525630
Node: Specifying the System Type527867
Node: Sharing Defaults528616
Node: Operation Controls529333
Node: Optional Features530355
Node: Reporting Bugs543081
Node: Major Differences From The Bourne Shell544441
Node: GNU Free Documentation License565871
Node: Indexes591051
Node: Builtin Index591505
Node: Reserved Word Index598606
Node: Variable Index601054
Node: Function Index618470
Node: Concept Index632606
Node: The Shopt Builtin232612
Node: Special Builtins249668
Node: Shell Variables250660
Node: Bourne Shell Variables251097
Node: Bash Variables253608
Node: Bash Features292895
Node: Invoking Bash293912
Node: Bash Startup Files301145
Node: Interactive Shells306508
Node: What is an Interactive Shell?306919
Node: Is this Shell Interactive?307584
Node: Interactive Shell Behavior308411
Node: Bash Conditional Expressions312175
Node: Shell Arithmetic317595
Node: Aliases320925
Node: Arrays324062
Node: The Directory Stack331767
Node: Directory Stack Builtins332567
Node: Controlling the Prompt337015
Node: The Restricted Shell340137
Node: Bash POSIX Mode343233
Node: Shell Compatibility Mode363195
Node: Job Control372205
Node: Job Control Basics372665
Node: Job Control Builtins379036
Node: Job Control Variables385827
Node: Command Line Editing387061
Node: Introduction and Notation388767
Node: Readline Interaction391122
Node: Readline Bare Essentials392313
Node: Readline Movement Commands394124
Node: Readline Killing Commands395123
Node: Readline Arguments397149
Node: Searching398242
Node: Readline Init File400488
Node: Readline Init File Syntax401794
Node: Conditional Init Constructs428748
Node: Sample Init File433136
Node: Bindable Readline Commands436259
Node: Commands For Moving437800
Node: Commands For History440267
Node: Commands For Text445661
Node: Commands For Killing449789
Node: Numeric Arguments452580
Node: Commands For Completion453735
Node: Keyboard Macros459434
Node: Miscellaneous Commands460138
Node: Readline vi Mode467684
Node: Programmable Completion468664
Node: Programmable Completion Builtins478403
Node: A Programmable Completion Example490143
Node: Using History Interactively495491
Node: Bash History Facilities496175
Node: Bash History Builtins499913
Node: History Interaction507511
Node: Event Designators512464
Node: Word Designators514045
Node: Modifiers516440
Node: Installing Bash518380
Node: Basic Installation519499
Node: Compilers and Options523378
Node: Compiling For Multiple Architectures524131
Node: Installation Names525887
Node: Specifying the System Type528124
Node: Sharing Defaults528873
Node: Operation Controls529590
Node: Optional Features530612
Node: Reporting Bugs543338
Node: Major Differences From The Bourne Shell544698
Node: GNU Free Documentation License566128
Node: Indexes591308
Node: Builtin Index591762
Node: Reserved Word Index598863
Node: Variable Index601311
Node: Function Index618727
Node: Concept Index632863

End Tag Table
+19 -11
View File
@@ -6175,13 +6175,16 @@ Same as @code{-x}.
@item -p
Turn on privileged mode.
In this mode, the @env{$BASH_ENV} and @env{$ENV} files are not
processed, shell functions are not inherited from the environment,
and the @env{SHELLOPTS}, @env{BASHOPTS}, @env{CDPATH} and @env{GLOBIGNORE}
variables, if they appear in the environment, are ignored.
In this mode, Bash does not process the @env{$BASH_ENV} and @env{$ENV} files,
does not inherit shell functions from the environment,
and ignores the
@env{SHELLOPTS}, @env{BASHOPTS}, @env{CDPATH} and @env{GLOBIGNORE}
variables, if they appear in the environment.
If the shell is started with the effective user (group) id not equal to the
real user (group) id, and the @option{-p} option is not supplied, these actions
are taken and the effective user id is set to the real user id.
real user (group) id,
and the @option{-p} option is not supplied,
these actions are taken and the effective user id is set to the real user id
(@pxref{Bash Startup Files} for details).
If the @option{-p} option is supplied at startup, the effective user id is
not reset.
Turning this option off causes the effective user
@@ -8182,11 +8185,16 @@ options or allow them to be specified.
@subsubheading Invoked with unequal effective and real @sc{uid/gid}s
If Bash is started with the effective user (group) id not equal to the
real user (group) id, and the @option{-p} option is not supplied, no startup
files are read, shell functions are not inherited from the environment,
the @env{SHELLOPTS}, @env{BASHOPTS}, @env{CDPATH}, and @env{GLOBIGNORE}
variables, if they appear in the environment, are ignored, and the effective
user id is set to the real user id.
real user (group) id,
and the @option{-p} option is not supplied,
Bash does not attempt to read any startup files or
@file{~/.bash_logout},
does not inherit shell functions from the environment,
ignores the
@env{SHELLOPTS}, @env{BASHOPTS}, @env{CDPATH}, and @env{GLOBIGNORE}
variables,
if they appear in the environment,
and sets the effective user id to the real user id.
If the @option{-p} option is supplied at invocation, the startup behavior is
the same, but Bash does not reset the effective user id.
+3 -3
View File
@@ -2,10 +2,10 @@
Copyright (C) 1988-2026 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Mon May 18 11:35:01 EDT 2026
@set LASTCHANGE Thu Jul 9 09:19:32 EDT 2026
@set EDITION 5.3
@set VERSION 5.3
@set UPDATED 18 May 2026
@set UPDATED-MONTH May 2026
@set UPDATED 9 July 2026
@set UPDATED-MONTH July 2026
+3 -1
View File
@@ -1,7 +1,7 @@
/* externs.h -- extern function declarations which do not appear in their
own header file. */
/* Copyright (C) 1993-2025 Free Software Foundation, Inc.
/* Copyright (C) 1993-2026 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -87,6 +87,8 @@ extern void set_exit_status (int);
extern void disable_priv_mode (void);
extern void unbind_args (void);
extern void bash_logout (void);
#if defined (RESTRICTED_SHELL)
extern int shell_is_restricted (char *);
extern int maybe_make_restricted (char *);
+23 -2
View File
@@ -615,6 +615,27 @@ sh_unset_nodelay_mode (int fd)
return 0;
}
int
sh_setnodelay (int fd)
{
int flags;
if ((flags = fcntl (fd, F_GETFL, 0)) < 0)
return -1;
/* This is defined to O_NDELAY in filecntl.h if O_NONBLOCK is not present
and O_NDELAY is defined. */
#ifdef O_NONBLOCK
flags |= O_NONBLOCK;
#endif
#ifdef O_NDELAY
flags |= O_NDELAY;
#endif
return (fcntl (fd, F_SETFL, flags));
}
/* Just a wrapper for the define in include/filecntl.h */
int
sh_setclexec (int fd)
@@ -1036,7 +1057,7 @@ trim_pathname (char *name, int maxlen)
than its argument. If FLAGS is non-zero, we are printing for portable
re-input and should single-quote filenames appropriately. */
char *
printable_filename (char *fn, int flags)
printable_filename (const char *fn, int flags)
{
char *newf;
@@ -1045,7 +1066,7 @@ printable_filename (char *fn, int flags)
else if (flags && sh_contains_shell_metas (fn))
newf = sh_single_quote (fn);
else
newf = fn;
newf = (char *)fn;
return newf;
}
+2 -1
View File
@@ -320,6 +320,7 @@ extern int line_isblank (const char *);
extern int assignment (const char *, int);
extern int sh_unset_nodelay_mode (int);
extern int sh_setnodelay (int);
extern int sh_setclexec (int);
extern int sh_validfd (int);
extern int fd_ispipe (int);
@@ -346,7 +347,7 @@ extern char *base_pathname (char *);
extern char *full_pathname (char *);
extern char *polite_directory_format (char *);
extern char *trim_pathname (char *, int);
extern char *printable_filename (char *, int);
extern char *printable_filename (const char *, int);
extern char *extract_colon_unit (char *, int *);
+1
View File
@@ -86,6 +86,7 @@ HEADERS = gmo.h gettextP.h hash-string.h loadinfo.h plural-exp.h \
thread-optim.h tsearch.h verify.h xsize.h \
printf-args.h printf-parse.h wprintf-parse.h \
export.h os2compat.h plural-exp.h vasnprintf.h vasnwprintf.h \
localename.h \
libgnuintl.in.h
SOURCES = bindtextdom.c dcgettext.c dgettext.c gettext.c \
+113
View File
@@ -0,0 +1,113 @@
/* Determine name of the currently selected locale.
Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_LOCALENAME_H
#define _GL_LOCALENAME_H
/* This file uses _GL_ATTRIBUTE_CONST, HAVE_CFPREFERENCESCOPYAPPVALUE. */
#ifdef __cplusplus
extern "C" {
#endif
/* Determine the current locale's name.
It considers both the POSIX notion of locale name (see functions
gl_locale_name_thread and gl_locale_name_posix) and the system notion
of locale name (see function gl_locale_name_default).
CATEGORY is a locale category abbreviation, as defined in <locale.h>,
but not LC_ALL. E.g. LC_MESSAGES.
CATEGORYNAME is the name of CATEGORY as a string, e.g. "LC_MESSAGES".
Return the locale category's name, canonicalized into XPG syntax
language[_territory][.codeset][@modifier]
The codeset part in the result is not reliable; the locale_charset()
should be used for codeset information instead.
The result must not be freed; it is statically allocated. */
extern const char * gl_locale_name (int category, const char *categoryname);
/* Determine the current per-thread locale's name, as specified by uselocale()
calls.
CATEGORY is a locale category abbreviation, as defined in <locale.h>,
but not LC_ALL. E.g. LC_MESSAGES.
CATEGORYNAME is the name of CATEGORY as a string, e.g. "LC_MESSAGES".
Return the locale category's name, canonicalized into XPG syntax
language[_territory][.codeset][@modifier]
or NULL if no locale has been specified for the current thread.
The codeset part in the result is not reliable; the locale_charset()
should be used for codeset information instead.
The result must not be freed; it is statically allocated. */
extern const char * gl_locale_name_thread (int category, const char *categoryname);
/* Determine the thread-independent current locale's name, as specified by
setlocale() calls or by environment variables.
CATEGORY is a locale category abbreviation, as defined in <locale.h>,
but not LC_ALL. E.g. LC_MESSAGES.
CATEGORYNAME is the name of CATEGORY as a string, e.g. "LC_MESSAGES".
Return the locale category's name, canonicalized into XPG syntax
language[_territory][.codeset][@modifier]
or NULL if no locale has been specified to setlocale() or by environment
variables.
The codeset part in the result is not reliable; the locale_charset()
should be used for codeset information instead.
The result must not be freed; it is statically allocated. */
extern const char * gl_locale_name_posix (int category, const char *categoryname);
/* Determine the default locale's name, as specified by environment
variables.
Return the locale category's name, or NULL if no locale has been specified
by environment variables.
The result must not be freed; it is statically allocated. */
extern const char * gl_locale_name_environ (int category, const char *categoryname);
/* Determine the default locale's name. This is the current locale's name,
if not specified by uselocale() calls, by setlocale() calls, or by
environment variables. This locale name is usually determined by systems
settings that the user can manipulate through a GUI.
Quoting POSIX:2001:
"All implementations shall define a locale as the default locale,
to be invoked when no environment variables are set, or set to the
empty string. This default locale can be the C locale or any other
implementation-defined locale. Some implementations may provide
facilities for local installation administrators to set the default
locale, customizing it for each location. IEEE Std 1003.1-2001 does
not require such a facility."
The result must not be freed; it is statically allocated. */
extern const char * gl_locale_name_default (void)
#if !(HAVE_CFPREFERENCESCOPYAPPVALUE || defined _WIN32 || defined __CYGWIN__)
_GL_ATTRIBUTE_CONST
#endif
;
/* These functions with the '_unsafe' suffix are like the functions without
this suffix, above, except that the result is not statically allocated, but
instead only valid in the current thread, until the next uselocale(),
setlocale(), newlocale(), or freelocale() call. */
extern const char * gl_locale_name_unsafe (int category,
const char *categoryname);
extern const char * gl_locale_name_thread_unsafe (int category,
const char *categoryname);
extern const char * gl_locale_name_posix_unsafe (int category,
const char *categoryname);
#ifdef __cplusplus
}
#endif
#endif /* _GL_LOCALENAME_H */
+64
View File
@@ -0,0 +1,64 @@
/* Make the global locale minimally POSIX compliant.
Copyright (C) 2025-2026 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2025. */
#ifndef _SETLOCALE_FIXES_H
#define _SETLOCALE_FIXES_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined _WIN32 && !defined __CYGWIN__
/* This section is only relevant on platforms that lack LC_MESSAGES, namely
native Windows. */
/* setlocale_messages (NAME) is like setlocale (LC_MESSAGES, NAME). */
extern const char *setlocale_messages (const char *name);
/* setlocale_messages_null () is like setlocale (LC_MESSAGES, NULL), except that
it is guaranteed to be multithread-safe. */
extern const char *setlocale_messages_null (void);
#endif
#if defined __ANDROID__
/* This section is only relevant on Android.
While OpenBSD ≥ 6.2 and Android API level >= 21 have a fake locale_t type,
regarding the global locale, OpenBSD at least stores the name of each
category of the global locale. Android doesn't do this, and additionally
has a bug: setting any category != LC_CTYPE of the global locale affects
the LC_CTYPE category as well. */
/* Like setlocale (CATEGORY, NAME), but fixes these two Android bugs. */
extern const char *setlocale_fixed (int category, const char *name);
/* Like setlocale_null (CATEGORY), but consistent with setlocale_fixed. */
extern const char *setlocale_fixed_null (int category);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SETLOCALE_FIXES_H */
+234 -69
View File
@@ -1,6 +1,5 @@
/* setlocale() function that respects the locale chosen by the user.
Copyright (C) 2009, 2011, 2013, 2018-2019 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
Copyright (C) 2009-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -15,6 +14,8 @@
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
@@ -25,23 +26,40 @@
This matters on MacOS X 10 and Windows.
See the comments in localename.c, function gl_locale_name_default. */
/* Specification. */
#include <locale.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* When building a DLL, we must export some functions. Note that because
the functions are only defined for binary backward compatibility, we
don't need to use __declspec(dllimport) in any case. */
#if HAVE_VISIBILITY && BUILDING_DLL
# define DLL_EXPORTED __attribute__((__visibility__("default")))
#elif defined _MSC_VER && BUILDING_DLL
# define DLL_EXPORTED __declspec(dllexport)
/* When building a shared library, we must export some functions.
Note that because this is a .c file, not a .h file, we don't need to use
__declspec(dllimport) in any case. */
#if HAVE_VISIBILITY && BUILDING_LIBRARY
# define SHLIB_EXPORTED __attribute__((__visibility__("default")))
#elif defined _MSC_VER && BUILDING_LIBRARY
/* When building with MSVC, exporting a symbol means that the object file
contains a "linker directive" of the form /EXPORT:symbol. This can be
inspected through the "objdump -s --section=.drectve FILE" or
"dumpbin /directives FILE" commands.
The symbols from this file should be exported if and only if the object
file gets included in a DLL. Libtool, on Windows platforms, defines
the C macro DLL_EXPORT (together with PIC) when compiling for a shared
library (called DLL under Windows) and does not define it when compiling
an object file meant to be linked statically into some executable. */
# if defined DLL_EXPORT
# define SHLIB_EXPORTED __declspec(dllexport)
# else
# define SHLIB_EXPORTED
# endif
#else
# define DLL_EXPORTED
# define SHLIB_EXPORTED
#endif
#include "gettextP.h"
#include "setlocale-fixes.h"
#include "localename.h"
#if HAVE_CFLOCALECOPYPREFERREDLANGUAGES || HAVE_CFPREFERENCESCOPYAPPVALUE
# if HAVE_CFLOCALECOPYPREFERREDLANGUAGES
@@ -52,8 +70,17 @@
# include <CoreFoundation/CFPropertyList.h>
# include <CoreFoundation/CFArray.h>
# include <CoreFoundation/CFString.h>
extern void gl_locale_name_canonicalize (char *name);
#endif
#if defined _WIN32 && !defined __CYGWIN__
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
/* Get _nl_msg_cat_cntr declaration. */
#include "gettextP.h"
#if (defined __APPLE__ && defined __MACH__) || defined _WIN32 || defined __CYGWIN__
# undef setlocale
@@ -649,6 +676,7 @@ search (const struct table_entry *table, size_t table_size, const char *string,
static char *
setlocale_unixlike (int category, const char *locale)
{
int is_utf8 = (GetACP () == 65001);
char *result;
char llCC_buf[64];
char ll_buf[64];
@@ -659,6 +687,15 @@ setlocale_unixlike (int category, const char *locale)
if (locale != NULL && strcmp (locale, "POSIX") == 0)
locale = "C";
/* The native Windows implementation of setlocale, in the UTF-8 environment,
does not understand the locale names "C.UTF-8" or "C.utf8" or "C.65001",
but it understands "English_United States.65001", which is functionally
equivalent. */
if (locale != NULL
&& ((is_utf8 && strcmp (locale, "C") == 0)
|| strcmp (locale, "C.UTF-8") == 0))
locale = "English_United States.65001";
/* First, try setlocale with the original argument unchanged. */
result = setlocale (category, locale);
if (result != NULL)
@@ -691,7 +728,15 @@ setlocale_unixlike (int category, const char *locale)
*/
if (strcmp (llCC_buf, locale) != 0)
{
result = setlocale (category, llCC_buf);
if (is_utf8)
{
char buf[64+6];
strcpy (buf, llCC_buf);
strcat (buf, ".65001");
result = setlocale (category, buf);
}
else
result = setlocale (category, llCC_buf);
if (result != NULL)
return result;
}
@@ -708,7 +753,15 @@ setlocale_unixlike (int category, const char *locale)
for (i = range.lo; i < range.hi; i++)
{
/* Try the replacement in language_table[i]. */
result = setlocale (category, language_table[i].english);
if (is_utf8)
{
char buf[64+6];
strcpy (buf, language_table[i].english);
strcat (buf, ".65001");
result = setlocale (category, buf);
}
else
result = setlocale (category, language_table[i].english);
if (result != NULL)
return result;
}
@@ -762,13 +815,15 @@ setlocale_unixlike (int category, const char *locale)
size_t part1_len = strlen (part1);
const char *part2 = country_table[j].english;
size_t part2_len = strlen (part2) + 1;
char buf[64+64];
char buf[64+64+6];
if (!(part1_len + 1 + part2_len <= sizeof (buf)))
if (!(part1_len + 1 + part2_len + 6 <= sizeof (buf)))
abort ();
memcpy (buf, part1, part1_len);
buf[part1_len] = '_';
memcpy (buf + part1_len + 1, part2, part2_len);
if (is_utf8)
strcat (buf, ".65001");
/* Try the concatenated replacements. */
result = setlocale (category, buf);
@@ -786,8 +841,16 @@ setlocale_unixlike (int category, const char *locale)
for (i = language_range.lo; i < language_range.hi; i++)
{
/* Try only the language replacement. */
result =
setlocale (category, language_table[i].english);
if (is_utf8)
{
char buf[64+6];
strcpy (buf, language_table[i].english);
strcat (buf, ".65001");
result = setlocale (category, buf);
}
else
result =
setlocale (category, language_table[i].english);
if (result != NULL)
return result;
}
@@ -808,7 +871,7 @@ setlocale_unixlike (int category, const char *locale)
static char *
setlocale_unixlike (int category, const char *locale)
{
char *result = setlocale (category, locale);
char *result = setlocale_fixed (category, locale);
if (result == NULL)
switch (category)
{
@@ -841,22 +904,12 @@ setlocale_unixlike (int category, const char *locale)
# if LC_MESSAGES == 1729
/* The system does not store an LC_MESSAGES locale category. Do it here. */
static char lc_messages_name[64] = "C";
/* Like setlocale, but support also LC_MESSAGES. */
static char *
setlocale_single (int category, const char *locale)
{
if (category == LC_MESSAGES)
{
if (locale != NULL)
{
lc_messages_name[sizeof (lc_messages_name) - 1] = '\0';
strncpy (lc_messages_name, locale, sizeof (lc_messages_name) - 1);
}
return lc_messages_name;
}
return setlocale_messages (locale);
else
return setlocale_unixlike (category, locale);
}
@@ -932,6 +985,7 @@ static char const locales_with_principal_territory[][6 + 1] =
"fy_NL", /* Western Frisian Netherlands */
"ga_IE", /* Irish Ireland */
"gd_GB", /* Scottish Gaelic Britain */
"gl_ES", /* Galician Spain */
"gon_IN", /* Gondi India */
"gsw_CH", /* Swiss German Switzerland */
"gu_IN", /* Gujarati India */
@@ -1050,6 +1104,7 @@ static char const locales_with_principal_territory[][6 + 1] =
"suk_TZ", /* Sukuma Tanzania */
"sus_GN", /* Susu Guinea */
"sv_SE", /* Swedish Sweden */
"ta_IN", /* Tamil India */
"te_IN", /* Telugu India */
"tem_SL", /* Timne Sierra Leone */
"tet_ID", /* Tetum Indonesia */
@@ -1061,7 +1116,7 @@ static char const locales_with_principal_territory[][6 + 1] =
"tl_PH", /* Tagalog Philippines */
"to_TO", /* Tonga Tonga */
"tpi_PG", /* Tok Pisin Papua New Guinea */
"tr_TR", /* Turkish Turkey */
"tr_TR", /* Turkish Türkiye */
"tum_MW", /* Tumbuka Malawi */
"ug_CN", /* Uighur China */
"uk_UA", /* Ukrainian Ukraine */
@@ -1316,7 +1371,7 @@ static char const locales_with_principal_language[][6 + 1] =
"tk_TM", /* Turkmen Turkmenistan */
"ar_TN", /* Arabic Tunisia */
"to_TO", /* Tonga Tonga */
"tr_TR", /* Turkish Turkey */
"tr_TR", /* Turkish Türkiye */
"zh_TW", /* Chinese Taiwan */
"sw_TZ", /* Swahili Tanzania */
"uk_UA", /* Ukrainian Ukraine */
@@ -1386,7 +1441,7 @@ get_main_locale_with_same_territory (const char *locale)
# endif
DLL_EXPORTED
SHLIB_EXPORTED
char *
libintl_setlocale (int category, const char *locale)
{
@@ -1552,7 +1607,7 @@ libintl_setlocale (int category, const char *locale)
For LC_COLLATE, the application should use the locale
properties kCFLocaleCollationIdentifier,
kCFLocaleCollatorIdentifier.
For LC_MONETARY, the applicationshould use the locale
For LC_MONETARY, the application should use the locale
properties kCFLocaleCurrencySymbol,
kCFLocaleCurrencyCode.
But since most applications don't have macOS specific
@@ -1587,7 +1642,7 @@ libintl_setlocale (int category, const char *locale)
/* All steps were successful. */
++_nl_msg_cat_cntr;
free (saved_locale);
return setlocale (LC_ALL, NULL);
goto ret_all;
fail:
if (saved_locale[0] != '\0') /* don't risk an endless recursion */
@@ -1611,55 +1666,165 @@ libintl_setlocale (int category, const char *locale)
}
else
{
# if defined _WIN32 && ! defined __CYGWIN__
if (category == LC_ALL && locale != NULL && strchr (locale, '.') != NULL)
# if LC_MESSAGES == 1729
if (locale != NULL)
{
char *saved_locale;
char truncated_locale[SETLOCALE_NULL_ALL_MAX];
const char *native_locale;
const char *messages_locale;
/* Back up the old locale. */
saved_locale = setlocale (LC_ALL, NULL);
if (saved_locale == NULL)
return NULL;
saved_locale = strdup (saved_locale);
if (saved_locale == NULL)
return NULL;
if (setlocale_unixlike (LC_ALL, locale) == NULL)
if (strncmp (locale, "LC_COLLATE=", 11) == 0)
{
free (saved_locale);
return NULL;
/* The locale argument indicates a mixed locale. It must be of
the form
"LC_COLLATE=...;LC_CTYPE=...;LC_MONETARY=...;LC_NUMERIC=...;LC_TIME=...;LC_MESSAGES=..."
since that is what this function returns (see ret_all below).
Decompose it. */
const char *last_semicolon = strrchr (locale, ';');
if (!(last_semicolon != NULL
&& strncmp (last_semicolon + 1, "LC_MESSAGES=", 12) == 0))
return NULL;
if (category == LC_MESSAGES)
return setlocale_single (category, last_semicolon + 13);
size_t truncated_locale_len = last_semicolon - locale;
if (truncated_locale_len >= sizeof (truncated_locale))
return NULL;
memcpy (truncated_locale, locale, truncated_locale_len);
truncated_locale[truncated_locale_len] = '\0';
native_locale = truncated_locale;
messages_locale = last_semicolon + 13;
}
else
{
native_locale = locale;
messages_locale = locale;
}
/* On native Windows, setlocale(LC_ALL,...) may succeed but set the
LC_CTYPE category to an invalid value ("C") when it does not
support the specified encoding. Report a failure instead. */
if (strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
if (category == LC_ALL)
{
if (saved_locale[0] != '\0') /* don't risk an endless recursion */
setlocale (LC_ALL, saved_locale);
free (saved_locale);
return NULL;
}
/* In the underlying implementation, LC_ALL does not contain
LC_MESSAGES. Therefore we need to handle LC_MESSAGES
separately. */
char *result;
/* It was really successful. */
++_nl_msg_cat_cntr;
free (saved_locale);
return setlocale (LC_ALL, NULL);
# if defined _WIN32 && ! defined __CYGWIN__
if (strchr (native_locale, '.') != NULL)
{
char *saved_locale;
/* Back up the old locale. */
saved_locale = setlocale (LC_ALL, NULL);
if (saved_locale == NULL)
return NULL;
saved_locale = strdup (saved_locale);
if (saved_locale == NULL)
return NULL;
if (setlocale_unixlike (LC_ALL, native_locale) == NULL)
{
free (saved_locale);
return NULL;
}
/* On native Windows, setlocale(LC_ALL,...) may succeed but
set the LC_CTYPE category to an invalid value ("C") when
it does not support the specified encoding. Report a
failure instead. */
if (strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
{
/* Don't risk an endless recursion. */
if (saved_locale[0] != '\0')
setlocale (LC_ALL, saved_locale);
free (saved_locale);
return NULL;
}
/* It was really successful. */
free (saved_locale);
result = setlocale (LC_ALL, NULL);
}
else
# endif
result = setlocale_single (LC_ALL, native_locale);
if (result == NULL)
return NULL;
setlocale_single (LC_MESSAGES, messages_locale);
++_nl_msg_cat_cntr;
goto ret_all;
}
else
{
char *result;
if (category == LC_MESSAGES)
result = setlocale_single (category, messages_locale);
else
result = setlocale_single (category, native_locale);
if (result != NULL)
++_nl_msg_cat_cntr;
return result;
}
}
else
else /* locale == NULL */
{
if (category == LC_ALL)
goto ret_all;
else
return setlocale_single (category, NULL);
}
# else
return setlocale_single (category, locale);
# endif
{
char *result = setlocale_single (category, locale);
if (result != NULL)
++_nl_msg_cat_cntr;
return result;
}
}
ret_all:
/* Return the name of all categories of the current locale. */
# if LC_MESSAGES == 1729 /* native Windows */
/* The locale name for mixed locales looks like this:
"LC_COLLATE=...;LC_CTYPE=...;LC_MONETARY=...;LC_NUMERIC=...;LC_TIME=..."
If necessary, add ";LC_MESSAGES=..." at the end. */
{
char *name1 = setlocale (LC_ALL, NULL);
char *name2 = setlocale_single (LC_MESSAGES, NULL);
if (strcmp (name1, name2) == 0)
/* Not a mixed locale. */
return name1;
else
{
static char resultbuf[SETLOCALE_NULL_ALL_MAX];
/* Prepare the result in a stack-allocated buffer, in order to reduce
race conditions in a multithreaded situation. */
char stackbuf[SETLOCALE_NULL_ALL_MAX];
if (strncmp (name1, "LC_COLLATE=", 11) == 0)
{
if (strlen (name1) + strlen (name2) + 13 >= sizeof (stackbuf))
return NULL;
sprintf (stackbuf, "%s;LC_MESSAGES=%s", name1, name2);
}
else
{
if (5 * strlen (name1) + strlen (name2) + 68 >= sizeof (stackbuf))
return NULL;
sprintf (stackbuf,
"LC_COLLATE=%s;LC_CTYPE=%s;LC_MONETARY=%s;LC_NUMERIC=%s;LC_TIME=%s;LC_MESSAGES=%s",
name1, name1, name1, name1, name1, name2);
}
strcpy (resultbuf, stackbuf);
return resultbuf;
}
}
# elif defined __ANDROID__
return setlocale_fixed_null (LC_ALL);
# else
return setlocale (LC_ALL, NULL);
# endif
}
# if HAVE_NEWLOCALE
DLL_EXPORTED
SHLIB_EXPORTED
locale_t
libintl_newlocale (int category_mask, const char *locale, locale_t base)
{
+1 -1
View File
@@ -1212,7 +1212,7 @@ the previous command.
Once the argument \fIn\fP is computed,
this uses the history expansion facilities to extract the
\fIn\fPth word, as if the
.Q !\fIn\fP
.Q !!:\fIn\fP
history expansion had been specified.
.TP
.B
+1 -1
View File
@@ -1501,7 +1501,7 @@ the previous command.
Once the argument @var{n} is computed,
this uses the history expansion facilities to extract the
@var{n}th word, as if the
@samp{!@var{n}} history expansion had been specified.
@samp{!!:@var{n}} history expansion had been specified.
@item yank-last-arg (M-. or M-_)
Insert last argument to the previous command (the last word of the
+4 -4
View File
@@ -1,11 +1,11 @@
@ignore
Copyright (C) 1988-2025 Free Software Foundation, Inc.
Copyright (C) 1988-2026 Free Software Foundation, Inc.
@end ignore
@set EDITION 8.3
@set VERSION 8.3
@set UPDATED 25 August 2025
@set UPDATED-MONTH August 2025
@set UPDATED 9 July 2026
@set UPDATED-MONTH July 2026
@set LASTCHANGE Mon Aug 25 11:33:46 EDT 2025
@set LASTCHANGE Thu Jul 9 09:20:35 EDT 2026
+23
View File
@@ -478,7 +478,30 @@ here_document_to_fd (WORD_DESC *redirectee, enum r_instruction ri)
}
#endif
#if defined (PIPESIZE_DYNAMIC)
/* If we can't count on the pipe size determined at compile time to be
constant across systems, define PIPESIZE_DYNAMIC in configure.ac.
We set the pipe's write end to be non-blocking, try to write, and
fall back to a temp file on error. */
if (sh_setnodelay (herepipe[1]) < 0)
{
close (herepipe[0]);
close (herepipe[1]);
goto use_tempfile;
}
#endif
r = heredoc_write (herepipe[1], document, document_len);
#if defined (PIPESIZE_DYNAMIC)
if (r == ENOSPC || r == EAGAIN)
{
close (herepipe[0]);
close (herepipe[1]);
goto use_tempfile;
}
#endif
if (document != redirectee->word)
free (document);
close (herepipe[1]);
+16
View File
@@ -211,6 +211,9 @@ static int act_like_sh;
/* Non-zero if we have already expanded and sourced $ENV. */
static int sourced_env;
/* Non-zero if we have already sourced ~/.bash_logout. */
static int sourced_logout;
/* Is this shell running setuid? */
static int running_setuid;
@@ -1250,6 +1253,19 @@ run_startup_files (void)
#endif
}
void
bash_logout (void)
{
/* Run our `~/.bash_logout' file if it exists, and this is a login shell. */
if (login_shell && sourced_logout++ == 0 && subshell_environment == 0 && running_setuid == 0)
{
maybe_execute_file ("~/.bash_logout", 1);
#ifdef SYS_BASH_LOGOUT
maybe_execute_file (SYS_BASH_LOGOUT, 1);
#endif
}
}
#if defined (RESTRICTED_SHELL)
/* Return 1 if the shell should be a restricted one based on NAME or the
value of `restricted'. Don't actually do anything, just return a