X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=builtins%2Ffc.def;h=257029dfa0f5f2b3411e2cbce439023444af8f55;hb=495aee441b75276e38c75694ccb455bb6463fdb9;hp=71f468fe3d8b122ea00afc34c3886d9047d7d6af;hpb=30d188c2932d6ef609d894fefeb7e7b03ccff463;p=platform%2Fupstream%2Fbash.git diff --git a/builtins/fc.def b/builtins/fc.def index 71f468f..257029d 100644 --- a/builtins/fc.def +++ b/builtins/fc.def @@ -1,7 +1,7 @@ This file is fc.def, from which is created fc.c. It implements the builtin "fc" in Bash. -Copyright (C) 1987-2009 Free Software Foundation, Inc. +Copyright (C) 1987-2010 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -85,7 +85,7 @@ $END extern int errno; #endif /* !errno */ -extern int current_command_line_count; +extern int current_command_line_count, saved_command_line_count; extern int literal_history; extern int posixly_correct; extern int subshell_environment, interactive_shell; @@ -304,7 +304,7 @@ fc_builtin (list) last_hist = i - rh - hist_last_line_added; /* XXX */ - if (i == last_hist && hlist[last_hist] == 0) + if (saved_command_line_count > 0 && i == last_hist && hlist[last_hist] == 0) while (last_hist >= 0 && hlist[last_hist] == 0) last_hist--; if (last_hist < 0) @@ -475,7 +475,7 @@ fc_gethnum (command, hlist) HIST_ENTRY **hlist; { int sign, n, clen, rh; - register int i, j, last_hist; + register int i, j; register char *s; sign = 1; @@ -495,15 +495,7 @@ fc_gethnum (command, hlist) has been enabled (interactive or not) should use it in the last_hist calculation as if it were on. */ rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list); - last_hist = i - rh - hist_last_line_added; - - if (i == last_hist && hlist[last_hist] == 0) - while (last_hist >= 0 && hlist[last_hist] == 0) - last_hist--; - if (last_hist < 0) - return (-1); - - i = last_hist; + i -= rh + hist_last_line_added; /* No specification defaults to most recent command. */ if (command == NULL)