documentation updates for history builtin to note it does not truncate the history file; documentation updates for HISTFILESIZE noting that it can work on lines or history entries depending on $HISTTIMEFORMAT; documentation update for history saving behavior at shell exit; history -w and history -a should update the number of history entries in the current session if they are using $HISTFILE; history -r now updates the number of history entries in the current session; improvement to history_truncate_file so it leaves fewer partial history entries when operating on lines

This commit is contained in:
Chet Ramey
2026-08-28 15:35:54 -04:00
parent 71327ab3b5
commit 81ddb6474b
16 changed files with 2086 additions and 1840 deletions
+165 -147
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.4, 20 August 2026).
Bash shell (version 5.4, 27 August 2026).
This is Edition 5.4, last updated 20 August 2026, of The GNU Bash
This is Edition 5.4, last updated 27 August 2026, of The GNU Bash
Reference Manual, for Bash, Version 5.4.
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.4, 20 August 2026). The Bash home page is
Bash shell (version 5.4, 27 August 2026). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.4, last updated 20 August 2026, of The GNU Bash
This is Edition 5.4, last updated 27 August 2026, of The GNU Bash
Reference Manual, for Bash, Version 5.4.
Bash contains features that appear in other popular shells, and some
@@ -5431,7 +5431,7 @@ This builtin allows you to change additional optional shell behavior.
histappend
If set, the history list is appended to the file named by the
value of the HISTFILE variable when the shell exits, rather
than overwriting the file.
than potentially overwriting the file.
histreedit
If set, and Readline is being used, the user is given the
@@ -6162,15 +6162,18 @@ Variables::).
exits.
HISTFILESIZE
The maximum number of lines contained in the history file. When
this variable is assigned a value, the history file is truncated,
if necessary, to contain no more than the number of history entries
that total no more than that number of lines by removing the oldest
entries. If the history list contains multi-line entries, the
history file may contain more lines than this maximum to avoid
leaving partial history entries. The history file is also
truncated to this size after writing it when a shell exits or by
the history builtin. If the value is 0, the history file is
The maximum number of lines or history entries contained in the
history file. When this variable is assigned a value, the history
file is truncated, if necessary, to contain no more than that
number of history entries or lines, depending on the value of
HISTTIMEFORMAT, by removing the oldest entries.
*Note Bash History Facilities::, for a description of how
HISTTIMEFORMAT affects how the value is treated and whether it
refers to lines or history entries.
The history file is also truncated to this size after writing it
when a shell exits. If the value is 0, the history file is
truncated to zero size. Non-numeric values and numeric values less
than zero inhibit truncation. The shell sets the default value to
the value of HISTSIZE after reading any startup files.
@@ -11013,10 +11016,21 @@ the values of the shell variables HISTIGNORE and HISTCONTROL.
reading history entries from the file named by the HISTFILE variable
(default ~/.bash_history). This is referred to as the “history file”.
The history file is truncated, if necessary, to contain no more than the
number of history entries specified by the value of the HISTFILESIZE
variable. If HISTFILESIZE is unset, or set to null, a non-numeric
value, or a numeric value less than zero, the history file is not
truncated.
number of lines or history entries specified by the value of the
HISTFILESIZE variable.
The value of HISTFILESIZE is interpreted as lines or possibly
multi-line history entries depending on whether the HISTTIMEFORMAT
variable has a value, since that controls whether or not timestamps are
written to the history file. If HISTTIMEFORMAT has a value,
HISTFILESIZE is interpreted as a number of history entries, including
timestamps. If it does not, HISTFILESIZE is interpreted as a number
of lines, which may result in incomplete history entries in the history
file, or the history file containing more lines than this maximum to
avoid leaving partial history entries.
If HISTFILESIZE is unset, or set to null, a non-numeric value, or a
numeric value less than zero, the history file is not truncated.
When the history file is read, lines beginning with the history
comment character followed immediately by a digit are interpreted as
@@ -11025,14 +11039,18 @@ optionally displayed depending on the value of the HISTTIMEFORMAT
variable (*note Bash Variables::). When present, history timestamps
delimit history entries, making multi-line entries possible.
When a shell with history enabled exits, Bash copies the last
When a shell with history enabled exits, Bash copies up to the last
$HISTSIZE entries from the history list to the file named by
$HISTFILE. If the histappend shell option is set (*note Bash
Builtins::), Bash appends the entries to the history file, otherwise it
overwrites the history file. If HISTFILE is unset or null, or if the
history file is unwritable, the history is not saved. After saving the
history, Bash truncates the history file to contain no more than
$HISTFILESIZE lines as described above.
Builtins::), or if the number of history entries entered during the
current shell session is less than $HISTSIZE, Bash appends the history
entries entered during the current session to $HISTFILE. If
histappend is not set, and the number of entries from the current
shell session exceeds $HISTSIZE, it overwrites the history file with
the entries from the current session. If HISTFILE is unset or null,
or if the history file is unwritable, the history is not saved. After
saving the history, Bash truncates the history file to contain no more
than $HISTFILESIZE entries as described above.
If the HISTTIMEFORMAT variable is set, the shell writes the
timestamp information associated with each history entry to the history
@@ -13295,51 +13313,51 @@ D.3 Parameter and Variable Index
* HISTCONTROL: Bash Variables. (line 445)
* HISTFILE: Bash Variables. (line 463)
* HISTFILESIZE: Bash Variables. (line 469)
* HISTIGNORE: Bash Variables. (line 483)
* HISTIGNORE: Bash Variables. (line 486)
* history-preserve-point: Readline Init File Syntax.
(line 236)
* history-size: Readline Init File Syntax.
(line 242)
* HISTSIZE: Bash Variables. (line 507)
* HISTTIMEFORMAT: Bash Variables. (line 514)
* HISTSIZE: Bash Variables. (line 510)
* HISTTIMEFORMAT: Bash Variables. (line 517)
* HOME: Bourne Shell Variables.
(line 13)
* horizontal-scroll-mode: Readline Init File Syntax.
(line 252)
* HOSTFILE: Bash Variables. (line 523)
* HOSTNAME: Bash Variables. (line 534)
* HOSTTYPE: Bash Variables. (line 537)
* HOSTFILE: Bash Variables. (line 526)
* HOSTNAME: Bash Variables. (line 537)
* HOSTTYPE: Bash Variables. (line 540)
* IFS: Bourne Shell Variables.
(line 18)
* IGNOREEOF: Bash Variables. (line 540)
* IGNOREEOF: Bash Variables. (line 543)
* input-meta: Readline Init File Syntax.
(line 260)
* INPUTRC: Bash Variables. (line 549)
* INSIDE_EMACS: Bash Variables. (line 553)
* INPUTRC: Bash Variables. (line 552)
* INSIDE_EMACS: Bash Variables. (line 556)
* isearch-terminators: Readline Init File Syntax.
(line 271)
* keymap: Readline Init File Syntax.
(line 278)
* LANG: Creating Internationalized Scripts.
(line 51)
* LANG <1>: Bash Variables. (line 559)
* LC_ALL: Bash Variables. (line 563)
* LC_COLLATE: Bash Variables. (line 567)
* LC_CTYPE: Bash Variables. (line 574)
* LANG <1>: Bash Variables. (line 562)
* LC_ALL: Bash Variables. (line 566)
* LC_COLLATE: Bash Variables. (line 570)
* LC_CTYPE: Bash Variables. (line 577)
* LC_MESSAGES: Creating Internationalized Scripts.
(line 51)
* LC_MESSAGES <1>: Bash Variables. (line 579)
* LC_NUMERIC: Bash Variables. (line 583)
* LC_TIME: Bash Variables. (line 587)
* LINENO: Bash Variables. (line 591)
* LINES: Bash Variables. (line 598)
* MACHTYPE: Bash Variables. (line 604)
* LC_MESSAGES <1>: Bash Variables. (line 582)
* LC_NUMERIC: Bash Variables. (line 586)
* LC_TIME: Bash Variables. (line 590)
* LINENO: Bash Variables. (line 594)
* LINES: Bash Variables. (line 601)
* MACHTYPE: Bash Variables. (line 607)
* MAIL: Bourne Shell Variables.
(line 24)
* MAILCHECK: Bash Variables. (line 608)
* MAILCHECK: Bash Variables. (line 611)
* MAILPATH: Bourne Shell Variables.
(line 29)
* MAPFILE: Bash Variables. (line 616)
* MAPFILE: Bash Variables. (line 619)
* mark-modified-lines: Readline Init File Syntax.
(line 308)
* mark-symlinked-directories: Readline Init File Syntax.
@@ -13350,46 +13368,46 @@ D.3 Parameter and Variable Index
(line 325)
* meta-flag: Readline Init File Syntax.
(line 260)
* OLDPWD: Bash Variables. (line 620)
* OLDPWD: Bash Variables. (line 623)
* OPTARG: Bourne Shell Variables.
(line 36)
* OPTERR: Bash Variables. (line 623)
* OPTERR: Bash Variables. (line 626)
* OPTIND: Bourne Shell Variables.
(line 40)
* OSTYPE: Bash Variables. (line 628)
* OSTYPE: Bash Variables. (line 631)
* output-meta: Readline Init File Syntax.
(line 330)
* page-completions: Readline Init File Syntax.
(line 339)
* PATH: Bourne Shell Variables.
(line 44)
* PIPESTATUS: Bash Variables. (line 631)
* POSIXLY_CORRECT: Bash Variables. (line 641)
* PPID: Bash Variables. (line 651)
* PROMPT_COMMAND: Bash Variables. (line 655)
* PROMPT_DIRTRIM: Bash Variables. (line 661)
* PS0: Bash Variables. (line 667)
* PIPESTATUS: Bash Variables. (line 634)
* POSIXLY_CORRECT: Bash Variables. (line 644)
* PPID: Bash Variables. (line 654)
* PROMPT_COMMAND: Bash Variables. (line 658)
* PROMPT_DIRTRIM: Bash Variables. (line 664)
* PS0: Bash Variables. (line 670)
* PS1: Bourne Shell Variables.
(line 53)
* PS2: Bourne Shell Variables.
(line 58)
* PS3: Bash Variables. (line 672)
* PS4: Bash Variables. (line 677)
* PWD: Bash Variables. (line 685)
* RANDOM: Bash Variables. (line 688)
* READLINE_ARGUMENT: Bash Variables. (line 696)
* READLINE_LINE: Bash Variables. (line 700)
* READLINE_MARK: Bash Variables. (line 704)
* READLINE_POINT: Bash Variables. (line 710)
* REPLY: Bash Variables. (line 714)
* PS3: Bash Variables. (line 675)
* PS4: Bash Variables. (line 680)
* PWD: Bash Variables. (line 688)
* RANDOM: Bash Variables. (line 691)
* READLINE_ARGUMENT: Bash Variables. (line 699)
* READLINE_LINE: Bash Variables. (line 703)
* READLINE_MARK: Bash Variables. (line 707)
* READLINE_POINT: Bash Variables. (line 713)
* REPLY: Bash Variables. (line 717)
* revert-all-at-newline: Readline Init File Syntax.
(line 352)
* search-ignore-case: Readline Init File Syntax.
(line 359)
* SECONDS: Bash Variables. (line 718)
* SHELL: Bash Variables. (line 728)
* SHELLOPTS: Bash Variables. (line 733)
* SHLVL: Bash Variables. (line 743)
* SECONDS: Bash Variables. (line 721)
* SHELL: Bash Variables. (line 731)
* SHELLOPTS: Bash Variables. (line 736)
* SHLVL: Bash Variables. (line 746)
* show-all-if-ambiguous: Readline Init File Syntax.
(line 364)
* show-all-if-unmodified: Readline Init File Syntax.
@@ -13398,15 +13416,15 @@ D.3 Parameter and Variable Index
(line 379)
* skip-completed-text: Readline Init File Syntax.
(line 385)
* SRANDOM: Bash Variables. (line 748)
* SRANDOM: Bash Variables. (line 751)
* TEXTDOMAIN: Creating Internationalized Scripts.
(line 51)
* TEXTDOMAINDIR: Creating Internationalized Scripts.
(line 51)
* TIMEFORMAT: Bash Variables. (line 757)
* TMOUT: Bash Variables. (line 796)
* TMPDIR: Bash Variables. (line 808)
* UID: Bash Variables. (line 812)
* TIMEFORMAT: Bash Variables. (line 760)
* TMOUT: Bash Variables. (line 799)
* TMPDIR: Bash Variables. (line 811)
* UID: Bash Variables. (line 815)
* vi-cmd-mode-string: Readline Init File Syntax.
(line 398)
* vi-ins-mode-string: Readline Init File Syntax.
@@ -13863,81 +13881,81 @@ Node: Bash Builtins182515
Node: Modifying Shell Behavior220253
Node: The Set Builtin220598
Node: The Shopt Builtin232727
Node: Special Builtins250266
Node: Shell Variables251258
Node: Bourne Shell Variables251695
Node: Bash Variables254206
Node: Bash Features293493
Node: Invoking Bash294510
Node: Bash Startup Files301743
Node: Interactive Shells307106
Node: What is an Interactive Shell?307517
Node: Is this Shell Interactive?308182
Node: Interactive Shell Behavior309009
Node: Bash Conditional Expressions312773
Node: Shell Arithmetic318193
Node: Aliases321523
Node: Arrays324660
Node: The Directory Stack332766
Node: Directory Stack Builtins333566
Node: Controlling the Prompt338014
Node: The Restricted Shell341136
Node: Bash POSIX Mode344232
Node: Shell Compatibility Mode364194
Node: Job Control373204
Node: Job Control Basics373664
Node: Job Control Builtins380035
Node: Job Control Variables386826
Node: Command Line Editing388060
Node: Introduction and Notation389766
Node: Readline Interaction392121
Node: Readline Bare Essentials393312
Node: Readline Movement Commands395123
Node: Readline Killing Commands396122
Node: Readline Arguments398148
Node: Searching399241
Node: Readline Init File401487
Node: Readline Init File Syntax402793
Node: Conditional Init Constructs429747
Node: Sample Init File434135
Node: Bindable Readline Commands437258
Node: Commands For Moving438799
Node: Commands For History441266
Node: Commands For Text447426
Node: Commands For Killing451554
Node: Numeric Arguments454345
Node: Commands For Completion455500
Node: Keyboard Macros461199
Node: Miscellaneous Commands461903
Node: Readline vi Mode469449
Node: Programmable Completion470429
Node: Programmable Completion Builtins480168
Node: A Programmable Completion Example491908
Node: Using History Interactively497256
Node: Bash History Facilities497940
Node: Bash History Builtins501678
Node: History Interaction509276
Node: Event Designators514229
Node: Word Designators515810
Node: Modifiers518205
Node: Installing Bash520145
Node: Basic Installation521264
Node: Compilers and Options525143
Node: Compiling For Multiple Architectures525896
Node: Installation Names527652
Node: Specifying the System Type529889
Node: Sharing Defaults530638
Node: Operation Controls531355
Node: Optional Features532377
Node: Reporting Bugs545103
Node: Major Differences From The Bourne Shell546463
Node: GNU Free Documentation License567893
Node: Indexes593073
Node: Builtin Index593527
Node: Reserved Word Index600628
Node: Variable Index603076
Node: Function Index620492
Node: Concept Index634920
Node: Special Builtins250278
Node: Shell Variables251270
Node: Bourne Shell Variables251707
Node: Bash Variables254218
Node: Bash Features293525
Node: Invoking Bash294542
Node: Bash Startup Files301775
Node: Interactive Shells307138
Node: What is an Interactive Shell?307549
Node: Is this Shell Interactive?308214
Node: Interactive Shell Behavior309041
Node: Bash Conditional Expressions312805
Node: Shell Arithmetic318225
Node: Aliases321555
Node: Arrays324692
Node: The Directory Stack332798
Node: Directory Stack Builtins333598
Node: Controlling the Prompt338046
Node: The Restricted Shell341168
Node: Bash POSIX Mode344264
Node: Shell Compatibility Mode364226
Node: Job Control373236
Node: Job Control Basics373696
Node: Job Control Builtins380067
Node: Job Control Variables386858
Node: Command Line Editing388092
Node: Introduction and Notation389798
Node: Readline Interaction392153
Node: Readline Bare Essentials393344
Node: Readline Movement Commands395155
Node: Readline Killing Commands396154
Node: Readline Arguments398180
Node: Searching399273
Node: Readline Init File401519
Node: Readline Init File Syntax402825
Node: Conditional Init Constructs429779
Node: Sample Init File434167
Node: Bindable Readline Commands437290
Node: Commands For Moving438831
Node: Commands For History441298
Node: Commands For Text447458
Node: Commands For Killing451586
Node: Numeric Arguments454377
Node: Commands For Completion455532
Node: Keyboard Macros461231
Node: Miscellaneous Commands461935
Node: Readline vi Mode469481
Node: Programmable Completion470461
Node: Programmable Completion Builtins480200
Node: A Programmable Completion Example491940
Node: Using History Interactively497288
Node: Bash History Facilities497972
Node: Bash History Builtins502641
Node: History Interaction510239
Node: Event Designators515192
Node: Word Designators516773
Node: Modifiers519168
Node: Installing Bash521108
Node: Basic Installation522227
Node: Compilers and Options526106
Node: Compiling For Multiple Architectures526859
Node: Installation Names528615
Node: Specifying the System Type530852
Node: Sharing Defaults531601
Node: Operation Controls532318
Node: Optional Features533340
Node: Reporting Bugs546066
Node: Major Differences From The Bourne Shell547426
Node: GNU Free Documentation License568856
Node: Indexes594036
Node: Builtin Index594490
Node: Reserved Word Index601591
Node: Variable Index604039
Node: Function Index621455
Node: Concept Index635883

End Tag Table