X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=bashhist.c;h=85e4eebec7f1981bea4d1f06763a1675feba9c26;hb=28ef6c316f1aff914bb95ac09787a3c83c1815fd;hp=3cc544c3d49c2f248df3ebfcec6521e01a5e00a7;hpb=bb70624e964126b7ac4ff085ba163a9c35ffa18f;p=platform%2Fupstream%2Fbash.git diff --git a/bashhist.c b/bashhist.c index 3cc544c..85e4eeb 100644 --- a/bashhist.c +++ b/bashhist.c @@ -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.