summaryrefslogtreecommitdiff
path: root/data/bash/bash40-014
blob: eeba336cdf410c922547a8b74a795d2a3e905636 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
			     BASH PATCH REPORT
			     =================

Bash-Release:	4.0
Patch-ID:	bash40-014

Bug-Reported-by:	smallnow@gmail.com
Bug-Reference-ID:	<49C460FE.40307@gmail.com>
Bug-Reference-URL:	http://lists.gnu.org/archive/html/bug-bash/2009-03/msg00166.html

Bug-Description:

When the fc builtin is run in a command substitution from a shell with history
enabled, it does not correctly calculate the command on which to operate.

Patch:

*** ../bash-4.0-patched/builtins/fc.def	2009-01-04 14:32:22.000000000 -0500
--- builtins/fc.def	2009-03-21 14:03:43.000000000 -0400
***************
*** 89,92 ****
--- 89,93 ----
  extern int literal_history;
  extern int posixly_correct;
+ extern int subshell_environment, interactive_shell;
  
  extern int unlink __P((const char *));
***************
*** 173,177 ****
    register char *sep;
    int numbering, reverse, listing, execute;
!   int histbeg, histend, last_hist, retval, opt;
    FILE *stream;
    REPL *rlist, *rl;
--- 174,178 ----
    register char *sep;
    int numbering, reverse, listing, execute;
!   int histbeg, histend, last_hist, retval, opt, rh;
    FILE *stream;
    REPL *rlist, *rl;
***************
*** 276,279 ****
--- 277,282 ----
        fprintf (stderr, "%s\n", command);
        fc_replhist (command);	/* replace `fc -s' with command */
+       /* Posix says that the re-executed commands should be entered into the
+ 	 history. */
        return (parse_and_execute (command, "fc", SEVAL_NOHIST));
      }
***************
*** 294,298 ****
       so we check hist_last_line_added. */
  
!   last_hist = i - remember_on_history - hist_last_line_added;
  
    if (list)
--- 297,306 ----
       so we check hist_last_line_added. */
  
!   /* Even though command substitution through parse_and_execute turns off
!      remember_on_history, command substitution in a shell when set -o history
!      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 (list)
***************
*** 457,461 ****
       HIST_ENTRY **hlist;
  {
!   int sign, n, clen;
    register int i, j;
    register char *s;
--- 465,469 ----
       HIST_ENTRY **hlist;
  {
!   int sign, n, clen, rh;
    register int i, j;
    register char *s;
***************
*** 473,477 ****
       so we check hist_last_line_added.  This needs to agree with the
       calculation of last_hist in fc_builtin above. */
!   i -= remember_on_history + hist_last_line_added;
  
    /* No specification defaults to most recent command. */
--- 481,490 ----
       so we check hist_last_line_added.  This needs to agree with the
       calculation of last_hist in fc_builtin above. */
!   /* Even though command substitution through parse_and_execute turns off
!      remember_on_history, command substitution in a shell when set -o history
!      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);
!   i -= rh + hist_last_line_added;
  
    /* No specification defaults to most recent command. */
*** ../bash-4.0/patchlevel.h	2009-01-04 14:32:40.000000000 -0500
--- patchlevel.h	2009-02-22 16:11:31.000000000 -0500
***************
*** 26,30 ****
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 13
  
  #endif /* _PATCHLEVEL_H_ */
--- 26,30 ----
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 14
  
  #endif /* _PATCHLEVEL_H_ */