Imported from ../bash-3.1.tar.gz.
This commit is contained in:
parent
eb87367179
commit
95732b497d
267 changed files with 24541 additions and 18843 deletions
|
|
@ -77,11 +77,13 @@ extern int errno;
|
|||
#endif
|
||||
|
||||
extern int current_command_line_count;
|
||||
extern int force_append_history; /* shopt -s histappend */
|
||||
|
||||
int delete_last_history __P((void));
|
||||
|
||||
static char *histtime __P((HIST_ENTRY *, const char *));
|
||||
static void display_history __P((WORD_LIST *));
|
||||
static int delete_histent __P((int));
|
||||
static int delete_last_history __P((void));
|
||||
static void push_history __P((WORD_LIST *));
|
||||
static int expand_and_print_history __P((WORD_LIST *));
|
||||
|
||||
|
|
@ -214,15 +216,19 @@ history_builtin (list)
|
|||
using_history ();
|
||||
|
||||
history_lines_in_file = where_history ();
|
||||
/* The question is whether we reset history_lines_this_session to 0,
|
||||
losing any history entries we had before we read the new entries
|
||||
from the history file, or whether we count the new entries we just
|
||||
read from the file as history lines added during this session.
|
||||
|
||||
/* If we're rewriting the history file at shell exit rather than just
|
||||
appending the lines from this session to it, the question is whether
|
||||
we reset history_lines_this_session to 0, losing any history entries
|
||||
we had before we read the new entries from the history file, or
|
||||
whether we count the new entries we just read from the file as
|
||||
history lines added during this session.
|
||||
Right now, we do the latter. This will cause these history entries
|
||||
to be written to the history file along with any intermediate entries
|
||||
we add when we do a `history -a', but the alternative is losing
|
||||
them altogether. */
|
||||
history_lines_this_session += history_lines_in_file - old_history_lines +
|
||||
if (force_append_history == 0)
|
||||
history_lines_this_session += history_lines_in_file - old_history_lines +
|
||||
history_base - obase;
|
||||
}
|
||||
|
||||
|
|
@ -310,7 +316,7 @@ delete_histent (i)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
delete_last_history ()
|
||||
{
|
||||
register int i;
|
||||
|
|
@ -353,9 +359,11 @@ push_history (list)
|
|||
If you don't want history -s to remove the compound command from the
|
||||
history, change #if 0 to #if 1 below. */
|
||||
#if 0
|
||||
if (hist_last_line_added && delete_last_history () == 0)
|
||||
if (hist_last_line_pushed == 0 && hist_last_line_added && delete_last_history () == 0)
|
||||
#else
|
||||
if ((hist_last_line_added || (current_command_line_count > 0 && current_command_first_line_saved && command_oriented_history))
|
||||
if (hist_last_line_pushed == 0 &&
|
||||
(hist_last_line_added ||
|
||||
(current_command_line_count > 0 && current_command_first_line_saved && command_oriented_history))
|
||||
&& delete_last_history () == 0)
|
||||
#endif
|
||||
return;
|
||||
|
|
@ -368,6 +376,8 @@ push_history (list)
|
|||
entry. Without FORCE=1, if current_command_line_count were > 1, the
|
||||
line would be appended to the entry before the just-deleted entry. */
|
||||
check_add_history (s, 1); /* obeys HISTCONTROL, HISTIGNORE */
|
||||
|
||||
hist_last_line_pushed = 1; /* XXX */
|
||||
free (s);
|
||||
}
|
||||
|
||||
|
|
@ -379,7 +389,7 @@ expand_and_print_history (list)
|
|||
char *s;
|
||||
int r, result;
|
||||
|
||||
if (hist_last_line_added && delete_last_history () == 0)
|
||||
if (hist_last_line_pushed == 0 && hist_last_line_added && delete_last_history () == 0)
|
||||
return EXECUTION_FAILURE;
|
||||
result = EXECUTION_SUCCESS;
|
||||
while (list)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue