history builtin has a -H option to display history entries as they would be written to the history file; history builtin now takes a START-END range specifier for listing; fix stray semicolon when printing shell functions containing a case command; changes to stdin redirection detection in preparation for POSIX interp 1913

This commit is contained in:
Chet Ramey
2026-01-05 11:57:18 -05:00
parent 4b27601dfd
commit a43e08df2d
27 changed files with 1506 additions and 1062 deletions
+37 -24
View File
@@ -5841,8 +5841,8 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS
ing is complete, ffcc reads the file containing the edited com-
mands and echoes and executes them. The --DD option, if supplied,
causes ffcc to remove the selected commands from the history list
before executing the file of edited commands. --DD is only active
when ffcc is invoked in this way.
before executing the file of edited commands. --DD is only effec-
tive when ffcc is invoked in this way.
In the second form, ffcc re-executes _c_o_m_m_a_n_d after replacing each
instance of _p_a_t with _r_e_p. _C_o_m_m_a_n_d is interpreted the same as
@@ -5973,21 +5973,36 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS
The return status is 0 unless no command matches _p_a_t_t_e_r_n.
hhiissttoorryy [[_n]]
hhiissttoorryy [[--HH]] [[_r_a_n_g_e]]
hhiissttoorryy --cc
hhiissttoorryy --dd _o_f_f_s_e_t
hhiissttoorryy --dd _s_t_a_r_t-_e_n_d
hhiissttoorryy --dd _r_a_n_g_e
hhiissttoorryy --aannrrww [_f_i_l_e_n_a_m_e]
hhiissttoorryy --pp _a_r_g [_a_r_g ...]
hhiissttoorryy --ss _a_r_g [_a_r_g ...]
With no options, display the command history list with numbers.
Entries prefixed with a ** have been modified. An argument of _n
lists only the last _n entries. If the shell variable HHIISSTTTTIIMMEE--
FFOORRMMAATT is set and not null, it is used as a format string for
_s_t_r_f_t_i_m_e(3) to display the time stamp associated with each dis-
played history entry. If hhiissttoorryy uses HHIISSTTTTIIMMEEFFOORRMMAATT, it does
not print an intervening space between the formatted time stamp
and the history entry.
With no options, or with the --HH option, display the portion of
the command history list specified by _r_a_n_g_e, as described below.
If _r_a_n_g_e is not specified, display the entire history list.
Without --HH, display the list with command numbers, prefixing en-
tries that have been modified with a "*".
A _r_a_n_g_e argument is specified in the form of a number _o_f_f_s_e_t or
a range _s_t_a_r_t-_e_n_d. If _o_f_f_s_e_t is supplied, it references the
history entry at position _o_f_f_s_e_t in the history list; when list-
ing this displays the last _o_f_f_s_e_t entries. A negative _o_f_f_s_e_t
counts back from the end of the history list, relative to one
greater than the last history position. When listing, negative
and positive _o_f_f_s_e_t_s have identical results. _s_t_a_r_t and _e_n_d, if
supplied, reference the portion of the history list beginning at
position _s_t_a_r_t through position _e_n_d. If _s_t_a_r_t or _e_n_d are nega-
tive, they count back from the end of the history list. When
listing, if _s_t_a_r_t is greater than _e_n_d, the history entries are
displayed in reverse order from _e_n_d to _s_t_a_r_t.
If the shell variable HHIISSTTTTIIMMEEFFOORRMMAATT is set and not null, it is
used as a format string for _s_t_r_f_t_i_m_e(3) to display the time
stamp associated with each displayed history entry. If hhiissttoorryy
uses HHIISSTTTTIIMMEEFFOORRMMAATT, it does not print an intervening space be-
tween the formatted time stamp and the history entry.
If _f_i_l_e_n_a_m_e is supplied, hhiissttoorryy uses it as the name of the his-
tory file; if not, it uses the value of HHIISSTTFFIILLEE. If _f_i_l_e_n_a_m_e
@@ -5998,16 +6013,14 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS
--cc Clear the history list by deleting all the entries. This
can be used with the other options to replace the history
list.
--dd _o_f_f_s_e_t
Delete the history entry at position _o_f_f_s_e_t. If _o_f_f_s_e_t
is negative, it is interpreted as relative to one greater
than the last history position, so negative indices count
back from the end of the history, and an index of -1
refers to the current hhiissttoorryy --dd command.
--dd _s_t_a_r_t-_e_n_d
Delete the range of history entries between positions
_s_t_a_r_t and _e_n_d, inclusive. Positive and negative values
for _s_t_a_r_t and _e_n_d are interpreted as described above.
--dd _r_a_n_g_e
Delete the history entries specified by _r_a_n_g_e, as de-
scribed above. An index of -1 refers to the current hhiiss--
ttoorryy --dd command.
--HH Display the selected history entries in the format that
would be written to the history file, including any time
stamp information as described below, without prefixing
the entry with any line number or "*".
--aa Append the "new" history lines to the history file.
These are history lines entered since the beginning of
the current bbaasshh session, but not already appended to the
@@ -7577,4 +7590,4 @@ BBUUGGSS
Array variables may not (yet) be exported.
GNU Bash 5.3 2025 December 18 _B_A_S_H(1)
GNU Bash 5.3 2025 December 26 _B_A_S_H(1)