From: Chet Ramey
Date: Mon, 5 Jan 2026 16:57:18 +0000 (-0500)
Subject: history builtin has a -H option to display history entries as they would be written...
X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=a43e08df2deefa6b63dce66d57adad2c9a704eb7;p=thirdparty%2Fbash.git
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
---
diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog
index 15553f70..9ec9fe60 100644
--- a/CWRU/CWRU.chlog
+++ b/CWRU/CWRU.chlog
@@ -12447,3 +12447,38 @@ builtins/evalstring.c
execute_cmd.c
- execute_command_internal: set currently_executing_command to NULL
in places where we return from this function
+
+ 12/26
+ -----
+builtins/history.def
+ - -H: new option, means to display history entries as they would be
+ written to the history file, with timestamp information and without
+ line numbers or `*'
+ - listing now takes a START-END range argument, so you can list a
+ subset of the history list from START to END, with the format
+ subject to the -H option. If START > END, list in reverse order.
+ This moves history and fc functionality closer to convergence
+ - parse_range: new function, encapsulates parsing START-END history
+ range specifiction; used by deletion and listing
+
+doc/bash.1,doc/bashref.texi
+ - history: update with a description of ranges, add description of -H;
+ listing and deletion now reference range description
+
+ 12/30
+ -----
+print_cmd.c
+ - print_case_clauses: reset was_heredoc to 0 after printing each case
+ clause, since any here-document must have been associated with the
+ command list following the pattern list and `)'
+ Report from "Stan Marsh" back in May, 2025
+
+ 12/31
+ -----
+doc/Makefile.in
+ - dvi: remove from default targets as per latest GNU coding standards
+
+redir.c
+ - stdin_redirection: now take the entire REDIRECT * as its argument,
+ so we can do additional posix-mandated checking on redirections
+ like 0<&0, to satisfy interp 1913
diff --git a/MANIFEST b/MANIFEST
index 3bf2fa24..f2cacc8b 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -697,7 +697,6 @@ doc/article.ps f
doc/rose94.ps f
#doc/bash.ps f
#doc/bashref.ps f
-doc/bashref.dvi f
doc/bash.0 f
doc/bashbug.0 f
doc/builtins.0 f
@@ -1301,6 +1300,7 @@ tests/history7.sub f
tests/history8.sub f
tests/history9.sub f
tests/history10.sub f
+tests/history11.sub f
tests/ifs.tests f
tests/ifs.right f
tests/ifs1.sub f
diff --git a/builtins/history.def b/builtins/history.def
index 4c36416c..478ae818 100644
--- a/builtins/history.def
+++ b/builtins/history.def
@@ -23,18 +23,32 @@ $PRODUCES history.c
$BUILTIN history
$FUNCTION history_builtin
$DEPENDS_ON HISTORY
-$SHORT_DOC history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
+$SHORT_DOC history [-c] [-H] [-d range] [range] or history -anrw [filename] or history -ps arg [arg...]
Display or manipulate the history list.
-Display the history list with line numbers, prefixing each modified
-entry with a `*'. An argument of N lists only the last N entries.
+Without options, or if -H is supplied, display the portion of the
+history list specified by RANGE, as described below. If -H is not
+supplied, the list displays line numbers, prefixing each modified
+entry with a `*'.
+
+When listing or deleting history entries, RANGE is an argument of
+the form of a number OFFSET or a range START-END. If OFFSET is supplied,
+it references the history entry at position OFFSET; when listing, this
+displays the last OFFSET entries. A negative OFFSET is interpreted
+relative to one greater than the last history position, so negative
+OFFSETs count back from the end of the history list. START and END, if
+supplied, reference the portion of the history list beginning at position
+START through position END. Negative START and END count back from the
+end of the history list. When listing, if START is greater than END,
+the history entries are displayed in reverse order from START to END.
Options:
-c clear the history list by deleting all of the entries
- -d offset delete the history entry at position OFFSET. Negative
- offsets count back from the end of the history list
- -d start-end delete the history entries beginning at position START
- through position END.
+ -d range delete the history entries specified by RANGE. RANGE is
+ described above.
+ -H display the selected history entries in the format that would
+ be written to the history file, including any timestamp,
+ without prefixing any line number or `*'.
-a append history lines from this session to the history file
-n read all history lines not already read from the history file
@@ -93,7 +107,8 @@ extern int errno;
#endif
static char *histtime (HIST_ENTRY *, const char *);
-static int display_history (WORD_LIST *);
+static int parse_range (char *, char *, int *, int *);
+static int display_history (WORD_LIST *, int);
static void push_history (WORD_LIST *);
static int expand_and_print_history (WORD_LIST *);
@@ -105,6 +120,7 @@ static int expand_and_print_history (WORD_LIST *);
#define PFLAG 0x20
#define CFLAG 0x40
#define DFLAG 0x80
+#define HFLAG 0x100
#ifndef TIMELEN_MAX
# define TIMELEN_MAX 128
@@ -119,7 +135,7 @@ history_builtin (WORD_LIST *list)
flags = 0;
reset_internal_getopt ();
- while ((opt = internal_getopt (list, "acd:npsrw")) != -1)
+ while ((opt = internal_getopt (list, "acd:npsrwH")) != -1)
{
switch (opt)
{
@@ -150,6 +166,9 @@ history_builtin (WORD_LIST *list)
flags |= PFLAG;
#endif
break;
+ case 'H':
+ flags |= HFLAG;
+ break;
CASE_HELPOPT;
default:
builtin_usage ();
@@ -189,37 +208,11 @@ history_builtin (WORD_LIST *list)
#endif
else if ((flags & DFLAG) && (range = strchr ((delete_arg[0] == '-') ? delete_arg + 1 : delete_arg, '-')))
{
- intmax_t delete_start, delete_end;
- *range++ = '\0';
- if (valid_number (delete_arg, &delete_start) == 0 || valid_number (range, &delete_end) == 0)
- {
- range[-1] = '-';
- sh_erange (delete_arg, _("history position"));
- return (EXECUTION_FAILURE);
- }
- if (delete_arg[0] == '-' && delete_start < 0)
- /* the_history[history_length] == 0x0, so this is correct */
- delete_start += history_length;
- /* numbers as displayed by display_history are offset by history_base */
- else if (delete_start > 0)
- delete_start -= history_base;
-
- if (delete_start < 0 || delete_start >= history_length)
- {
- sh_erange (delete_arg, _("history position"));
- return (EXECUTION_FAILURE);
- }
+ int delete_start, delete_end;
- if (range[0] == '-' && delete_end < 0)
- delete_end += history_length;
- else if (delete_end > 0)
- delete_end -= history_base;
+ if (parse_range (delete_arg, range, &delete_start, &delete_end) != 0)
+ return (EXECUTION_FAILURE);
- if (delete_end < 0 || delete_end >= history_length)
- {
- sh_erange (range, _("history position"));
- return (EXECUTION_FAILURE);
- }
/* XXX - print error if end < start? */
result = bash_delete_history_range (delete_start, delete_end);
if (where_history () > history_length)
@@ -266,7 +259,7 @@ history_builtin (WORD_LIST *list)
}
else if ((flags & (AFLAG|RFLAG|NFLAG|WFLAG|CFLAG)) == 0)
{
- result = display_history (list);
+ result = display_history (list, flags);
return (sh_chkwrite (result));
}
@@ -366,49 +359,123 @@ histtime (HIST_ENTRY *hlist, const char *histtimefmt)
return timestr;
}
+/* Parse a range START-END into two offsets into the history list (offset by
+ history_base), return in *STARTP and *ENDP. Return 0 on success, non-zero
+ on failure. Negative START and END are offsets from history_length. */
static int
-display_history (WORD_LIST *list)
+parse_range (char *arg, char *range, int *startp, int *endp)
{
- register int i;
+ intmax_t ls, le;
+
+ *range++ = '\0';
+ if (valid_number (arg, &ls) == 0 || valid_number (range, &le) == 0)
+ {
+ range[-1] = '-'; /* must point into ARG */
+ sh_erange (arg, _("history position"));
+ return (EXECUTION_FAILURE);
+ }
+ if (arg[0] == '-' && ls < 0)
+ ls += history_length;
+ else if (ls > 0)
+ ls -= history_base;
+ if (ls < 0 || ls >= history_length)
+ {
+ sh_erange (arg, _("history position"));
+ range[-1] = '-'; /* must point into ARG */
+ return (EXECUTION_FAILURE);
+ }
+ if (range[0] == '-' && le < 0)
+ le += history_length;
+ else if (le > 0)
+ le -= history_base;
+ if (le < 0 || le >= history_length)
+ {
+ sh_erange (range, _("history position"));
+ range[-1] = '-'; /* must point into ARG */
+ return (EXECUTION_FAILURE);
+ }
+
+ range[-1] = '-';
+ *startp = ls;
+ *endp = le;
+
+ return EXECUTION_SUCCESS;
+}
+
+static int
+display_history (WORD_LIST *list, int flags)
+{
+ int i, start, end, reverse;
intmax_t limit;
HIST_ENTRY **hlist;
- char *histtimefmt, *timestr;
+ char *histtimefmt, *timestr, *range, *list_arg;
- if (list)
+ reverse = 0;
+ if (list && list->word)
{
- if (get_numeric_arg (list, 0, &limit) == 0)
- return (EX_USAGE);
+ list_arg = list->word->word;
+ range = strchr ((list_arg[0] == '-') ? list_arg + 1 : list_arg, '-');
+ if (range)
+ {
+ if (parse_range (list_arg, range, &start, &end) != 0)
+ return (EXECUTION_FAILURE);
+ if (end < start) /* end < start means to print in reverse order */
+ {
+ int t;
+ t = end;
+ end = start;
+ start = t;
+ reverse = 1;
+ }
+ }
+ else
+ {
+ if (get_numeric_arg (list, 0, &limit) == 0)
+ return (EX_USAGE);
+ if (limit < 0)
+ limit = -limit;
- if (limit < 0)
- limit = -limit;
+ start = (0 <= limit && limit < history_length) ? history_length - limit : 0;
+ end = history_length - 1;
+ }
}
else
- limit = -1;
+ {
+ start = 0;
+ end = history_length - 1;
+ }
hlist = history_list ();
+ if (hlist == 0)
+ return (EXECUTION_SUCCESS);
+
+ histtimefmt = get_string_value ("HISTTIMEFORMAT");
- if (hlist)
+ for (i = reverse ? end : start; reverse ? i >= start : i <= end; reverse ? i-- : i++)
{
- for (i = 0; hlist[i]; i++)
- ;
+ QUIT;
- if (0 <= limit && limit < i)
- i -= limit;
+ if (flags & HFLAG)
+ {
+ if (history_write_timestamps && hlist[i]->timestamp && hlist[i]->timestamp[0])
+ printf ("%s\n", hlist[i]->timestamp);
+ if (printf ("%s\n", histline (i)) < 0)
+ {
+ sh_wrerror ();
+ break;
+ }
+ }
else
- i = 0;
-
- histtimefmt = get_string_value ("HISTTIMEFORMAT");
-
- while (hlist[i])
{
- QUIT;
-
timestr = (histtimefmt && *histtimefmt) ? histtime (hlist[i], histtimefmt) : (char *)NULL;
- printf ("%5d%c %s%s\n", i + history_base,
- histdata(i) ? '*' : ' ',
- ((timestr && *timestr) ? timestr : ""),
- histline(i));
- i++;
+ if (printf ("%5d%c %s%s\n", i + history_base,
+ histdata (i) ? '*' : ' ',
+ ((timestr && *timestr) ? timestr : ""),
+ histline (i)) < 0)
+ {
+ sh_wrerror ();
+ break;
+ }
}
}
diff --git a/doc/Makefile.in b/doc/Makefile.in
index e0e2a15b..1bb1483c 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -154,8 +154,9 @@ BASHREF_FILES = $(srcdir)/bashref.texi $(srcdir)/fdl.texi $(srcdir)/version.texi
# $(RM) $@
# -${TEXI2PDF} $<
-all: info dvi text html pdf # $(MAN2HTML)
-nodvi: ps info text html
+all: info text html pdf # $(MAN2HTML)
+withdvi: pdf info text html dvi
+
everything: all ps
CREATED_PS = bash.ps bashref.ps
diff --git a/doc/bash.0 b/doc/bash.0
index 259d5bd2..f858b6b5 100644
--- a/doc/bash.0
+++ b/doc/bash.0
@@ -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)
diff --git a/doc/bash.1 b/doc/bash.1
index 145717cc..c605d04c 100644
--- a/doc/bash.1
+++ b/doc/bash.1
@@ -5,7 +5,7 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
-.\" Last Change: Thu Dec 18 17:18:21 EST 2025
+.\" Last Change: Fri Dec 26 18:21:22 EST 2025
.\"
.\" 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 "2025 December 18" "GNU Bash 5.3"
+.TH BASH 1 "2025 December 26" "GNU Bash 5.3"
.\"
.ie \n(.g \{\
.ds ' \(aq
@@ -10413,7 +10413,7 @@ option, if supplied,
causes \fBfc\fP to remove the selected commands from the history
list before executing the file of edited commands.
.B \-D
-is only active when \fBfc\fP is invoked in this way.
+is only effective when \fBfc\fP is invoked in this way.
.IP
In the second form, \fBfc\fP re-executes \fIcommand\fP
after replacing each instance of \fIpat\fP with \fIrep\fP.
@@ -10660,14 +10660,12 @@ prints the descriptions of all matching help topics.
The return status is 0 unless no command matches
.IR pattern .
.TP
-\fBhistory [\fIn\fP]
+\fBhistory [\fB\-H\fP] [\fIrange\fP]
.PD 0
.TP
\fBhistory\fP \fB\-c\fP
.TP
-\fBhistory \-d\fP \fIoffset\fP
-.TP
-\fBhistory \-d\fP \fIstart\fP-\fIend\fP
+\fBhistory \-d\fP \fIrange\fP
.TP
\fBhistory\fP \fB\-anrw\fP [\fIfilename\fP]
.TP
@@ -10675,15 +10673,33 @@ The return status is 0 unless no command matches
.TP
\fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg\fP .\|.\|.]
.PD
-With no options, display the command history list with numbers.
-Entries prefixed with a
-.B *
-have been modified.
-An argument of
-.I n
-lists only the last
-.I n
-entries.
+With no options,
+or with the \fB\-H\fP option,
+display the portion of the command history list
+specified by \fIrange\fP, as described below.
+If \fIrange\fP is not specified, display the entire history list.
+Without \fB\-H\fP, display the list with command numbers, prefixing
+entries that have been modified with a
+.Q "*" .
+.IP
+A
+.I range
+argument is specified in the form of a number \fIoffset\fP or
+a range \fIstart\fP\-\fIend\fP.
+If \fIoffset\fP is supplied, it references the history entry at
+position \fIoffset\fP in the history list;
+when listing this displays the last \fIoffset\fP entries.
+A negative \fIoffset\fP counts back from the end of the history list,
+relative to one greater than the last history position.
+When listing, negative and positive \fIoffsets\fP have identical results.
+\fIstart\fP and \fIend\fP, if supplied, reference the portion of
+the history list beginning at position \fIstart\fP through position
+\fIend\fP.
+If \fIstart\fP or \fIend\fP are negative, they count back from the
+end of the history list.
+When listing, if \fIstart\fP is greater than \fIend\fP, the history
+entries are displayed in reverse order from \fIend\fP to \fIstart\fP.
+.IP
If the shell variable
.SM
.B HISTTIMEFORMAT
@@ -10717,18 +10733,16 @@ Options, if supplied, have the following meanings:
Clear the history list by deleting all the entries.
This can be used with the other options to replace the history list.
.TP
-\fB\-d\fP \fIoffset\fP
-Delete the history entry at position \fIoffset\fP.
-If \fIoffset\fP 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
-\fBhistory \-d\fP command.
-.TP
-\fB\-d\fP \fIstart\fP\-\fIend\fP
-Delete the range of history entries between positions \fIstart\fP and
-\fIend\fP, inclusive.
-Positive and negative values for \fIstart\fP and \fIend\fP
-are interpreted as described above.
+\fB\-d\fP \fIrange\fP
+Delete the history entries specified by \fIrange\fP, as described above.
+An index of \-1 refers to the current \fBhistory \-d\fP command.
+.TP
+\fB\-H\fP
+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
+.Q "*" .
.TP
.B \-a
Append the
diff --git a/doc/bash.html b/doc/bash.html
index 14e4e194..2f8fc02a 100644
--- a/doc/bash.html
+++ b/doc/bash.html
@@ -1,5 +1,5 @@
-
+
@@ -12232,8 +12232,8 @@ with a name that is not a function.
fc [−e
-ename] [−lnr] [first]
-[last]
+ename] [−D] [−lnr]
+[first] [last]
fc −s [pat=rep] [cmd]
The first form selects a range
@@ -12271,7 +12271,11 @@ variable, and the value of EDITOR if
FCEDIT is not set. If neither variable
is set, fc uses vi. When editing is complete,
fc reads the file containing the edited commands and
-echoes and executes them.
+echoes and executes them. The −D option, if
+supplied, causes fc to remove the selected commands
+from the history list before executing the file of edited
+commands. −D is only effective when fc
+is invoked in this way.
In the second
form, fc re-executes command after replacing
@@ -12486,23 +12490,44 @@ prints the descriptions of all matching help topics.
The return
status is 0 unless no command matches pattern.
-history [n]
-
+
history [−H]
+[range]
history −c
-history −d offset
-history −d start-end
+history −d range
history −anrw [filename]
history −p arg [arg ...]
history −s arg [arg ...]
-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
-HISTTIMEFORMAT is set and not null, it
-is used as a format string for strftime(3) to display
-the time stamp associated with each displayed history entry.
-If history uses
+
With no options, or with the
+−H option, display the portion of the command
+history list specified by range, as described below.
+If range is not specified, display the entire history
+list. Without −H, display the list with command
+numbers, prefixing entries that have been modified with a
+“*”.
+
+A range
+argument is specified in the form of a number offset
+or a range start−end. If offset
+is supplied, it references the history entry at position
+offset in the history list; when listing this
+displays the last offset entries. A negative
+offset counts back from the end of the history list,
+relative to one greater than the last history position. When
+listing, negative and positive offsets have identical
+results. start and end, if supplied, reference
+the portion of the history list beginning at position
+start through position end. If start or
+end are negative, they count back from the end of the
+history list. When listing, if start is greater than
+end, the history entries are displayed in reverse
+order from end to start.
+
+If the shell
+variable HISTTIMEFORMAT is set and not
+null, it is used as a format string for strftime(3)
+to display the time stamp associated with each displayed
+history entry. If history uses
HISTTIMEFORMAT, it does
not print an intervening space between the formatted time
stamp and the history entry.
@@ -12537,22 +12562,12 @@ list.
−d
-offset
-
-Delete the history entry at
-position offset. If offset 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
-history −d command.
-
-−d
-start−end
+range
-Delete the range of history
-entries between positions start and end,
-inclusive. Positive and negative values for start and
-end are interpreted as described above.
+Delete the history entries
+specified by range, as described above. An index of
+−1 refers to the current history −d
+command.
@@ -12561,6 +12576,20 @@ inclusive. Positive and negative values for start and
|
+ −H |
+ |
+
+
+
+ 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 “*”. |
+
+ |
+
+
+
−a |
|
diff --git a/doc/bash.info b/doc/bash.info
index b7665149..5ae297f2 100644
--- a/doc/bash.info
+++ b/doc/bash.info
@@ -1,9 +1,9 @@
This is bash.info, produced by makeinfo version 7.2 from bashref.texi.
This text is a brief description of the features that are present in the
-Bash shell (version 5.3, 18 December 2025).
+Bash shell (version 5.3, 26 December 2025).
- This is Edition 5.3, last updated 18 December 2025, of âThe GNU Bash
+ This is Edition 5.3, last updated 26 December 2025, of âThe GNU Bash
Reference Manualâ, for âBashâ, Version 5.3.
Copyright © 1988-2025 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 December 2025). The Bash home page is
+Bash shell (version 5.3, 26 December 2025). The Bash home page is
.
- This is Edition 5.3, last updated 18 December 2025, of âThe GNU Bash
+ This is Edition 5.3, last updated 26 December 2025, of âThe GNU Bash
Reference Manualâ, for âBashâ, Version 5.3.
Bash contains features that appear in other popular shells, and some
@@ -10993,7 +10993,7 @@ history file.
âfcâ reads the file of edited commands and echoes and executes
them. The â-Dâ option, if supplied, causes âfcâ to remove the
selected commands from the history list before executing the file
- of edited commands. â-Dâ is only active when âfcâ is invoked in
+ of edited commands. â-Dâ is only effective when âfcâ is invoked in
this way. It could be used if you make a typo in a command and
want to fix it using an editor while removing the erroneous command
from the history to avoid clutter.
@@ -11016,21 +11016,36 @@ history file.
history entry, in which case âfcâ returns a non-zero status.
âhistoryâ
- history [N]
+ history [-H] [RANGE]
history -c
- history -d OFFSET
- history -d START-END
+ history -d RANGE
history [-anrw] [FILENAME]
- history -ps ARG
-
- With no options, display the 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 âHISTTIMEFORMATâ is
- set and not null, it is used as a format string for âstrftimeâ(3)
- to display the time stamp associated with each displayed history
- entry. If âhistoryâ uses âHISTTIMEFORMATâ, it does not print an
- intervening space between the formatted time stamp and the history
- entry.
+ history -ps ARG [ARG...]
+
+ With no options, or with the â-Hâ option, display the portion of
+ the command history list specified by RANGE, as described below.
+ If RANGE is not specified, display the entire history list.
+ Without â-Hâ, display the list with command numbers, prefixing
+ entries that have been modified with a â*â.
+
+ A RANGE argument is specified in the form of a number OFFSET or a
+ range START-END. If OFFSET is supplied, it references the history
+ entry at position OFFSET in the history list; when listing this
+ displays the last OFFSET entries. A negative OFFSET counts back
+ from the end of the history list, relative to one greater than the
+ last history position. When listing, negative and positive OFFSETs
+ have identical results. START and END, if supplied, reference the
+ portion of the history list beginning at position START through
+ position END. If START or END are negative, they count back from
+ the end of the history list. When listing, if START is greater
+ than END, the history entries are displayed in reverse order from
+ END to START.
+
+ If the shell variable âHISTTIMEFORMATâ is set and not null, it is
+ used as a format string for âstrftimeâ(3) to display the time stamp
+ associated with each displayed history entry. If âhistoryâ uses
+ âHISTTIMEFORMATâ, it does not print an intervening space between
+ the formatted time stamp and the history entry.
Options, if supplied, have the following meanings:
@@ -11038,19 +11053,16 @@ history file.
Clear the history list. This may be combined with the other
options to replace the history list.
- â-d OFFSETâ
- Delete the history entry at position OFFSET. If OFFSET is
- positive, it should be specified as it appears when the
- history is displayed. If OFFSET 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 âhistory
- -dâ command.
+ â-d RANGEâ
+ Delete the history entries specified by RANGE, as described
+ above. An offset of â-1â refers to the current âhistory -dâ
+ command.
- â-d START-ENDâ
- Delete the range of history entries between positions START
- and END, inclusive. Positive and negative values for START
- and END are interpreted as described above.
+ â-Hâ
+ 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 â*â.
â-aâ
Append the "new" history lines to the history file. These are
@@ -13791,28 +13803,28 @@ Node: A Programmable Completion Example485732
Node: Using History Interactively491077
Node: Bash History Facilities491758
Node: Bash History Builtins495493
-Node: History Interaction502365
-Node: Event Designators507315
-Node: Word Designators508893
-Node: Modifiers511285
-Node: Installing Bash513222
-Node: Basic Installation514338
-Node: Compilers and Options518214
-Node: Compiling For Multiple Architectures518964
-Node: Installation Names520717
-Node: Specifying the System Type522951
-Node: Sharing Defaults523697
-Node: Operation Controls524411
-Node: Optional Features525430
-Node: Reporting Bugs538153
-Node: Major Differences From The Bourne Shell539510
-Node: GNU Free Documentation License560937
-Node: Indexes586114
-Node: Builtin Index586565
-Node: Reserved Word Index593663
-Node: Variable Index596108
-Node: Function Index613521
-Node: Concept Index627516
+Node: History Interaction503088
+Node: Event Designators508038
+Node: Word Designators509616
+Node: Modifiers512008
+Node: Installing Bash513945
+Node: Basic Installation515061
+Node: Compilers and Options518937
+Node: Compiling For Multiple Architectures519687
+Node: Installation Names521440
+Node: Specifying the System Type523674
+Node: Sharing Defaults524420
+Node: Operation Controls525134
+Node: Optional Features526153
+Node: Reporting Bugs538876
+Node: Major Differences From The Bourne Shell540233
+Node: GNU Free Documentation License561660
+Node: Indexes586837
+Node: Builtin Index587288
+Node: Reserved Word Index594386
+Node: Variable Index596831
+Node: Function Index614244
+Node: Concept Index628239
End Tag Table
diff --git a/doc/bash.pdf b/doc/bash.pdf
index eb9f142a..c861b55f 100644
Binary files a/doc/bash.pdf and b/doc/bash.pdf differ
diff --git a/doc/bashref.aux b/doc/bashref.aux
index 5743a0e1..dc5bd7d7 100644
--- a/doc/bashref.aux
+++ b/doc/bashref.aux
@@ -330,9 +330,9 @@
@xrdef{Event Designators-pg}{172}
@xrdef{Word Designators-title}{Word Designators}
@xrdef{Word Designators-snt}{Section@tie 9.3.2}
+@xrdef{Word Designators-pg}{173}
@xrdef{Modifiers-title}{Modifiers}
@xrdef{Modifiers-snt}{Section@tie 9.3.3}
-@xrdef{Word Designators-pg}{173}
@xrdef{Modifiers-pg}{174}
@xrdef{Installing Bash-title}{Installing Bash}
@xrdef{Installing Bash-snt}{Chapter@tie 10}
diff --git a/doc/bashref.bt b/doc/bashref.bt
index 054755d9..27c0dcf0 100644
--- a/doc/bashref.bt
+++ b/doc/bashref.bt
@@ -58,4 +58,4 @@
\entry{complete}{161}{\code {complete}}
\entry{compopt}{165}{\code {compopt}}
\entry{fc}{169}{\code {fc}}
-\entry{history}{169}{\code {history}}
+\entry{history}{170}{\code {history}}
diff --git a/doc/bashref.bts b/doc/bashref.bts
index 90717177..e7b501c5 100644
--- a/doc/bashref.bts
+++ b/doc/bashref.bts
@@ -39,7 +39,7 @@
\initial {H}
\entry{\code {hash}}{56}
\entry{\code {help}}{67}
-\entry{\code {history}}{169}
+\entry{\code {history}}{170}
\initial {J}
\entry{\code {jobs}}{127}
\initial {K}
diff --git a/doc/bashref.html b/doc/bashref.html
index bde971b4..9f198533 100644
--- a/doc/bashref.html
+++ b/doc/bashref.html
@@ -4,9 +4,9 @@
|