diff options
| author | Jari Aalto <jari.aalto@cante.net> | 2001-04-06 19:14:31 +0000 |
|---|---|---|
| committer | Jari Aalto <jari.aalto@cante.net> | 2009-09-12 16:46:53 +0000 |
| commit | 28ef6c316f1aff914bb95ac09787a3c83c1815fd (patch) | |
| tree | 2812fe7ffc9beec4f99856906ddfcafda54cf16a /bashhist.c | |
| parent | bb70624e964126b7ac4ff085ba163a9c35ffa18f (diff) | |
| download | android_external_bash-28ef6c316f1aff914bb95ac09787a3c83c1815fd.tar.gz android_external_bash-28ef6c316f1aff914bb95ac09787a3c83c1815fd.tar.bz2 android_external_bash-28ef6c316f1aff914bb95ac09787a3c83c1815fd.zip | |
Imported from ../bash-2.05.tar.gz.
Diffstat (limited to 'bashhist.c')
| -rw-r--r-- | bashhist.c | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -490,10 +490,10 @@ void maybe_add_history (line) char *line; { - int should_add; + static int first_line_saved = 0; HIST_ENTRY *temp; - should_add = hist_last_line_added = 0; + hist_last_line_added = 0; /* Don't use the value of history_control to affect the second and subsequent lines of a multi-line command (old code did @@ -504,19 +504,24 @@ maybe_add_history (line) if (current_command_line_count > 1) #endif { - if (literal_history || dstack.delimiter_depth != 0 || shell_comment (line) == 0) + if (first_line_saved && + (literal_history || dstack.delimiter_depth != 0 || shell_comment (line) == 0)) bash_add_history (line); return; } + /* This is the first line of a (possible multi-line) command. Note whether + or not we should save the first line and remember it. */ + first_line_saved = 0; + switch (history_control) { case 0: - should_add = 1; + first_line_saved = 1; break; case 1: if (*line != ' ') - should_add = 1; + first_line_saved = 1; break; case 3: if (*line == ' ') @@ -527,14 +532,16 @@ maybe_add_history (line) temp = previous_history (); if (temp == 0 || STREQ (temp->line, line) == 0) - should_add = 1; + first_line_saved = 1; using_history (); break; } - if (should_add && history_should_ignore (line) == 0) + if (first_line_saved && history_should_ignore (line) == 0) bash_add_history (line); + else + first_line_saved = 0; } /* Add a line to the history list. |
