Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/history.def |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||||||||
8 | - | |||||||||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||||||||
10 | - | |||||||||||||||||||||||||||||||
11 | - | |||||||||||||||||||||||||||||||
12 | - | |||||||||||||||||||||||||||||||
13 | - | |||||||||||||||||||||||||||||||
14 | - | |||||||||||||||||||||||||||||||
15 | static char *histtime (HIST_ENTRY *, const char *); | - | ||||||||||||||||||||||||||||||
16 | static int display_history (WORD_LIST *); | - | ||||||||||||||||||||||||||||||
17 | static void push_history (WORD_LIST *); | - | ||||||||||||||||||||||||||||||
18 | static int expand_and_print_history (WORD_LIST *); | - | ||||||||||||||||||||||||||||||
19 | int | - | ||||||||||||||||||||||||||||||
20 | history_builtin (list) | - | ||||||||||||||||||||||||||||||
21 | WORD_LIST *list; | - | ||||||||||||||||||||||||||||||
22 | { | - | ||||||||||||||||||||||||||||||
23 | int flags, opt, result, old_history_lines, obase, ind; | - | ||||||||||||||||||||||||||||||
24 | char *filename, *delete_arg, *range; | - | ||||||||||||||||||||||||||||||
25 | intmax_t delete_offset; | - | ||||||||||||||||||||||||||||||
26 | - | |||||||||||||||||||||||||||||||
27 | flags = 0; | - | ||||||||||||||||||||||||||||||
28 | reset_internal_getopt (); | - | ||||||||||||||||||||||||||||||
29 | while ((
| 32-45 | ||||||||||||||||||||||||||||||
30 | { | - | ||||||||||||||||||||||||||||||
31 | switch (opt) | - | ||||||||||||||||||||||||||||||
32 | { | - | ||||||||||||||||||||||||||||||
33 | case executed 2 times by 1 test: 'a':case 'a': Executed by:
executed 2 times by 1 test: case 'a': Executed by:
| 2 | ||||||||||||||||||||||||||||||
34 | flags |= 0x01; | - | ||||||||||||||||||||||||||||||
35 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||||||||
36 | case executed 6 times by 1 test: 'c':case 'c': Executed by:
executed 6 times by 1 test: case 'c': Executed by:
| 6 | ||||||||||||||||||||||||||||||
37 | flags |= 0x40; | - | ||||||||||||||||||||||||||||||
38 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||||||||
39 | case executed 1 time by 1 test: 'n':case 'n': Executed by:
executed 1 time by 1 test: case 'n': Executed by:
| 1 | ||||||||||||||||||||||||||||||
40 | flags |= 0x08; | - | ||||||||||||||||||||||||||||||
41 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||||||||
42 | case executed 2 times by 1 test: 'r':case 'r': Executed by:
executed 2 times by 1 test: case 'r': Executed by:
| 2 | ||||||||||||||||||||||||||||||
43 | flags |= 0x02; | - | ||||||||||||||||||||||||||||||
44 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||||||||
45 | case executed 3 times by 1 test: 'w':case 'w': Executed by:
executed 3 times by 1 test: case 'w': Executed by:
| 3 | ||||||||||||||||||||||||||||||
46 | flags |= 0x04; | - | ||||||||||||||||||||||||||||||
47 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||||||||||||||
48 | case executed 3 times by 1 test: 's':case 's': Executed by:
executed 3 times by 1 test: case 's': Executed by:
| 3 | ||||||||||||||||||||||||||||||
49 | flags |= 0x10; | - | ||||||||||||||||||||||||||||||
50 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||||||||||||||
51 | case executed 7 times by 1 test: 'd':case 'd': Executed by:
executed 7 times by 1 test: case 'd': Executed by:
| 7 | ||||||||||||||||||||||||||||||
52 | flags |= 0x80; | - | ||||||||||||||||||||||||||||||
53 | delete_arg = list_optarg; | - | ||||||||||||||||||||||||||||||
54 | break; executed 7 times by 1 test: break; Executed by:
| 7 | ||||||||||||||||||||||||||||||
55 | case executed 7 times by 1 test: 'p':case 'p': Executed by:
executed 7 times by 1 test: case 'p': Executed by:
| 7 | ||||||||||||||||||||||||||||||
56 | - | |||||||||||||||||||||||||||||||
57 | flags |= 0x20; | - | ||||||||||||||||||||||||||||||
58 | - | |||||||||||||||||||||||||||||||
59 | break; executed 7 times by 1 test: break; Executed by:
| 7 | ||||||||||||||||||||||||||||||
60 | case never executed: -99:case -99: never executed: builtin_help (); returncase -99: never executed: (258);return (258); never executed: return (258); | 0 | ||||||||||||||||||||||||||||||
61 | default executed 1 time by 1 test: :default: Executed by:
executed 1 time by 1 test: default: Executed by:
| 1 | ||||||||||||||||||||||||||||||
62 | builtin_usage (); | - | ||||||||||||||||||||||||||||||
63 | return executed 1 time by 1 test: (258);return (258); Executed by:
executed 1 time by 1 test: return (258); Executed by:
| 1 | ||||||||||||||||||||||||||||||
64 | } | - | ||||||||||||||||||||||||||||||
65 | } | - | ||||||||||||||||||||||||||||||
66 | list = loptend; | - | ||||||||||||||||||||||||||||||
67 | - | |||||||||||||||||||||||||||||||
68 | opt = flags & (0x01|0x02|0x04|0x08); | - | ||||||||||||||||||||||||||||||
69 | if (opt
| 1-38 | ||||||||||||||||||||||||||||||
70 | { | - | ||||||||||||||||||||||||||||||
71 | builtin_error ( | - | ||||||||||||||||||||||||||||||
72 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||||||||
73 | "cannot use more than one of -anrw" | - | ||||||||||||||||||||||||||||||
74 | , 5) | - | ||||||||||||||||||||||||||||||
75 | ); | - | ||||||||||||||||||||||||||||||
76 | return executed 1 time by 1 test: (1);return (1); Executed by:
executed 1 time by 1 test: return (1); Executed by:
| 1 | ||||||||||||||||||||||||||||||
77 | } | - | ||||||||||||||||||||||||||||||
78 | - | |||||||||||||||||||||||||||||||
79 | - | |||||||||||||||||||||||||||||||
80 | if (flags & 0x40
| 6-38 | ||||||||||||||||||||||||||||||
81 | { | - | ||||||||||||||||||||||||||||||
82 | bash_clear_history (); | - | ||||||||||||||||||||||||||||||
83 | if (list == 0
| 0-6 | ||||||||||||||||||||||||||||||
84 | return executed 6 times by 1 test: (0);return (0); Executed by:
executed 6 times by 1 test: return (0); Executed by:
| 6 | ||||||||||||||||||||||||||||||
85 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
86 | - | |||||||||||||||||||||||||||||||
87 | if (flags & 0x10
| 3-35 | ||||||||||||||||||||||||||||||
88 | { | - | ||||||||||||||||||||||||||||||
89 | if (list
| 0-3 | ||||||||||||||||||||||||||||||
90 | push_history (list); executed 3 times by 1 test: push_history (list); Executed by:
| 3 | ||||||||||||||||||||||||||||||
91 | return executed 3 times by 1 test: (0);return (0); Executed by:
executed 3 times by 1 test: return (0); Executed by:
| 3 | ||||||||||||||||||||||||||||||
92 | } | - | ||||||||||||||||||||||||||||||
93 | - | |||||||||||||||||||||||||||||||
94 | else if (flags & 0x20
| 7-28 | ||||||||||||||||||||||||||||||
95 | { | - | ||||||||||||||||||||||||||||||
96 | if (list
| 0-7 | ||||||||||||||||||||||||||||||
97 | return executed 7 times by 1 test: (expand_and_print_history (list));return (expand_and_print_history (list)); Executed by:
executed 7 times by 1 test: return (expand_and_print_history (list)); Executed by:
| 7 | ||||||||||||||||||||||||||||||
98 | return never executed: (sh_chkwrite (0));return (sh_chkwrite (0)); never executed: return (sh_chkwrite (0)); | 0 | ||||||||||||||||||||||||||||||
99 | } | - | ||||||||||||||||||||||||||||||
100 | - | |||||||||||||||||||||||||||||||
101 | else if ((
| 0-21 | ||||||||||||||||||||||||||||||
102 | (__extension__ (__builtin_constant_p (
| 0-7 | ||||||||||||||||||||||||||||||
103 | '-'
| 0-7 | ||||||||||||||||||||||||||||||
104 | )
| 0-7 | ||||||||||||||||||||||||||||||
105 | (delete_arg[0] == '-') ? delete_arg + 1 : delete_arg
| 0-7 | ||||||||||||||||||||||||||||||
106 | )
| 0-7 | ||||||||||||||||||||||||||||||
107 | '-'
| 0-7 | ||||||||||||||||||||||||||||||
108 | ) == '\0'
| 0-7 | ||||||||||||||||||||||||||||||
109 | (delete_arg[0] == '-') ? delete_arg + 1 : delete_arg
| 0-7 | ||||||||||||||||||||||||||||||
110 | ,
| 0-7 | ||||||||||||||||||||||||||||||
111 | '-'
| 0-7 | ||||||||||||||||||||||||||||||
112 | ) : __builtin_strchr (
| 0-7 | ||||||||||||||||||||||||||||||
113 | (delete_arg[0] == '-') ? delete_arg + 1 : delete_arg
| 0-7 | ||||||||||||||||||||||||||||||
114 | ,
| 0-7 | ||||||||||||||||||||||||||||||
115 | '-'
| 0-7 | ||||||||||||||||||||||||||||||
116 | )))
| 0-7 | ||||||||||||||||||||||||||||||
117 | )
| 0-7 | ||||||||||||||||||||||||||||||
118 | { | - | ||||||||||||||||||||||||||||||
119 | intmax_t delete_start, delete_end; | - | ||||||||||||||||||||||||||||||
120 | *range++ = '\0'; | - | ||||||||||||||||||||||||||||||
121 | if (legal_number (delete_arg, &delete_start) == 0
| 0-7 | ||||||||||||||||||||||||||||||
122 | { | - | ||||||||||||||||||||||||||||||
123 | range[-1] = '-'; | - | ||||||||||||||||||||||||||||||
124 | sh_erange (delete_arg, | - | ||||||||||||||||||||||||||||||
125 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||||||||
126 | "history position" | - | ||||||||||||||||||||||||||||||
127 | , 5) | - | ||||||||||||||||||||||||||||||
128 | ); | - | ||||||||||||||||||||||||||||||
129 | return executed 1 time by 1 test: (1);return (1); Executed by:
executed 1 time by 1 test: return (1); Executed by:
| 1 | ||||||||||||||||||||||||||||||
130 | } | - | ||||||||||||||||||||||||||||||
131 | if (delete_arg[0] == '-'
| 0-5 | ||||||||||||||||||||||||||||||
132 | { | - | ||||||||||||||||||||||||||||||
133 | - | |||||||||||||||||||||||||||||||
134 | delete_start += history_length; | - | ||||||||||||||||||||||||||||||
135 | if (delete_start < history_base
| 0-1 | ||||||||||||||||||||||||||||||
136 | { | - | ||||||||||||||||||||||||||||||
137 | start_error: | - | ||||||||||||||||||||||||||||||
138 | sh_erange (delete_arg, | - | ||||||||||||||||||||||||||||||
139 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||||||||
140 | "history position" | - | ||||||||||||||||||||||||||||||
141 | , 5) | - | ||||||||||||||||||||||||||||||
142 | ); | - | ||||||||||||||||||||||||||||||
143 | return executed 2 times by 1 test: (1);return (1); Executed by:
executed 2 times by 1 test: return (1); Executed by:
| 2 | ||||||||||||||||||||||||||||||
144 | } | - | ||||||||||||||||||||||||||||||
145 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
146 | - | |||||||||||||||||||||||||||||||
147 | else if (delete_start > 0
| 0-5 | ||||||||||||||||||||||||||||||
148 | delete_start -= history_base; executed 5 times by 1 test: delete_start -= history_base; Executed by:
| 5 | ||||||||||||||||||||||||||||||
149 | if (delete_start < 0
| 0-5 | ||||||||||||||||||||||||||||||
150 | goto executed 1 time by 1 test: start_error;goto start_error; Executed by:
executed 1 time by 1 test: goto start_error; Executed by:
| 1 | ||||||||||||||||||||||||||||||
151 | if (range[0] == '-'
| 0-2 | ||||||||||||||||||||||||||||||
152 | { | - | ||||||||||||||||||||||||||||||
153 | delete_end += history_length; | - | ||||||||||||||||||||||||||||||
154 | if (delete_end < history_base
| 1 | ||||||||||||||||||||||||||||||
155 | { | - | ||||||||||||||||||||||||||||||
156 | range_error: | - | ||||||||||||||||||||||||||||||
157 | sh_erange (range, | - | ||||||||||||||||||||||||||||||
158 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||||||||
159 | "history position" | - | ||||||||||||||||||||||||||||||
160 | , 5) | - | ||||||||||||||||||||||||||||||
161 | ); | - | ||||||||||||||||||||||||||||||
162 | return executed 2 times by 1 test: (1);return (1); Executed by:
executed 2 times by 1 test: return (1); Executed by:
| 2 | ||||||||||||||||||||||||||||||
163 | } | - | ||||||||||||||||||||||||||||||
164 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||||||||
165 | else if (delete_end > 0
| 0-2 | ||||||||||||||||||||||||||||||
166 | delete_end -= history_base; executed 2 times by 1 test: delete_end -= history_base; Executed by:
| 2 | ||||||||||||||||||||||||||||||
167 | if (delete_end < 0
| 0-3 | ||||||||||||||||||||||||||||||
168 | goto executed 1 time by 1 test: range_error;goto range_error; Executed by:
executed 1 time by 1 test: goto range_error; Executed by:
| 1 | ||||||||||||||||||||||||||||||
169 | result = bash_delete_history_range (delete_start, delete_end); | - | ||||||||||||||||||||||||||||||
170 | if (where_history () > history_length
| 0-2 | ||||||||||||||||||||||||||||||
171 | history_set_pos (history_length); executed 2 times by 1 test: history_set_pos (history_length); Executed by:
| 2 | ||||||||||||||||||||||||||||||
172 | return executed 2 times by 1 test: (result ? 0 : 1);return (result ? 0 : 1); Executed by:
executed 2 times by 1 test: return (result ? 0 : 1); Executed by:
| 2 | ||||||||||||||||||||||||||||||
173 | } | - | ||||||||||||||||||||||||||||||
174 | else if (flags & 0x80
| 0-21 | ||||||||||||||||||||||||||||||
175 | { | - | ||||||||||||||||||||||||||||||
176 | if (legal_number (delete_arg, &delete_offset) == 0
| 0 | ||||||||||||||||||||||||||||||
177 | { | - | ||||||||||||||||||||||||||||||
178 | sh_erange (delete_arg, | - | ||||||||||||||||||||||||||||||
179 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||||||||
180 | "history position" | - | ||||||||||||||||||||||||||||||
181 | , 5) | - | ||||||||||||||||||||||||||||||
182 | ); | - | ||||||||||||||||||||||||||||||
183 | return never executed: (1);return (1); never executed: return (1); | 0 | ||||||||||||||||||||||||||||||
184 | } | - | ||||||||||||||||||||||||||||||
185 | - | |||||||||||||||||||||||||||||||
186 | if (delete_arg[0] == '-'
| 0 | ||||||||||||||||||||||||||||||
187 | { | - | ||||||||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||||||||
189 | - | |||||||||||||||||||||||||||||||
190 | - | |||||||||||||||||||||||||||||||
191 | ind = history_length + delete_offset; | - | ||||||||||||||||||||||||||||||
192 | if (ind < history_base
| 0 | ||||||||||||||||||||||||||||||
193 | { | - | ||||||||||||||||||||||||||||||
194 | sh_erange (delete_arg, | - | ||||||||||||||||||||||||||||||
195 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||||||||
196 | "history position" | - | ||||||||||||||||||||||||||||||
197 | , 5) | - | ||||||||||||||||||||||||||||||
198 | ); | - | ||||||||||||||||||||||||||||||
199 | return never executed: (1);return (1); never executed: return (1); | 0 | ||||||||||||||||||||||||||||||
200 | } | - | ||||||||||||||||||||||||||||||
201 | opt = ind + history_base; | - | ||||||||||||||||||||||||||||||
202 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
203 | else if ((
| 0 | ||||||||||||||||||||||||||||||
204 | { | - | ||||||||||||||||||||||||||||||
205 | sh_erange (delete_arg, | - | ||||||||||||||||||||||||||||||
206 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||||||||
207 | "history position" | - | ||||||||||||||||||||||||||||||
208 | , 5) | - | ||||||||||||||||||||||||||||||
209 | ); | - | ||||||||||||||||||||||||||||||
210 | return never executed: (1);return (1); never executed: return (1); | 0 | ||||||||||||||||||||||||||||||
211 | } | - | ||||||||||||||||||||||||||||||
212 | else | - | ||||||||||||||||||||||||||||||
213 | opt = delete_offset; never executed: opt = delete_offset; | 0 | ||||||||||||||||||||||||||||||
214 | - | |||||||||||||||||||||||||||||||
215 | - | |||||||||||||||||||||||||||||||
216 | - | |||||||||||||||||||||||||||||||
217 | result = bash_delete_histent (opt - history_base); | - | ||||||||||||||||||||||||||||||
218 | - | |||||||||||||||||||||||||||||||
219 | - | |||||||||||||||||||||||||||||||
220 | if (where_history () > history_length
| 0 | ||||||||||||||||||||||||||||||
221 | history_set_pos (history_length); never executed: history_set_pos (history_length); | 0 | ||||||||||||||||||||||||||||||
222 | return never executed: (result ? 0 : 1);return (result ? 0 : 1); never executed: return (result ? 0 : 1); | 0 | ||||||||||||||||||||||||||||||
223 | } | - | ||||||||||||||||||||||||||||||
224 | else if ((
| 6-15 | ||||||||||||||||||||||||||||||
225 | { | - | ||||||||||||||||||||||||||||||
226 | result = display_history (list); | - | ||||||||||||||||||||||||||||||
227 | return executed 15 times by 1 test: (sh_chkwrite (result));return (sh_chkwrite (result)); Executed by:
executed 15 times by 1 test: return (sh_chkwrite (result)); Executed by:
| 15 | ||||||||||||||||||||||||||||||
228 | } | - | ||||||||||||||||||||||||||||||
229 | - | |||||||||||||||||||||||||||||||
230 | filename = list
| 2-4 | ||||||||||||||||||||||||||||||
231 | result = 0; | - | ||||||||||||||||||||||||||||||
232 | - | |||||||||||||||||||||||||||||||
233 | if (flags & 0x01
| 2-4 | ||||||||||||||||||||||||||||||
234 | result = maybe_append_history (filename); executed 2 times by 1 test: result = maybe_append_history (filename); Executed by:
| 2 | ||||||||||||||||||||||||||||||
235 | else if (flags & 0x04
| 2 | ||||||||||||||||||||||||||||||
236 | result = write_history (filename); executed 2 times by 1 test: result = write_history (filename); Executed by:
| 2 | ||||||||||||||||||||||||||||||
237 | else if (flags & 0x02
| 1 | ||||||||||||||||||||||||||||||
238 | { | - | ||||||||||||||||||||||||||||||
239 | result = read_history (filename); | - | ||||||||||||||||||||||||||||||
240 | history_lines_in_file = history_lines_read_from_file; | - | ||||||||||||||||||||||||||||||
241 | - | |||||||||||||||||||||||||||||||
242 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||||||||
243 | else if (flags & 0x08
| 0-1 | ||||||||||||||||||||||||||||||
244 | { | - | ||||||||||||||||||||||||||||||
245 | - | |||||||||||||||||||||||||||||||
246 | old_history_lines = history_lines_in_file; | - | ||||||||||||||||||||||||||||||
247 | obase = history_base; | - | ||||||||||||||||||||||||||||||
248 | - | |||||||||||||||||||||||||||||||
249 | using_history (); | - | ||||||||||||||||||||||||||||||
250 | result = read_history_range (filename, history_lines_in_file, -1); | - | ||||||||||||||||||||||||||||||
251 | using_history (); | - | ||||||||||||||||||||||||||||||
252 | - | |||||||||||||||||||||||||||||||
253 | history_lines_in_file = history_lines_read_from_file; | - | ||||||||||||||||||||||||||||||
254 | if (force_append_history == 0
| 0-1 | ||||||||||||||||||||||||||||||
255 | history_lines_this_session += history_lines_in_file - old_history_lines + executed 1 time by 1 test: history_lines_this_session += history_lines_in_file - old_history_lines + history_base - obase; Executed by:
| 1 | ||||||||||||||||||||||||||||||
256 | history_base - obase; executed 1 time by 1 test: history_lines_this_session += history_lines_in_file - old_history_lines + history_base - obase; Executed by:
| 1 | ||||||||||||||||||||||||||||||
257 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||||||||
258 | - | |||||||||||||||||||||||||||||||
259 | return executed 6 times by 1 test: (result ? 1 : 0);return (result ? 1 : 0); Executed by:
executed 6 times by 1 test: return (result ? 1 : 0); Executed by:
| 6 | ||||||||||||||||||||||||||||||
260 | } | - | ||||||||||||||||||||||||||||||
261 | - | |||||||||||||||||||||||||||||||
262 | - | |||||||||||||||||||||||||||||||
263 | - | |||||||||||||||||||||||||||||||
264 | - | |||||||||||||||||||||||||||||||
265 | - | |||||||||||||||||||||||||||||||
266 | static char * | - | ||||||||||||||||||||||||||||||
267 | histtime (hlist, histtimefmt) | - | ||||||||||||||||||||||||||||||
268 | HIST_ENTRY *hlist; | - | ||||||||||||||||||||||||||||||
269 | const char *histtimefmt; | - | ||||||||||||||||||||||||||||||
270 | { | - | ||||||||||||||||||||||||||||||
271 | static char timestr[128]; | - | ||||||||||||||||||||||||||||||
272 | time_t t; | - | ||||||||||||||||||||||||||||||
273 | struct tm *tm; | - | ||||||||||||||||||||||||||||||
274 | - | |||||||||||||||||||||||||||||||
275 | t = history_get_time (hlist); | - | ||||||||||||||||||||||||||||||
276 | tm = t
| 0 | ||||||||||||||||||||||||||||||
277 | if (t
| 0 | ||||||||||||||||||||||||||||||
278 | strftime (timestr, sizeof (timestr), histtimefmt, tm); never executed: strftime (timestr, sizeof (timestr), histtimefmt, tm); | 0 | ||||||||||||||||||||||||||||||
279 | else if (hlist->timestamp
| 0 | ||||||||||||||||||||||||||||||
280 | snprintf (timestr, sizeof (timestr), never executed: snprintf (timestr, sizeof (timestr), dcgettext (((void *)0), "%s: invalid timestamp" , 5) , (hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp); | 0 | ||||||||||||||||||||||||||||||
281 | dcgettext (((void *)0), never executed: snprintf (timestr, sizeof (timestr), dcgettext (((void *)0), "%s: invalid timestamp" , 5) , (hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp); | 0 | ||||||||||||||||||||||||||||||
282 | "%s: invalid timestamp" never executed: snprintf (timestr, sizeof (timestr), dcgettext (((void *)0), "%s: invalid timestamp" , 5) , (hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp); | 0 | ||||||||||||||||||||||||||||||
283 | , 5) never executed: snprintf (timestr, sizeof (timestr), dcgettext (((void *)0), "%s: invalid timestamp" , 5) , (hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp); | 0 | ||||||||||||||||||||||||||||||
284 | , never executed: snprintf (timestr, sizeof (timestr), dcgettext (((void *)0), "%s: invalid timestamp" , 5) , (hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp); | 0 | ||||||||||||||||||||||||||||||
285 | (hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp); never executed: snprintf (timestr, sizeof (timestr), dcgettext (((void *)0), "%s: invalid timestamp" , 5) , (hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp); | 0 | ||||||||||||||||||||||||||||||
286 | else | - | ||||||||||||||||||||||||||||||
287 | strcpy (timestr, "??"); never executed: strcpy (timestr, "??"); | 0 | ||||||||||||||||||||||||||||||
288 | return never executed: timestr;return timestr; never executed: return timestr; | 0 | ||||||||||||||||||||||||||||||
289 | } | - | ||||||||||||||||||||||||||||||
290 | - | |||||||||||||||||||||||||||||||
291 | static int | - | ||||||||||||||||||||||||||||||
292 | display_history (list) | - | ||||||||||||||||||||||||||||||
293 | WORD_LIST *list; | - | ||||||||||||||||||||||||||||||
294 | { | - | ||||||||||||||||||||||||||||||
295 | register int i; | - | ||||||||||||||||||||||||||||||
296 | intmax_t limit; | - | ||||||||||||||||||||||||||||||
297 | HIST_ENTRY **hlist; | - | ||||||||||||||||||||||||||||||
298 | char *histtimefmt, *timestr; | - | ||||||||||||||||||||||||||||||
299 | - | |||||||||||||||||||||||||||||||
300 | if (list
| 1-14 | ||||||||||||||||||||||||||||||
301 | { | - | ||||||||||||||||||||||||||||||
302 | if (get_numeric_arg (list, 0, &limit) == 0
| 0-1 | ||||||||||||||||||||||||||||||
303 | return never executed: (1);return (1); never executed: return (1); | 0 | ||||||||||||||||||||||||||||||
304 | - | |||||||||||||||||||||||||||||||
305 | if (limit < 0
| 0-1 | ||||||||||||||||||||||||||||||
306 | limit = -limit; never executed: limit = -limit; | 0 | ||||||||||||||||||||||||||||||
307 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||||||||
308 | else | - | ||||||||||||||||||||||||||||||
309 | limit = -1; executed 14 times by 1 test: limit = -1; Executed by:
| 14 | ||||||||||||||||||||||||||||||
310 | - | |||||||||||||||||||||||||||||||
311 | hlist = history_list (); | - | ||||||||||||||||||||||||||||||
312 | - | |||||||||||||||||||||||||||||||
313 | if (hlist
| 0-15 | ||||||||||||||||||||||||||||||
314 | { | - | ||||||||||||||||||||||||||||||
315 | for (i = 0; hlist[i]
| 15-135 | ||||||||||||||||||||||||||||||
316 | ; executed 135 times by 1 test: ; Executed by:
| 135 | ||||||||||||||||||||||||||||||
317 | - | |||||||||||||||||||||||||||||||
318 | if (0 <= limit
| 0-14 | ||||||||||||||||||||||||||||||
319 | i -= limit; executed 1 time by 1 test: i -= limit; Executed by:
| 1 | ||||||||||||||||||||||||||||||
320 | else | - | ||||||||||||||||||||||||||||||
321 | i = 0; executed 14 times by 1 test: i = 0; Executed by:
| 14 | ||||||||||||||||||||||||||||||
322 | - | |||||||||||||||||||||||||||||||
323 | histtimefmt = get_string_value ("HISTTIMEFORMAT"); | - | ||||||||||||||||||||||||||||||
324 | - | |||||||||||||||||||||||||||||||
325 | while (hlist[i]
| 15-122 | ||||||||||||||||||||||||||||||
326 | { | - | ||||||||||||||||||||||||||||||
327 | do { if (terminating_signal
never executed: if (interrupt_statetermsig_handler (terminating_signal);
never executed: } while (0);throw_to_top_level (); | 0-122 | ||||||||||||||||||||||||||||||
328 | - | |||||||||||||||||||||||||||||||
329 | timestr = (histtimefmt
| 0-122 | ||||||||||||||||||||||||||||||
330 | ((void *)0) | - | ||||||||||||||||||||||||||||||
331 | ; | - | ||||||||||||||||||||||||||||||
332 | printf ("%5d%c %s%s\n", i + history_base, | - | ||||||||||||||||||||||||||||||
333 | (hlist[(i)]->data) ? '*' : ' ', | - | ||||||||||||||||||||||||||||||
334 | ((timestr && *timestr) ? timestr : ""), | - | ||||||||||||||||||||||||||||||
335 | (hlist[(i)]->line)); | - | ||||||||||||||||||||||||||||||
336 | i++; | - | ||||||||||||||||||||||||||||||
337 | } executed 122 times by 1 test: end of block Executed by:
| 122 | ||||||||||||||||||||||||||||||
338 | } executed 15 times by 1 test: end of block Executed by:
| 15 | ||||||||||||||||||||||||||||||
339 | - | |||||||||||||||||||||||||||||||
340 | return executed 15 times by 1 test: (0);return (0); Executed by:
executed 15 times by 1 test: return (0); Executed by:
| 15 | ||||||||||||||||||||||||||||||
341 | } | - | ||||||||||||||||||||||||||||||
342 | - | |||||||||||||||||||||||||||||||
343 | - | |||||||||||||||||||||||||||||||
344 | - | |||||||||||||||||||||||||||||||
345 | static void | - | ||||||||||||||||||||||||||||||
346 | push_history (list) | - | ||||||||||||||||||||||||||||||
347 | WORD_LIST *list; | - | ||||||||||||||||||||||||||||||
348 | { | - | ||||||||||||||||||||||||||||||
349 | char *s; | - | ||||||||||||||||||||||||||||||
350 | if (remember_on_history
| 0-3 | ||||||||||||||||||||||||||||||
351 | (hist_last_line_added
| 0-3 | ||||||||||||||||||||||||||||||
352 | (current_command_line_count > 0
| 0-3 | ||||||||||||||||||||||||||||||
353 | && bash_delete_last_history () == 0
| 0 | ||||||||||||||||||||||||||||||
354 | - | |||||||||||||||||||||||||||||||
355 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
356 | - | |||||||||||||||||||||||||||||||
357 | s = string_list (list); | - | ||||||||||||||||||||||||||||||
358 | - | |||||||||||||||||||||||||||||||
359 | - | |||||||||||||||||||||||||||||||
360 | - | |||||||||||||||||||||||||||||||
361 | - | |||||||||||||||||||||||||||||||
362 | - | |||||||||||||||||||||||||||||||
363 | - | |||||||||||||||||||||||||||||||
364 | check_add_history (s, 1); | - | ||||||||||||||||||||||||||||||
365 | - | |||||||||||||||||||||||||||||||
366 | hist_last_line_pushed = 1; | - | ||||||||||||||||||||||||||||||
367 | sh_xfree((s), "./history.def", 423); | - | ||||||||||||||||||||||||||||||
368 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||||||||||||||
369 | - | |||||||||||||||||||||||||||||||
370 | - | |||||||||||||||||||||||||||||||
371 | static int | - | ||||||||||||||||||||||||||||||
372 | expand_and_print_history (list) | - | ||||||||||||||||||||||||||||||
373 | WORD_LIST *list; | - | ||||||||||||||||||||||||||||||
374 | { | - | ||||||||||||||||||||||||||||||
375 | char *s; | - | ||||||||||||||||||||||||||||||
376 | int r, result; | - | ||||||||||||||||||||||||||||||
377 | - | |||||||||||||||||||||||||||||||
378 | if (hist_last_line_pushed == 0
| 0-5 | ||||||||||||||||||||||||||||||
379 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||||||||
380 | result = 0; | - | ||||||||||||||||||||||||||||||
381 | while (list
| 7 | ||||||||||||||||||||||||||||||
382 | { | - | ||||||||||||||||||||||||||||||
383 | r = history_expand (list->word->word, &s); | - | ||||||||||||||||||||||||||||||
384 | if (r < 0
| 1-6 | ||||||||||||||||||||||||||||||
385 | { | - | ||||||||||||||||||||||||||||||
386 | builtin_error ( | - | ||||||||||||||||||||||||||||||
387 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||||||||
388 | "%s: history expansion failed" | - | ||||||||||||||||||||||||||||||
389 | , 5) | - | ||||||||||||||||||||||||||||||
390 | , list->word->word); | - | ||||||||||||||||||||||||||||||
391 | result = 1; | - | ||||||||||||||||||||||||||||||
392 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||||||||
393 | else | - | ||||||||||||||||||||||||||||||
394 | { | - | ||||||||||||||||||||||||||||||
395 | fputs (s, | - | ||||||||||||||||||||||||||||||
396 | stdout | - | ||||||||||||||||||||||||||||||
397 | ); | - | ||||||||||||||||||||||||||||||
398 | putchar ('\n'); | - | ||||||||||||||||||||||||||||||
399 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||||||||
400 | do { if (s
executed 7 times by 1 test: } while (0);sh_xfree((s), "./history.def", 450); Executed by:
| 0-7 | ||||||||||||||||||||||||||||||
401 | list = list->next; | - | ||||||||||||||||||||||||||||||
402 | } executed 7 times by 1 test: end of block Executed by:
| 7 | ||||||||||||||||||||||||||||||
403 | fflush ( | - | ||||||||||||||||||||||||||||||
404 | stdout | - | ||||||||||||||||||||||||||||||
405 | ); | - | ||||||||||||||||||||||||||||||
406 | return executed 7 times by 1 test: result;return result; Executed by:
executed 7 times by 1 test: return result; Executed by:
| 7 | ||||||||||||||||||||||||||||||
407 | } | - | ||||||||||||||||||||||||||||||
Switch to Source code | Preprocessed file |