source: patches/bash-4.3-branch_update-5.patch@ 04373b6

sysvinit
Last change on this file since 04373b6 was 9d809e0, checked in by William Harrington <kb0iic@…>, 10 years ago

Add bash-4.3-branch_update-5.patch for patch level 30. Thanks to zippo for the nudge.

  • Property mode set to 100644
File size: 126.1 KB
RevLine 
[9d809e0]1Submitted By: William Harrington (kb0iic at cross-lfs dot org)
2Date: 10-10-2014
3Initial Package Version: 4.3
4Origin: Upstream
5Upstream Status: Applied
6Description: Contains all upstream patches up to 4.3-030
7
8diff -Naur bash-4.3.orig/arrayfunc.c bash-4.3/arrayfunc.c
9--- bash-4.3.orig/arrayfunc.c 2013-08-02 20:19:59.000000000 +0000
10+++ bash-4.3/arrayfunc.c 2014-10-10 14:40:53.290659356 +0000
11@@ -179,6 +179,7 @@
12 array_insert (array_cell (entry), ind, newval);
13 FREE (newval);
14
15+ VUNSETATTR (entry, att_invisible); /* no longer invisible */
16 return (entry);
17 }
18
19@@ -597,6 +598,11 @@
20 if (assoc_p (var))
21 {
22 val = expand_assignment_string_to_string (val, 0);
23+ if (val == 0)
24+ {
25+ val = (char *)xmalloc (1);
26+ val[0] = '\0'; /* like do_assignment_internal */
27+ }
28 free_val = 1;
29 }
30
31diff -Naur bash-4.3.orig/bashline.c bash-4.3/bashline.c
32--- bash-4.3.orig/bashline.c 2014-02-10 00:56:58.000000000 +0000
33+++ bash-4.3/bashline.c 2014-10-10 14:40:53.270659407 +0000
34@@ -4167,9 +4167,16 @@
35 int qc;
36
37 qc = rl_dispatching ? rl_completion_quote_character : 0;
38- dfn = bash_dequote_filename ((char *)text, qc);
39+ /* If rl_completion_found_quote != 0, rl_completion_matches will call the
40+ filename dequoting function, causing the directory name to be dequoted
41+ twice. */
42+ if (rl_dispatching && rl_completion_found_quote == 0)
43+ dfn = bash_dequote_filename ((char *)text, qc);
44+ else
45+ dfn = (char *)text;
46 m1 = rl_completion_matches (dfn, rl_filename_completion_function);
47- free (dfn);
48+ if (dfn != text)
49+ free (dfn);
50
51 if (m1 == 0 || m1[0] == 0)
52 return m1;
53diff -Naur bash-4.3.orig/builtins/common.h bash-4.3/builtins/common.h
54--- bash-4.3.orig/builtins/common.h 2013-07-08 20:54:47.000000000 +0000
55+++ bash-4.3/builtins/common.h 2014-10-10 14:40:53.353992529 +0000
56@@ -33,6 +33,8 @@
57 #define SEVAL_RESETLINE 0x010
58 #define SEVAL_PARSEONLY 0x020
59 #define SEVAL_NOLONGJMP 0x040
60+#define SEVAL_FUNCDEF 0x080 /* only allow function definitions */
61+#define SEVAL_ONECMD 0x100 /* only allow a single command */
62
63 /* Flags for describe_command, shared between type.def and command.def */
64 #define CDESC_ALL 0x001 /* type -a */
65diff -Naur bash-4.3.orig/builtins/evalstring.c bash-4.3/builtins/evalstring.c
66--- bash-4.3.orig/builtins/evalstring.c 2014-02-11 14:42:10.000000000 +0000
67+++ bash-4.3/builtins/evalstring.c 2014-10-10 14:40:53.390659103 +0000
68@@ -308,6 +308,27 @@
69 {
70 struct fd_bitmap *bitmap;
71
72+ if (flags & SEVAL_FUNCDEF)
73+ {
74+ char *x;
75+
76+ /* If the command parses to something other than a straight
77+ function definition, or if we have not consumed the entire
78+ string, or if the parser has transformed the function
79+ name (as parsing will if it begins or ends with shell
80+ whitespace, for example), reject the attempt */
81+ if (command->type != cm_function_def ||
82+ ((x = parser_remaining_input ()) && *x) ||
83+ (STREQ (from_file, command->value.Function_def->name->word) == 0))
84+ {
85+ internal_warning (_("%s: ignoring function definition attempt"), from_file);
86+ should_jump_to_top_level = 0;
87+ last_result = last_command_exit_value = EX_BADUSAGE;
88+ reset_parser ();
89+ break;
90+ }
91+ }
92+
93 bitmap = new_fd_bitmap (FD_BITMAP_SIZE);
94 begin_unwind_frame ("pe_dispose");
95 add_unwind_protect (dispose_fd_bitmap, bitmap);
96@@ -368,6 +389,12 @@
97 dispose_command (command);
98 dispose_fd_bitmap (bitmap);
99 discard_unwind_frame ("pe_dispose");
100+
101+ if (flags & SEVAL_ONECMD)
102+ {
103+ reset_parser ();
104+ break;
105+ }
106 }
107 }
108 else
109diff -Naur bash-4.3.orig/builtins/read.def bash-4.3/builtins/read.def
110--- bash-4.3.orig/builtins/read.def 2013-09-02 15:54:00.000000000 +0000
111+++ bash-4.3/builtins/read.def 2014-10-10 14:40:53.307325981 +0000
112@@ -442,7 +442,10 @@
113 add_unwind_protect (reset_alarm, (char *)NULL);
114 #if defined (READLINE)
115 if (edit)
116- add_unwind_protect (reset_attempted_completion_function, (char *)NULL);
117+ {
118+ add_unwind_protect (reset_attempted_completion_function, (char *)NULL);
119+ add_unwind_protect (bashline_reset_event_hook, (char *)NULL);
120+ }
121 #endif
122 falarm (tmsec, tmusec);
123 }
124@@ -1021,6 +1024,7 @@
125
126 old_attempted_completion_function = rl_attempted_completion_function;
127 rl_attempted_completion_function = (rl_completion_func_t *)NULL;
128+ bashline_set_event_hook ();
129 if (itext)
130 {
131 old_startup_hook = rl_startup_hook;
132@@ -1032,6 +1036,7 @@
133
134 rl_attempted_completion_function = old_attempted_completion_function;
135 old_attempted_completion_function = (rl_completion_func_t *)NULL;
136+ bashline_reset_event_hook ();
137
138 if (ret == 0)
139 return ret;
140diff -Naur bash-4.3.orig/copy_cmd.c bash-4.3/copy_cmd.c
141--- bash-4.3.orig/copy_cmd.c 2009-09-11 20:28:02.000000000 +0000
142+++ bash-4.3/copy_cmd.c 2014-10-10 14:40:53.390659103 +0000
143@@ -126,7 +126,7 @@
144 {
145 case r_reading_until:
146 case r_deblank_reading_until:
147- new_redirect->here_doc_eof = savestring (redirect->here_doc_eof);
148+ new_redirect->here_doc_eof = redirect->here_doc_eof ? savestring (redirect->here_doc_eof) : 0;
149 /*FALLTHROUGH*/
150 case r_reading_string:
151 case r_appending_to:
152diff -Naur bash-4.3.orig/execute_cmd.c bash-4.3/execute_cmd.c
153--- bash-4.3.orig/execute_cmd.c 2014-01-31 15:54:52.000000000 +0000
154+++ bash-4.3/execute_cmd.c 2014-10-10 14:40:53.337325905 +0000
155@@ -2409,7 +2409,16 @@
156 #endif
157 lstdin = wait_for (lastpid);
158 #if defined (JOB_CONTROL)
159- exec_result = job_exit_status (lastpipe_jid);
160+ /* If wait_for removes the job from the jobs table, use result of last
161+ command as pipeline's exit status as usual. The jobs list can get
162+ frozen and unfrozen at inconvenient times if there are multiple pipelines
163+ running simultaneously. */
164+ if (INVALID_JOB (lastpipe_jid) == 0)
165+ exec_result = job_exit_status (lastpipe_jid);
166+ else if (pipefail_opt)
167+ exec_result = exec_result | lstdin; /* XXX */
168+ /* otherwise we use exec_result */
169+
170 #endif
171 unfreeze_jobs_list ();
172 }
173diff -Naur bash-4.3.orig/externs.h bash-4.3/externs.h
174--- bash-4.3.orig/externs.h 2014-01-02 19:58:20.000000000 +0000
175+++ bash-4.3/externs.h 2014-10-10 14:40:53.230659509 +0000
176@@ -324,6 +324,7 @@
177 extern char *sh_backslash_quote __P((char *, const char *, int));
178 extern char *sh_backslash_quote_for_double_quotes __P((char *));
179 extern int sh_contains_shell_metas __P((char *));
180+extern int sh_contains_quotes __P((char *));
181
182 /* declarations for functions defined in lib/sh/spell.c */
183 extern int spname __P((char *, char *));
184diff -Naur bash-4.3.orig/jobs.c bash-4.3/jobs.c
185--- bash-4.3.orig/jobs.c 2014-01-10 14:05:34.000000000 +0000
186+++ bash-4.3/jobs.c 2014-10-10 14:40:53.243992808 +0000
187@@ -3597,6 +3597,7 @@
188 unwind_protect_int (jobs_list_frozen);
189 unwind_protect_pointer (the_pipeline);
190 unwind_protect_pointer (subst_assign_varlist);
191+ unwind_protect_pointer (this_shell_builtin);
192
193 /* We have to add the commands this way because they will be run
194 in reverse order of adding. We don't want maybe_set_sigchld_trap ()
195@@ -4374,7 +4375,7 @@
196 void
197 end_job_control ()
198 {
199- if (interactive_shell) /* XXX - should it be interactive? */
200+ if (interactive_shell || job_control) /* XXX - should it be just job_control? */
201 {
202 terminate_stopped_jobs ();
203
204diff -Naur bash-4.3.orig/lib/glob/glob.c bash-4.3/lib/glob/glob.c
205--- bash-4.3.orig/lib/glob/glob.c 2014-02-01 02:43:51.000000000 +0000
206+++ bash-4.3/lib/glob/glob.c 2014-10-10 14:40:53.277326057 +0000
207@@ -123,6 +123,8 @@
208 extern char *glob_patscan __P((char *, char *, int));
209 extern wchar_t *glob_patscan_wc __P((wchar_t *, wchar_t *, int));
210
211+extern char *glob_dirscan __P((char *, int));
212+
213 /* Compile `glob_loop.c' for single-byte characters. */
214 #define CHAR unsigned char
215 #define INT int
216@@ -179,42 +181,53 @@
217 char *pat, *dname;
218 int flags;
219 {
220- char *pp, *pe, *t;
221- int n, r;
222+ char *pp, *pe, *t, *se;
223+ int n, r, negate;
224
225+ negate = *pat == '!';
226 pp = pat + 2;
227- pe = pp + strlen (pp) - 1; /*(*/
228- if (*pe != ')')
229+ se = pp + strlen (pp) - 1; /* end of string */
230+ pe = glob_patscan (pp, se, 0); /* end of extglob pattern (( */
231+ /* we should check for invalid extglob pattern here */
232+ if (pe == 0)
233 return 0;
234- if ((t = strchr (pp, '|')) == 0) /* easy case first */
235+
236+ /* if pe != se we have more of the pattern at the end of the extglob
237+ pattern. Check the easy case first ( */
238+ if (pe == se && *pe == ')' && (t = strchr (pp, '|')) == 0)
239 {
240 *pe = '\0';
241+#if defined (HANDLE_MULTIBYTE)
242+ r = mbskipname (pp, dname, flags);
243+#else
244 r = skipname (pp, dname, flags); /*(*/
245+#endif
246 *pe = ')';
247 return r;
248 }
249+
250+ /* check every subpattern */
251 while (t = glob_patscan (pp, pe, '|'))
252 {
253 n = t[-1];
254 t[-1] = '\0';
255+#if defined (HANDLE_MULTIBYTE)
256+ r = mbskipname (pp, dname, flags);
257+#else
258 r = skipname (pp, dname, flags);
259+#endif
260 t[-1] = n;
261 if (r == 0) /* if any pattern says not skip, we don't skip */
262 return r;
263 pp = t;
264 } /*(*/
265
266- if (pp == pe) /* glob_patscan might find end of pattern */
267+ /* glob_patscan might find end of pattern */
268+ if (pp == se)
269 return r;
270
271- *pe = '\0';
272-# if defined (HANDLE_MULTIBYTE)
273- r = mbskipname (pp, dname, flags); /*(*/
274-# else
275- r = skipname (pp, dname, flags); /*(*/
276-# endif
277- *pe = ')';
278- return r;
279+ /* but if it doesn't then we didn't match a leading dot */
280+ return 0;
281 }
282 #endif
283
284@@ -277,20 +290,23 @@
285 int flags;
286 {
287 #if EXTENDED_GLOB
288- wchar_t *pp, *pe, *t, n;
289- int r;
290+ wchar_t *pp, *pe, *t, n, *se;
291+ int r, negate;
292
293+ negate = *pat == L'!';
294 pp = pat + 2;
295- pe = pp + wcslen (pp) - 1; /*(*/
296- if (*pe != L')')
297- return 0;
298- if ((t = wcschr (pp, L'|')) == 0)
299+ se = pp + wcslen (pp) - 1; /*(*/
300+ pe = glob_patscan_wc (pp, se, 0);
301+
302+ if (pe == se && *pe == ')' && (t = wcschr (pp, L'|')) == 0)
303 {
304 *pe = L'\0';
305 r = wchkname (pp, dname); /*(*/
306 *pe = L')';
307 return r;
308 }
309+
310+ /* check every subpattern */
311 while (t = glob_patscan_wc (pp, pe, '|'))
312 {
313 n = t[-1];
314@@ -305,10 +321,8 @@
315 if (pp == pe) /* glob_patscan_wc might find end of pattern */
316 return r;
317
318- *pe = L'\0';
319- r = wchkname (pp, dname); /*(*/
320- *pe = L')';
321- return r;
322+ /* but if it doesn't then we didn't match a leading dot */
323+ return 0;
324 #else
325 return (wchkname (pat, dname));
326 #endif
327@@ -1006,7 +1020,7 @@
328 {
329 char **result;
330 unsigned int result_size;
331- char *directory_name, *filename, *dname;
332+ char *directory_name, *filename, *dname, *fn;
333 unsigned int directory_len;
334 int free_dirname; /* flag */
335 int dflags;
336@@ -1022,6 +1036,18 @@
337
338 /* Find the filename. */
339 filename = strrchr (pathname, '/');
340+#if defined (EXTENDED_GLOB)
341+ if (filename && extended_glob)
342+ {
343+ fn = glob_dirscan (pathname, '/');
344+#if DEBUG_MATCHING
345+ if (fn != filename)
346+ fprintf (stderr, "glob_filename: glob_dirscan: fn (%s) != filename (%s)\n", fn ? fn : "(null)", filename);
347+#endif
348+ filename = fn;
349+ }
350+#endif
351+
352 if (filename == NULL)
353 {
354 filename = pathname;
355diff -Naur bash-4.3.orig/lib/glob/gmisc.c bash-4.3/lib/glob/gmisc.c
356--- bash-4.3.orig/lib/glob/gmisc.c 2013-10-28 18:45:25.000000000 +0000
357+++ bash-4.3/lib/glob/gmisc.c 2014-10-10 14:40:53.277326057 +0000
358@@ -42,6 +42,8 @@
359 #define WLPAREN L'('
360 #define WRPAREN L')'
361
362+extern char *glob_patscan __P((char *, char *, int));
363+
364 /* Return 1 of the first character of WSTRING could match the first
365 character of pattern WPAT. Wide character version. */
366 int
367@@ -210,6 +212,7 @@
368 case '+':
369 case '!':
370 case '@':
371+ case '?':
372 return (pat[1] == LPAREN);
373 default:
374 return 0;
375@@ -374,3 +377,34 @@
376
377 return matlen;
378 }
379+
380+/* Skip characters in PAT and return the final occurrence of DIRSEP. This
381+ is only called when extended_glob is set, so we have to skip over extglob
382+ patterns x(...) */
383+char *
384+glob_dirscan (pat, dirsep)
385+ char *pat;
386+ int dirsep;
387+{
388+ char *p, *d, *pe, *se;
389+
390+ d = pe = se = 0;
391+ for (p = pat; p && *p; p++)
392+ {
393+ if (extglob_pattern_p (p))
394+ {
395+ if (se == 0)
396+ se = p + strlen (p) - 1;
397+ pe = glob_patscan (p + 2, se, 0);
398+ if (pe == 0)
399+ continue;
400+ else if (*pe == 0)
401+ break;
402+ p = pe - 1; /* will do increment above */
403+ continue;
404+ }
405+ if (*p == dirsep)
406+ d = p;
407+ }
408+ return d;
409+}
410diff -Naur bash-4.3.orig/lib/readline/display.c bash-4.3/lib/readline/display.c
411--- bash-4.3.orig/lib/readline/display.c 2013-12-27 18:10:56.000000000 +0000
412+++ bash-4.3/lib/readline/display.c 2014-10-10 14:40:53.253992783 +0000
413@@ -1637,7 +1637,7 @@
414 /* If we are changing the number of invisible characters in a line, and
415 the spot of first difference is before the end of the invisible chars,
416 lendiff needs to be adjusted. */
417- if (current_line == 0 && !_rl_horizontal_scroll_mode &&
418+ if (current_line == 0 && /* !_rl_horizontal_scroll_mode && */
419 current_invis_chars != visible_wrap_offset)
420 {
421 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
422@@ -1825,8 +1825,13 @@
423 else
424 _rl_last_c_pos += bytes_to_insert;
425
426+ /* XXX - we only want to do this if we are at the end of the line
427+ so we move there with _rl_move_cursor_relative */
428 if (_rl_horizontal_scroll_mode && ((oe-old) > (ne-new)))
429- goto clear_rest_of_line;
430+ {
431+ _rl_move_cursor_relative (ne-new, new);
432+ goto clear_rest_of_line;
433+ }
434 }
435 }
436 /* Otherwise, print over the existing material. */
437@@ -2677,7 +2682,8 @@
438 {
439 if (_rl_echoing_p)
440 {
441- _rl_move_vert (_rl_vis_botlin);
442+ if (_rl_vis_botlin > 0) /* minor optimization plus bug fix */
443+ _rl_move_vert (_rl_vis_botlin);
444 _rl_vis_botlin = 0;
445 fflush (rl_outstream);
446 rl_restart_output (1, 0);
447diff -Naur bash-4.3.orig/lib/readline/input.c bash-4.3/lib/readline/input.c
448--- bash-4.3.orig/lib/readline/input.c 2014-01-10 20:07:08.000000000 +0000
449+++ bash-4.3/lib/readline/input.c 2014-10-10 14:40:53.307325981 +0000
450@@ -534,8 +534,16 @@
451 return (RL_ISSTATE (RL_STATE_READCMD) ? READERR : EOF);
452 else if (_rl_caught_signal == SIGHUP || _rl_caught_signal == SIGTERM)
453 return (RL_ISSTATE (RL_STATE_READCMD) ? READERR : EOF);
454+ /* keyboard-generated signals of interest */
455 else if (_rl_caught_signal == SIGINT || _rl_caught_signal == SIGQUIT)
456 RL_CHECK_SIGNALS ();
457+ /* non-keyboard-generated signals of interest */
458+ else if (_rl_caught_signal == SIGALRM
459+#if defined (SIGVTALRM)
460+ || _rl_caught_signal == SIGVTALRM
461+#endif
462+ )
463+ RL_CHECK_SIGNALS ();
464
465 if (rl_signal_event_hook)
466 (*rl_signal_event_hook) ();
467diff -Naur bash-4.3.orig/lib/readline/misc.c bash-4.3/lib/readline/misc.c
468--- bash-4.3.orig/lib/readline/misc.c 2012-09-01 22:03:11.000000000 +0000
469+++ bash-4.3/lib/readline/misc.c 2014-10-10 14:40:53.330659255 +0000
470@@ -461,6 +461,7 @@
471 saved_undo_list = 0;
472 /* Set up rl_line_buffer and other variables from history entry */
473 rl_replace_from_history (entry, 0); /* entry->line is now current */
474+ entry->data = 0; /* entry->data is now current undo list */
475 /* Undo all changes to this history entry */
476 while (rl_undo_list)
477 rl_do_undo ();
478@@ -468,7 +469,6 @@
479 the timestamp. */
480 FREE (entry->line);
481 entry->line = savestring (rl_line_buffer);
482- entry->data = 0;
483 }
484 entry = previous_history ();
485 }
486diff -Naur bash-4.3.orig/lib/readline/readline.c bash-4.3/lib/readline/readline.c
487--- bash-4.3.orig/lib/readline/readline.c 2013-10-28 18:58:06.000000000 +0000
488+++ bash-4.3/lib/readline/readline.c 2014-10-10 14:40:53.177326310 +0000
489@@ -744,7 +744,8 @@
490 r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ));
491
492 RL_CHECK_SIGNALS ();
493- if (r == 0) /* success! */
494+ /* We only treat values < 0 specially to simulate recursion. */
495+ if (r >= 0 || (r == -1 && (cxt->flags & KSEQ_SUBSEQ) == 0)) /* success! or failure! */
496 {
497 _rl_keyseq_chain_dispose ();
498 RL_UNSETSTATE (RL_STATE_MULTIKEY);
499@@ -964,7 +965,7 @@
500 #if defined (VI_MODE)
501 if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap &&
502 key != ANYOTHERKEY &&
503- rl_key_sequence_length == 1 && /* XXX */
504+ _rl_dispatching_keymap == vi_movement_keymap &&
505 _rl_vi_textmod_command (key))
506 _rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign);
507 #endif
508diff -Naur bash-4.3.orig/lib/readline/readline.c.orig bash-4.3/lib/readline/readline.c.orig
509--- bash-4.3.orig/lib/readline/readline.c.orig 1970-01-01 00:00:00.000000000 +0000
510+++ bash-4.3/lib/readline/readline.c.orig 2014-10-10 14:40:53.170659661 +0000
511@@ -0,0 +1,1364 @@
512+/* readline.c -- a general facility for reading lines of input
513+ with emacs style editing and completion. */
514+
515+/* Copyright (C) 1987-2013 Free Software Foundation, Inc.
516+
517+ This file is part of the GNU Readline Library (Readline), a library
518+ for reading lines of text with interactive input and history editing.
519+
520+ Readline is free software: you can redistribute it and/or modify
521+ it under the terms of the GNU General Public License as published by
522+ the Free Software Foundation, either version 3 of the License, or
523+ (at your option) any later version.
524+
525+ Readline is distributed in the hope that it will be useful,
526+ but WITHOUT ANY WARRANTY; without even the implied warranty of
527+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
528+ GNU General Public License for more details.
529+
530+ You should have received a copy of the GNU General Public License
531+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
532+*/
533+
534+#define READLINE_LIBRARY
535+
536+#if defined (HAVE_CONFIG_H)
537+# include <config.h>
538+#endif
539+
540+#include <sys/types.h>
541+#include "posixstat.h"
542+#include <fcntl.h>
543+#if defined (HAVE_SYS_FILE_H)
544+# include <sys/file.h>
545+#endif /* HAVE_SYS_FILE_H */
546+
547+#if defined (HAVE_UNISTD_H)
548+# include <unistd.h>
549+#endif /* HAVE_UNISTD_H */
550+
551+#if defined (HAVE_STDLIB_H)
552+# include <stdlib.h>
553+#else
554+# include "ansi_stdlib.h"
555+#endif /* HAVE_STDLIB_H */
556+
557+#if defined (HAVE_LOCALE_H)
558+# include <locale.h>
559+#endif
560+
561+#include <stdio.h>
562+#include "posixjmp.h"
563+#include <errno.h>
564+
565+#if !defined (errno)
566+extern int errno;
567+#endif /* !errno */
568+
569+/* System-specific feature definitions and include files. */
570+#include "rldefs.h"
571+#include "rlmbutil.h"
572+
573+#if defined (__EMX__)
574+# define INCL_DOSPROCESS
575+# include <os2.h>
576+#endif /* __EMX__ */
577+
578+/* Some standard library routines. */
579+#include "readline.h"
580+#include "history.h"
581+
582+#include "rlprivate.h"
583+#include "rlshell.h"
584+#include "xmalloc.h"
585+
586+#ifndef RL_LIBRARY_VERSION
587+# define RL_LIBRARY_VERSION "5.1"
588+#endif
589+
590+#ifndef RL_READLINE_VERSION
591+# define RL_READLINE_VERSION 0x0501
592+#endif
593+
594+extern void _rl_free_history_entry PARAMS((HIST_ENTRY *));
595+
596+#if defined (COLOR_SUPPORT)
597+extern void _rl_parse_colors PARAMS((void)); /* XXX */
598+#endif
599+
600+
601+/* Forward declarations used in this file. */
602+static char *readline_internal PARAMS((void));
603+static void readline_initialize_everything PARAMS((void));
604+
605+static void bind_arrow_keys_internal PARAMS((Keymap));
606+static void bind_arrow_keys PARAMS((void));
607+
608+static void readline_default_bindings PARAMS((void));
609+static void reset_default_bindings PARAMS((void));
610+
611+static int _rl_subseq_result PARAMS((int, Keymap, int, int));
612+static int _rl_subseq_getchar PARAMS((int));
613+
614+/* **************************************************************** */
615+/* */
616+/* Line editing input utility */
617+/* */
618+/* **************************************************************** */
619+
620+const char *rl_library_version = RL_LIBRARY_VERSION;
621+
622+int rl_readline_version = RL_READLINE_VERSION;
623+
624+/* True if this is `real' readline as opposed to some stub substitute. */
625+int rl_gnu_readline_p = 1;
626+
627+/* A pointer to the keymap that is currently in use.
628+ By default, it is the standard emacs keymap. */
629+Keymap _rl_keymap = emacs_standard_keymap;
630+
631+/* The current style of editing. */
632+int rl_editing_mode = emacs_mode;
633+
634+/* The current insert mode: input (the default) or overwrite */
635+int rl_insert_mode = RL_IM_DEFAULT;
636+
637+/* Non-zero if we called this function from _rl_dispatch(). It's present
638+ so functions can find out whether they were called from a key binding
639+ or directly from an application. */
640+int rl_dispatching;
641+
642+/* Non-zero if the previous command was a kill command. */
643+int _rl_last_command_was_kill = 0;
644+
645+/* The current value of the numeric argument specified by the user. */
646+int rl_numeric_arg = 1;
647+
648+/* Non-zero if an argument was typed. */
649+int rl_explicit_arg = 0;
650+
651+/* Temporary value used while generating the argument. */
652+int rl_arg_sign = 1;
653+
654+/* Non-zero means we have been called at least once before. */
655+static int rl_initialized;
656+
657+#if 0
658+/* If non-zero, this program is running in an EMACS buffer. */
659+static int running_in_emacs;
660+#endif
661+
662+/* Flags word encapsulating the current readline state. */
663+int rl_readline_state = RL_STATE_NONE;
664+
665+/* The current offset in the current input line. */
666+int rl_point;
667+
668+/* Mark in the current input line. */
669+int rl_mark;
670+
671+/* Length of the current input line. */
672+int rl_end;
673+
674+/* Make this non-zero to return the current input_line. */
675+int rl_done;
676+
677+/* The last function executed by readline. */
678+rl_command_func_t *rl_last_func = (rl_command_func_t *)NULL;
679+
680+/* Top level environment for readline_internal (). */
681+procenv_t _rl_top_level;
682+
683+/* The streams we interact with. */
684+FILE *_rl_in_stream, *_rl_out_stream;
685+
686+/* The names of the streams that we do input and output to. */
687+FILE *rl_instream = (FILE *)NULL;
688+FILE *rl_outstream = (FILE *)NULL;
689+
690+/* Non-zero means echo characters as they are read. Defaults to no echo;
691+ set to 1 if there is a controlling terminal, we can get its attributes,
692+ and the attributes include `echo'. Look at rltty.c:prepare_terminal_settings
693+ for the code that sets it. */
694+int _rl_echoing_p = 0;
695+
696+/* Current prompt. */
697+char *rl_prompt = (char *)NULL;
698+int rl_visible_prompt_length = 0;
699+
700+/* Set to non-zero by calling application if it has already printed rl_prompt
701+ and does not want readline to do it the first time. */
702+int rl_already_prompted = 0;
703+
704+/* The number of characters read in order to type this complete command. */
705+int rl_key_sequence_length = 0;
706+
707+/* If non-zero, then this is the address of a function to call just
708+ before readline_internal_setup () prints the first prompt. */
709+rl_hook_func_t *rl_startup_hook = (rl_hook_func_t *)NULL;
710+
711+/* If non-zero, this is the address of a function to call just before
712+ readline_internal_setup () returns and readline_internal starts
713+ reading input characters. */
714+rl_hook_func_t *rl_pre_input_hook = (rl_hook_func_t *)NULL;
715+
716+/* What we use internally. You should always refer to RL_LINE_BUFFER. */
717+static char *the_line;
718+
719+/* The character that can generate an EOF. Really read from
720+ the terminal driver... just defaulted here. */
721+int _rl_eof_char = CTRL ('D');
722+
723+/* Non-zero makes this the next keystroke to read. */
724+int rl_pending_input = 0;
725+
726+/* Pointer to a useful terminal name. */
727+const char *rl_terminal_name = (const char *)NULL;
728+
729+/* Non-zero means to always use horizontal scrolling in line display. */
730+int _rl_horizontal_scroll_mode = 0;
731+
732+/* Non-zero means to display an asterisk at the starts of history lines
733+ which have been modified. */
734+int _rl_mark_modified_lines = 0;
735+
736+/* The style of `bell' notification preferred. This can be set to NO_BELL,
737+ AUDIBLE_BELL, or VISIBLE_BELL. */
738+int _rl_bell_preference = AUDIBLE_BELL;
739+
740+/* String inserted into the line by rl_insert_comment (). */
741+char *_rl_comment_begin;
742+
743+/* Keymap holding the function currently being executed. */
744+Keymap rl_executing_keymap;
745+
746+/* Keymap we're currently using to dispatch. */
747+Keymap _rl_dispatching_keymap;
748+
749+/* Non-zero means to erase entire line, including prompt, on empty input lines. */
750+int rl_erase_empty_line = 0;
751+
752+/* Non-zero means to read only this many characters rather than up to a
753+ character bound to accept-line. */
754+int rl_num_chars_to_read;
755+
756+/* Line buffer and maintenance. */
757+char *rl_line_buffer = (char *)NULL;
758+int rl_line_buffer_len = 0;
759+
760+/* Key sequence `contexts' */
761+_rl_keyseq_cxt *_rl_kscxt = 0;
762+
763+int rl_executing_key;
764+char *rl_executing_keyseq = 0;
765+int _rl_executing_keyseq_size = 0;
766+
767+/* Timeout (specified in milliseconds) when reading characters making up an
768+ ambiguous multiple-key sequence */
769+int _rl_keyseq_timeout = 500;
770+
771+#define RESIZE_KEYSEQ_BUFFER() \
772+ do \
773+ { \
774+ if (rl_key_sequence_length + 2 >= _rl_executing_keyseq_size) \
775+ { \
776+ _rl_executing_keyseq_size += 16; \
777+ rl_executing_keyseq = xrealloc (rl_executing_keyseq, _rl_executing_keyseq_size); \
778+ } \
779+ } \
780+ while (0);
781+
782+/* Forward declarations used by the display, termcap, and history code. */
783+
784+/* **************************************************************** */
785+/* */
786+/* `Forward' declarations */
787+/* */
788+/* **************************************************************** */
789+
790+/* Non-zero means do not parse any lines other than comments and
791+ parser directives. */
792+unsigned char _rl_parsing_conditionalized_out = 0;
793+
794+/* Non-zero means to convert characters with the meta bit set to
795+ escape-prefixed characters so we can indirect through
796+ emacs_meta_keymap or vi_escape_keymap. */
797+int _rl_convert_meta_chars_to_ascii = 1;
798+
799+/* Non-zero means to output characters with the meta bit set directly
800+ rather than as a meta-prefixed escape sequence. */
801+int _rl_output_meta_chars = 0;
802+
803+/* Non-zero means to look at the termios special characters and bind
804+ them to equivalent readline functions at startup. */
805+int _rl_bind_stty_chars = 1;
806+
807+/* Non-zero means to go through the history list at every newline (or
808+ whenever rl_done is set and readline returns) and revert each line to
809+ its initial state. */
810+int _rl_revert_all_at_newline = 0;
811+
812+/* Non-zero means to honor the termios ECHOCTL bit and echo control
813+ characters corresponding to keyboard-generated signals. */
814+int _rl_echo_control_chars = 1;
815+
816+/* Non-zero means to prefix the displayed prompt with a character indicating
817+ the editing mode: @ for emacs, : for vi-command, + for vi-insert. */
818+int _rl_show_mode_in_prompt = 0;
819+
820+/* **************************************************************** */
821+/* */
822+/* Top Level Functions */
823+/* */
824+/* **************************************************************** */
825+
826+/* Non-zero means treat 0200 bit in terminal input as Meta bit. */
827+int _rl_meta_flag = 0; /* Forward declaration */
828+
829+/* Set up the prompt and expand it. Called from readline() and
830+ rl_callback_handler_install (). */
831+int
832+rl_set_prompt (prompt)
833+ const char *prompt;
834+{
835+ FREE (rl_prompt);
836+ rl_prompt = prompt ? savestring (prompt) : (char *)NULL;
837+ rl_display_prompt = rl_prompt ? rl_prompt : "";
838+
839+ rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
840+ return 0;
841+}
842+
843+/* Read a line of input. Prompt with PROMPT. An empty PROMPT means
844+ none. A return value of NULL means that EOF was encountered. */
845+char *
846+readline (prompt)
847+ const char *prompt;
848+{
849+ char *value;
850+#if 0
851+ int in_callback;
852+#endif
853+
854+ /* If we are at EOF return a NULL string. */
855+ if (rl_pending_input == EOF)
856+ {
857+ rl_clear_pending_input ();
858+ return ((char *)NULL);
859+ }
860+
861+#if 0
862+ /* If readline() is called after installing a callback handler, temporarily
863+ turn off the callback state to avoid ensuing messiness. Patch supplied
864+ by the gdb folks. XXX -- disabled. This can be fooled and readline
865+ left in a strange state by a poorly-timed longjmp. */
866+ if (in_callback = RL_ISSTATE (RL_STATE_CALLBACK))
867+ RL_UNSETSTATE (RL_STATE_CALLBACK);
868+#endif
869+
870+ rl_set_prompt (prompt);
871+
872+ rl_initialize ();
873+ if (rl_prep_term_function)
874+ (*rl_prep_term_function) (_rl_meta_flag);
875+
876+#if defined (HANDLE_SIGNALS)
877+ rl_set_signals ();
878+#endif
879+
880+ value = readline_internal ();
881+ if (rl_deprep_term_function)
882+ (*rl_deprep_term_function) ();
883+
884+#if defined (HANDLE_SIGNALS)
885+ rl_clear_signals ();
886+#endif
887+
888+#if 0
889+ if (in_callback)
890+ RL_SETSTATE (RL_STATE_CALLBACK);
891+#endif
892+
893+#if HAVE_DECL_AUDIT_TTY && defined (ENABLE_TTY_AUDIT_SUPPORT)
894+ if (value)
895+ _rl_audit_tty (value);
896+#endif
897+
898+ return (value);
899+}
900+
901+#if defined (READLINE_CALLBACKS)
902+# define STATIC_CALLBACK
903+#else
904+# define STATIC_CALLBACK static
905+#endif
906+
907+STATIC_CALLBACK void
908+readline_internal_setup ()
909+{
910+ char *nprompt;
911+
912+ _rl_in_stream = rl_instream;
913+ _rl_out_stream = rl_outstream;
914+
915+ /* Enable the meta key only for the duration of readline(), if this
916+ terminal has one and the terminal has been initialized */
917+ if (_rl_enable_meta & RL_ISSTATE (RL_STATE_TERMPREPPED))
918+ _rl_enable_meta_key ();
919+
920+ if (rl_startup_hook)
921+ (*rl_startup_hook) ();
922+
923+#if defined (VI_MODE)
924+ if (rl_editing_mode == vi_mode)
925+ rl_vi_insertion_mode (1, 'i'); /* don't want to reset last */
926+#endif /* VI_MODE */
927+
928+ /* If we're not echoing, we still want to at least print a prompt, because
929+ rl_redisplay will not do it for us. If the calling application has a
930+ custom redisplay function, though, let that function handle it. */
931+ if (_rl_echoing_p == 0 && rl_redisplay_function == rl_redisplay)
932+ {
933+ if (rl_prompt && rl_already_prompted == 0)
934+ {
935+ nprompt = _rl_strip_prompt (rl_prompt);
936+ fprintf (_rl_out_stream, "%s", nprompt);
937+ fflush (_rl_out_stream);
938+ xfree (nprompt);
939+ }
940+ }
941+ else
942+ {
943+ if (rl_prompt && rl_already_prompted)
944+ rl_on_new_line_with_prompt ();
945+ else
946+ rl_on_new_line ();
947+ (*rl_redisplay_function) ();
948+ }
949+
950+ if (rl_pre_input_hook)
951+ (*rl_pre_input_hook) ();
952+
953+ RL_CHECK_SIGNALS ();
954+}
955+
956+STATIC_CALLBACK char *
957+readline_internal_teardown (eof)
958+ int eof;
959+{
960+ char *temp;
961+ HIST_ENTRY *entry;
962+
963+ RL_CHECK_SIGNALS ();
964+
965+ /* Restore the original of this history line, iff the line that we
966+ are editing was originally in the history, AND the line has changed. */
967+ entry = current_history ();
968+
969+ if (entry && rl_undo_list)
970+ {
971+ temp = savestring (the_line);
972+ rl_revert_line (1, 0);
973+ entry = replace_history_entry (where_history (), the_line, (histdata_t)NULL);
974+ _rl_free_history_entry (entry);
975+
976+ strcpy (the_line, temp);
977+ xfree (temp);
978+ }
979+
980+ if (_rl_revert_all_at_newline)
981+ _rl_revert_all_lines ();
982+
983+ /* At any rate, it is highly likely that this line has an undo list. Get
984+ rid of it now. */
985+ if (rl_undo_list)
986+ rl_free_undo_list ();
987+
988+ /* Disable the meta key, if this terminal has one and we were told to use it.
989+ The check whether or not we sent the enable string is in
990+ _rl_disable_meta_key(); the flag is set in _rl_enable_meta_key */
991+ _rl_disable_meta_key ();
992+
993+ /* Restore normal cursor, if available. */
994+ _rl_set_insert_mode (RL_IM_INSERT, 0);
995+
996+ return (eof ? (char *)NULL : savestring (the_line));
997+}
998+
999+void
1000+_rl_internal_char_cleanup ()
1001+{
1002+#if defined (VI_MODE)
1003+ /* In vi mode, when you exit insert mode, the cursor moves back
1004+ over the previous character. We explicitly check for that here. */
1005+ if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap)
1006+ rl_vi_check ();
1007+#endif /* VI_MODE */
1008+
1009+ if (rl_num_chars_to_read && rl_end >= rl_num_chars_to_read)
1010+ {
1011+ (*rl_redisplay_function) ();
1012+ _rl_want_redisplay = 0;
1013+ rl_newline (1, '\n');
1014+ }
1015+
1016+ if (rl_done == 0)
1017+ {
1018+ (*rl_redisplay_function) ();
1019+ _rl_want_redisplay = 0;
1020+ }
1021+
1022+ /* If the application writer has told us to erase the entire line if
1023+ the only character typed was something bound to rl_newline, do so. */
1024+ if (rl_erase_empty_line && rl_done && rl_last_func == rl_newline &&
1025+ rl_point == 0 && rl_end == 0)
1026+ _rl_erase_entire_line ();
1027+}
1028+
1029+STATIC_CALLBACK int
1030+#if defined (READLINE_CALLBACKS)
1031+readline_internal_char ()
1032+#else
1033+readline_internal_charloop ()
1034+#endif
1035+{
1036+ static int lastc, eof_found;
1037+ int c, code, lk;
1038+
1039+ lastc = -1;
1040+ eof_found = 0;
1041+
1042+#if !defined (READLINE_CALLBACKS)
1043+ while (rl_done == 0)
1044+ {
1045+#endif
1046+ lk = _rl_last_command_was_kill;
1047+
1048+#if defined (HAVE_POSIX_SIGSETJMP)
1049+ code = sigsetjmp (_rl_top_level, 0);
1050+#else
1051+ code = setjmp (_rl_top_level);
1052+#endif
1053+
1054+ if (code)
1055+ {
1056+ (*rl_redisplay_function) ();
1057+ _rl_want_redisplay = 0;
1058+ /* If we get here, we're not being called from something dispatched
1059+ from _rl_callback_read_char(), which sets up its own value of
1060+ _rl_top_level (saving and restoring the old, of course), so
1061+ we can just return here. */
1062+ if (RL_ISSTATE (RL_STATE_CALLBACK))
1063+ return (0);
1064+ }
1065+
1066+ if (rl_pending_input == 0)
1067+ {
1068+ /* Then initialize the argument and number of keys read. */
1069+ _rl_reset_argument ();
1070+ rl_key_sequence_length = 0;
1071+ rl_executing_keyseq[0] = 0;
1072+ }
1073+
1074+ RL_SETSTATE(RL_STATE_READCMD);
1075+ c = rl_read_key ();
1076+ RL_UNSETSTATE(RL_STATE_READCMD);
1077+
1078+ /* look at input.c:rl_getc() for the circumstances under which this will
1079+ be returned; punt immediately on read error without converting it to
1080+ a newline; assume that rl_read_key has already called the signal
1081+ handler. */
1082+ if (c == READERR)
1083+ {
1084+#if defined (READLINE_CALLBACKS)
1085+ RL_SETSTATE(RL_STATE_DONE);
1086+ return (rl_done = 1);
1087+#else
1088+ eof_found = 1;
1089+ break;
1090+#endif
1091+ }
1092+
1093+ /* EOF typed to a non-blank line is a <NL>. If we want to change this,
1094+ to force any existing line to be ignored when read(2) reads EOF,
1095+ for example, this is the place to change. */
1096+ if (c == EOF && rl_end)
1097+ c = NEWLINE;
1098+
1099+ /* The character _rl_eof_char typed to blank line, and not as the
1100+ previous character is interpreted as EOF. */
1101+ if (((c == _rl_eof_char && lastc != c) || c == EOF) && !rl_end)
1102+ {
1103+#if defined (READLINE_CALLBACKS)
1104+ RL_SETSTATE(RL_STATE_DONE);
1105+ return (rl_done = 1);
1106+#else
1107+ eof_found = 1;
1108+ break;
1109+#endif
1110+ }
1111+
1112+ lastc = c;
1113+ _rl_dispatch ((unsigned char)c, _rl_keymap);
1114+ RL_CHECK_SIGNALS ();
1115+
1116+ /* If there was no change in _rl_last_command_was_kill, then no kill
1117+ has taken place. Note that if input is pending we are reading
1118+ a prefix command, so nothing has changed yet. */
1119+ if (rl_pending_input == 0 && lk == _rl_last_command_was_kill)
1120+ _rl_last_command_was_kill = 0;
1121+
1122+ _rl_internal_char_cleanup ();
1123+
1124+#if defined (READLINE_CALLBACKS)
1125+ return 0;
1126+#else
1127+ }
1128+
1129+ return (eof_found);
1130+#endif
1131+}
1132+
1133+#if defined (READLINE_CALLBACKS)
1134+static int
1135+readline_internal_charloop ()
1136+{
1137+ int eof = 1;
1138+
1139+ while (rl_done == 0)
1140+ eof = readline_internal_char ();
1141+ return (eof);
1142+}
1143+#endif /* READLINE_CALLBACKS */
1144+
1145+/* Read a line of input from the global rl_instream, doing output on
1146+ the global rl_outstream.
1147+ If rl_prompt is non-null, then that is our prompt. */
1148+static char *
1149+readline_internal ()
1150+{
1151+ int eof;
1152+
1153+ readline_internal_setup ();
1154+ eof = readline_internal_charloop ();
1155+ return (readline_internal_teardown (eof));
1156+}
1157+
1158+void
1159+_rl_init_line_state ()
1160+{
1161+ rl_point = rl_end = rl_mark = 0;
1162+ the_line = rl_line_buffer;
1163+ the_line[0] = 0;
1164+}
1165+
1166+void
1167+_rl_set_the_line ()
1168+{
1169+ the_line = rl_line_buffer;
1170+}
1171+
1172+#if defined (READLINE_CALLBACKS)
1173+_rl_keyseq_cxt *
1174+_rl_keyseq_cxt_alloc ()
1175+{
1176+ _rl_keyseq_cxt *cxt;
1177+
1178+ cxt = (_rl_keyseq_cxt *)xmalloc (sizeof (_rl_keyseq_cxt));
1179+
1180+ cxt->flags = cxt->subseq_arg = cxt->subseq_retval = 0;
1181+
1182+ cxt->okey = 0;
1183+ cxt->ocxt = _rl_kscxt;
1184+ cxt->childval = 42; /* sentinel value */
1185+
1186+ return cxt;
1187+}
1188+
1189+void
1190+_rl_keyseq_cxt_dispose (cxt)
1191+ _rl_keyseq_cxt *cxt;
1192+{
1193+ xfree (cxt);
1194+}
1195+
1196+void
1197+_rl_keyseq_chain_dispose ()
1198+{
1199+ _rl_keyseq_cxt *cxt;
1200+
1201+ while (_rl_kscxt)
1202+ {
1203+ cxt = _rl_kscxt;
1204+ _rl_kscxt = _rl_kscxt->ocxt;
1205+ _rl_keyseq_cxt_dispose (cxt);
1206+ }
1207+}
1208+#endif
1209+
1210+static int
1211+_rl_subseq_getchar (key)
1212+ int key;
1213+{
1214+ int k;
1215+
1216+ if (key == ESC)
1217+ RL_SETSTATE(RL_STATE_METANEXT);
1218+ RL_SETSTATE(RL_STATE_MOREINPUT);
1219+ k = rl_read_key ();
1220+ RL_UNSETSTATE(RL_STATE_MOREINPUT);
1221+ if (key == ESC)
1222+ RL_UNSETSTATE(RL_STATE_METANEXT);
1223+
1224+ return k;
1225+}
1226+
1227+#if defined (READLINE_CALLBACKS)
1228+int
1229+_rl_dispatch_callback (cxt)
1230+ _rl_keyseq_cxt *cxt;
1231+{
1232+ int nkey, r;
1233+
1234+ /* For now */
1235+ /* The first time this context is used, we want to read input and dispatch
1236+ on it. When traversing the chain of contexts back `up', we want to use
1237+ the value from the next context down. We're simulating recursion using
1238+ a chain of contexts. */
1239+ if ((cxt->flags & KSEQ_DISPATCHED) == 0)
1240+ {
1241+ nkey = _rl_subseq_getchar (cxt->okey);
1242+ if (nkey < 0)
1243+ {
1244+ _rl_abort_internal ();
1245+ return -1;
1246+ }
1247+ r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
1248+ cxt->flags |= KSEQ_DISPATCHED;
1249+ }
1250+ else
1251+ r = cxt->childval;
1252+
1253+ /* For now */
1254+ if (r != -3) /* don't do this if we indicate there will be other matches */
1255+ r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ));
1256+
1257+ RL_CHECK_SIGNALS ();
1258+ /* We only treat values < 0 specially to simulate recursion. */
1259+ if (r >= 0 || (r == -1 && (cxt->flags & KSEQ_SUBSEQ) == 0)) /* success! or failure! */
1260+ {
1261+ _rl_keyseq_chain_dispose ();
1262+ RL_UNSETSTATE (RL_STATE_MULTIKEY);
1263+ return r;
1264+ }
1265+
1266+ if (r != -3) /* magic value that says we added to the chain */
1267+ _rl_kscxt = cxt->ocxt;
1268+ if (_rl_kscxt)
1269+ _rl_kscxt->childval = r;
1270+ if (r != -3)
1271+ _rl_keyseq_cxt_dispose (cxt);
1272+
1273+ return r;
1274+}
1275+#endif /* READLINE_CALLBACKS */
1276+
1277+/* Do the command associated with KEY in MAP.
1278+ If the associated command is really a keymap, then read
1279+ another key, and dispatch into that map. */
1280+int
1281+_rl_dispatch (key, map)
1282+ register int key;
1283+ Keymap map;
1284+{
1285+ _rl_dispatching_keymap = map;
1286+ return _rl_dispatch_subseq (key, map, 0);
1287+}
1288+
1289+int
1290+_rl_dispatch_subseq (key, map, got_subseq)
1291+ register int key;
1292+ Keymap map;
1293+ int got_subseq;
1294+{
1295+ int r, newkey;
1296+ char *macro;
1297+ rl_command_func_t *func;
1298+#if defined (READLINE_CALLBACKS)
1299+ _rl_keyseq_cxt *cxt;
1300+#endif
1301+
1302+ if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii)
1303+ {
1304+ if (map[ESC].type == ISKMAP)
1305+ {
1306+ if (RL_ISSTATE (RL_STATE_MACRODEF))
1307+ _rl_add_macro_char (ESC);
1308+ RESIZE_KEYSEQ_BUFFER ();
1309+ rl_executing_keyseq[rl_key_sequence_length++] = ESC;
1310+ map = FUNCTION_TO_KEYMAP (map, ESC);
1311+ key = UNMETA (key);
1312+ return (_rl_dispatch (key, map));
1313+ }
1314+ else
1315+ rl_ding ();
1316+ return 0;
1317+ }
1318+
1319+ if (RL_ISSTATE (RL_STATE_MACRODEF))
1320+ _rl_add_macro_char (key);
1321+
1322+ r = 0;
1323+ switch (map[key].type)
1324+ {
1325+ case ISFUNC:
1326+ func = map[key].function;
1327+ if (func)
1328+ {
1329+ /* Special case rl_do_lowercase_version (). */
1330+ if (func == rl_do_lowercase_version)
1331+ /* Should we do anything special if key == ANYOTHERKEY? */
1332+ return (_rl_dispatch (_rl_to_lower (key), map));
1333+
1334+ rl_executing_keymap = map;
1335+ rl_executing_key = key;
1336+
1337+ RESIZE_KEYSEQ_BUFFER();
1338+ rl_executing_keyseq[rl_key_sequence_length++] = key;
1339+ rl_executing_keyseq[rl_key_sequence_length] = '\0';
1340+
1341+ rl_dispatching = 1;
1342+ RL_SETSTATE(RL_STATE_DISPATCHING);
1343+ r = (*func) (rl_numeric_arg * rl_arg_sign, key);
1344+ RL_UNSETSTATE(RL_STATE_DISPATCHING);
1345+ rl_dispatching = 0;
1346+
1347+ /* If we have input pending, then the last command was a prefix
1348+ command. Don't change the state of rl_last_func. Otherwise,
1349+ remember the last command executed in this variable. */
1350+ if (rl_pending_input == 0 && map[key].function != rl_digit_argument)
1351+ rl_last_func = map[key].function;
1352+
1353+ RL_CHECK_SIGNALS ();
1354+ }
1355+ else if (map[ANYOTHERKEY].function)
1356+ {
1357+ /* OK, there's no function bound in this map, but there is a
1358+ shadow function that was overridden when the current keymap
1359+ was created. Return -2 to note that. */
1360+ if (RL_ISSTATE (RL_STATE_MACROINPUT))
1361+ _rl_prev_macro_key ();
1362+ else
1363+ _rl_unget_char (key);
1364+ return -2;
1365+ }
1366+ else if (got_subseq)
1367+ {
1368+ /* Return -1 to note that we're in a subsequence, but we don't
1369+ have a matching key, nor was one overridden. This means
1370+ we need to back up the recursion chain and find the last
1371+ subsequence that is bound to a function. */
1372+ if (RL_ISSTATE (RL_STATE_MACROINPUT))
1373+ _rl_prev_macro_key ();
1374+ else
1375+ _rl_unget_char (key);
1376+ return -1;
1377+ }
1378+ else
1379+ {
1380+#if defined (READLINE_CALLBACKS)
1381+ RL_UNSETSTATE (RL_STATE_MULTIKEY);
1382+ _rl_keyseq_chain_dispose ();
1383+#endif
1384+ _rl_abort_internal ();
1385+ return -1;
1386+ }
1387+ break;
1388+
1389+ case ISKMAP:
1390+ if (map[key].function != 0)
1391+ {
1392+#if defined (VI_MODE)
1393+ /* The only way this test will be true is if a subsequence has been
1394+ bound starting with ESC, generally the arrow keys. What we do is
1395+ check whether there's input in the queue, which there generally
1396+ will be if an arrow key has been pressed, and, if there's not,
1397+ just dispatch to (what we assume is) rl_vi_movement_mode right
1398+ away. This is essentially an input test with a zero timeout (by
1399+ default) or a timeout determined by the value of `keyseq-timeout' */
1400+ /* _rl_keyseq_timeout specified in milliseconds; _rl_input_queued
1401+ takes microseconds, so multiply by 1000 */
1402+ if (rl_editing_mode == vi_mode && key == ESC && map == vi_insertion_keymap
1403+ && _rl_input_queued ((_rl_keyseq_timeout > 0) ? _rl_keyseq_timeout*1000 : 0) == 0)
1404+ return (_rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key)));
1405+#endif
1406+
1407+ RESIZE_KEYSEQ_BUFFER ();
1408+ rl_executing_keyseq[rl_key_sequence_length++] = key;
1409+ _rl_dispatching_keymap = FUNCTION_TO_KEYMAP (map, key);
1410+
1411+ /* Allocate new context here. Use linked contexts (linked through
1412+ cxt->ocxt) to simulate recursion */
1413+#if defined (READLINE_CALLBACKS)
1414+ if (RL_ISSTATE (RL_STATE_CALLBACK))
1415+ {
1416+ /* Return 0 only the first time, to indicate success to
1417+ _rl_callback_read_char. The rest of the time, we're called
1418+ from _rl_dispatch_callback, so we return -3 to indicate
1419+ special handling is necessary. */
1420+ r = RL_ISSTATE (RL_STATE_MULTIKEY) ? -3 : 0;
1421+ cxt = _rl_keyseq_cxt_alloc ();
1422+
1423+ if (got_subseq)
1424+ cxt->flags |= KSEQ_SUBSEQ;
1425+ cxt->okey = key;
1426+ cxt->oldmap = map;
1427+ cxt->dmap = _rl_dispatching_keymap;
1428+ cxt->subseq_arg = got_subseq || cxt->dmap[ANYOTHERKEY].function;
1429+
1430+ RL_SETSTATE (RL_STATE_MULTIKEY);
1431+ _rl_kscxt = cxt;
1432+
1433+ return r; /* don't indicate immediate success */
1434+ }
1435+#endif
1436+
1437+ /* Tentative inter-character timeout for potential multi-key
1438+ sequences? If no input within timeout, abort sequence and
1439+ act as if we got non-matching input. */
1440+ /* _rl_keyseq_timeout specified in milliseconds; _rl_input_queued
1441+ takes microseconds, so multiply by 1000 */
1442+ if (_rl_keyseq_timeout > 0 &&
1443+ (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) &&
1444+ _rl_pushed_input_available () == 0 &&
1445+ _rl_dispatching_keymap[ANYOTHERKEY].function &&
1446+ _rl_input_queued (_rl_keyseq_timeout*1000) == 0)
1447+ return (_rl_subseq_result (-2, map, key, got_subseq));
1448+
1449+ newkey = _rl_subseq_getchar (key);
1450+ if (newkey < 0)
1451+ {
1452+ _rl_abort_internal ();
1453+ return -1;
1454+ }
1455+
1456+ r = _rl_dispatch_subseq (newkey, _rl_dispatching_keymap, got_subseq || map[ANYOTHERKEY].function);
1457+ return _rl_subseq_result (r, map, key, got_subseq);
1458+ }
1459+ else
1460+ {
1461+ _rl_abort_internal ();
1462+ return -1;
1463+ }
1464+ break;
1465+
1466+ case ISMACR:
1467+ if (map[key].function != 0)
1468+ {
1469+ rl_executing_keyseq[rl_key_sequence_length] = '\0';
1470+ macro = savestring ((char *)map[key].function);
1471+ _rl_with_macro_input (macro);
1472+ return 0;
1473+ }
1474+ break;
1475+ }
1476+#if defined (VI_MODE)
1477+ if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap &&
1478+ key != ANYOTHERKEY &&
1479+ rl_key_sequence_length == 1 && /* XXX */
1480+ _rl_vi_textmod_command (key))
1481+ _rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign);
1482+#endif
1483+
1484+ return (r);
1485+}
1486+
1487+static int
1488+_rl_subseq_result (r, map, key, got_subseq)
1489+ int r;
1490+ Keymap map;
1491+ int key, got_subseq;
1492+{
1493+ Keymap m;
1494+ int type, nt;
1495+ rl_command_func_t *func, *nf;
1496+
1497+ if (r == -2)
1498+ /* We didn't match anything, and the keymap we're indexed into
1499+ shadowed a function previously bound to that prefix. Call
1500+ the function. The recursive call to _rl_dispatch_subseq has
1501+ already taken care of pushing any necessary input back onto
1502+ the input queue with _rl_unget_char. */
1503+ {
1504+ m = _rl_dispatching_keymap;
1505+ type = m[ANYOTHERKEY].type;
1506+ func = m[ANYOTHERKEY].function;
1507+ if (type == ISFUNC && func == rl_do_lowercase_version)
1508+ r = _rl_dispatch (_rl_to_lower (key), map);
1509+ else if (type == ISFUNC && func == rl_insert)
1510+ {
1511+ /* If the function that was shadowed was self-insert, we
1512+ somehow need a keymap with map[key].func == self-insert.
1513+ Let's use this one. */
1514+ nt = m[key].type;
1515+ nf = m[key].function;
1516+
1517+ m[key].type = type;
1518+ m[key].function = func;
1519+ r = _rl_dispatch (key, m);
1520+ m[key].type = nt;
1521+ m[key].function = nf;
1522+ }
1523+ else
1524+ r = _rl_dispatch (ANYOTHERKEY, m);
1525+ }
1526+ else if (r && map[ANYOTHERKEY].function)
1527+ {
1528+ /* We didn't match (r is probably -1), so return something to
1529+ tell the caller that it should try ANYOTHERKEY for an
1530+ overridden function. */
1531+ if (RL_ISSTATE (RL_STATE_MACROINPUT))
1532+ _rl_prev_macro_key ();
1533+ else
1534+ _rl_unget_char (key);
1535+ _rl_dispatching_keymap = map;
1536+ return -2;
1537+ }
1538+ else if (r && got_subseq)
1539+ {
1540+ /* OK, back up the chain. */
1541+ if (RL_ISSTATE (RL_STATE_MACROINPUT))
1542+ _rl_prev_macro_key ();
1543+ else
1544+ _rl_unget_char (key);
1545+ _rl_dispatching_keymap = map;
1546+ return -1;
1547+ }
1548+
1549+ return r;
1550+}
1551+
1552+/* **************************************************************** */
1553+/* */
1554+/* Initializations */
1555+/* */
1556+/* **************************************************************** */
1557+
1558+/* Initialize readline (and terminal if not already). */
1559+int
1560+rl_initialize ()
1561+{
1562+ /* If we have never been called before, initialize the
1563+ terminal and data structures. */
1564+ if (!rl_initialized)
1565+ {
1566+ RL_SETSTATE(RL_STATE_INITIALIZING);
1567+ readline_initialize_everything ();
1568+ RL_UNSETSTATE(RL_STATE_INITIALIZING);
1569+ rl_initialized++;
1570+ RL_SETSTATE(RL_STATE_INITIALIZED);
1571+ }
1572+
1573+ /* Initialize the current line information. */
1574+ _rl_init_line_state ();
1575+
1576+ /* We aren't done yet. We haven't even gotten started yet! */
1577+ rl_done = 0;
1578+ RL_UNSETSTATE(RL_STATE_DONE);
1579+
1580+ /* Tell the history routines what is going on. */
1581+ _rl_start_using_history ();
1582+
1583+ /* Make the display buffer match the state of the line. */
1584+ rl_reset_line_state ();
1585+
1586+ /* No such function typed yet. */
1587+ rl_last_func = (rl_command_func_t *)NULL;
1588+
1589+ /* Parsing of key-bindings begins in an enabled state. */
1590+ _rl_parsing_conditionalized_out = 0;
1591+
1592+#if defined (VI_MODE)
1593+ if (rl_editing_mode == vi_mode)
1594+ _rl_vi_initialize_line ();
1595+#endif
1596+
1597+ /* Each line starts in insert mode (the default). */
1598+ _rl_set_insert_mode (RL_IM_DEFAULT, 1);
1599+
1600+ return 0;
1601+}
1602+
1603+#if 0
1604+#if defined (__EMX__)
1605+static void
1606+_emx_build_environ ()
1607+{
1608+ TIB *tibp;
1609+ PIB *pibp;
1610+ char *t, **tp;
1611+ int c;
1612+
1613+ DosGetInfoBlocks (&tibp, &pibp);
1614+ t = pibp->pib_pchenv;
1615+ for (c = 1; *t; c++)
1616+ t += strlen (t) + 1;
1617+ tp = environ = (char **)xmalloc ((c + 1) * sizeof (char *));
1618+ t = pibp->pib_pchenv;
1619+ while (*t)
1620+ {
1621+ *tp++ = t;
1622+ t += strlen (t) + 1;
1623+ }
1624+ *tp = 0;
1625+}
1626+#endif /* __EMX__ */
1627+#endif
1628+
1629+/* Initialize the entire state of the world. */
1630+static void
1631+readline_initialize_everything ()
1632+{
1633+#if 0
1634+#if defined (__EMX__)
1635+ if (environ == 0)
1636+ _emx_build_environ ();
1637+#endif
1638+#endif
1639+
1640+#if 0
1641+ /* Find out if we are running in Emacs -- UNUSED. */
1642+ running_in_emacs = sh_get_env_value ("EMACS") != (char *)0;
1643+#endif
1644+
1645+ /* Set up input and output if they are not already set up. */
1646+ if (!rl_instream)
1647+ rl_instream = stdin;
1648+
1649+ if (!rl_outstream)
1650+ rl_outstream = stdout;
1651+
1652+ /* Bind _rl_in_stream and _rl_out_stream immediately. These values
1653+ may change, but they may also be used before readline_internal ()
1654+ is called. */
1655+ _rl_in_stream = rl_instream;
1656+ _rl_out_stream = rl_outstream;
1657+
1658+ /* Allocate data structures. */
1659+ if (rl_line_buffer == 0)
1660+ rl_line_buffer = (char *)xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE);
1661+
1662+ /* Initialize the terminal interface. */
1663+ if (rl_terminal_name == 0)
1664+ rl_terminal_name = sh_get_env_value ("TERM");
1665+ _rl_init_terminal_io (rl_terminal_name);
1666+
1667+ /* Bind tty characters to readline functions. */
1668+ readline_default_bindings ();
1669+
1670+ /* Initialize the function names. */
1671+ rl_initialize_funmap ();
1672+
1673+ /* Decide whether we should automatically go into eight-bit mode. */
1674+ _rl_init_eightbit ();
1675+
1676+ /* Read in the init file. */
1677+ rl_read_init_file ((char *)NULL);
1678+
1679+ /* XXX */
1680+ if (_rl_horizontal_scroll_mode && _rl_term_autowrap)
1681+ {
1682+ _rl_screenwidth--;
1683+ _rl_screenchars -= _rl_screenheight;
1684+ }
1685+
1686+ /* Override the effect of any `set keymap' assignments in the
1687+ inputrc file. */
1688+ rl_set_keymap_from_edit_mode ();
1689+
1690+ /* Try to bind a common arrow key prefix, if not already bound. */
1691+ bind_arrow_keys ();
1692+
1693+ /* If the completion parser's default word break characters haven't
1694+ been set yet, then do so now. */
1695+ if (rl_completer_word_break_characters == (char *)NULL)
1696+ rl_completer_word_break_characters = (char *)rl_basic_word_break_characters;
1697+
1698+#if defined (COLOR_SUPPORT)
1699+ if (_rl_colored_stats)
1700+ _rl_parse_colors ();
1701+#endif
1702+
1703+ rl_executing_keyseq = malloc (_rl_executing_keyseq_size = 16);
1704+ if (rl_executing_keyseq)
1705+ rl_executing_keyseq[0] = '\0';
1706+}
1707+
1708+/* If this system allows us to look at the values of the regular
1709+ input editing characters, then bind them to their readline
1710+ equivalents, iff the characters are not bound to keymaps. */
1711+static void
1712+readline_default_bindings ()
1713+{
1714+ if (_rl_bind_stty_chars)
1715+ rl_tty_set_default_bindings (_rl_keymap);
1716+}
1717+
1718+/* Reset the default bindings for the terminal special characters we're
1719+ interested in back to rl_insert and read the new ones. */
1720+static void
1721+reset_default_bindings ()
1722+{
1723+ if (_rl_bind_stty_chars)
1724+ {
1725+ rl_tty_unset_default_bindings (_rl_keymap);
1726+ rl_tty_set_default_bindings (_rl_keymap);
1727+ }
1728+}
1729+
1730+/* Bind some common arrow key sequences in MAP. */
1731+static void
1732+bind_arrow_keys_internal (map)
1733+ Keymap map;
1734+{
1735+ Keymap xkeymap;
1736+
1737+ xkeymap = _rl_keymap;
1738+ _rl_keymap = map;
1739+
1740+#if defined (__MSDOS__)
1741+ rl_bind_keyseq_if_unbound ("\033[0A", rl_get_previous_history);
1742+ rl_bind_keyseq_if_unbound ("\033[0B", rl_backward_char);
1743+ rl_bind_keyseq_if_unbound ("\033[0C", rl_forward_char);
1744+ rl_bind_keyseq_if_unbound ("\033[0D", rl_get_next_history);
1745+#endif
1746+
1747+ rl_bind_keyseq_if_unbound ("\033[A", rl_get_previous_history);
1748+ rl_bind_keyseq_if_unbound ("\033[B", rl_get_next_history);
1749+ rl_bind_keyseq_if_unbound ("\033[C", rl_forward_char);
1750+ rl_bind_keyseq_if_unbound ("\033[D", rl_backward_char);
1751+ rl_bind_keyseq_if_unbound ("\033[H", rl_beg_of_line);
1752+ rl_bind_keyseq_if_unbound ("\033[F", rl_end_of_line);
1753+
1754+ rl_bind_keyseq_if_unbound ("\033OA", rl_get_previous_history);
1755+ rl_bind_keyseq_if_unbound ("\033OB", rl_get_next_history);
1756+ rl_bind_keyseq_if_unbound ("\033OC", rl_forward_char);
1757+ rl_bind_keyseq_if_unbound ("\033OD", rl_backward_char);
1758+ rl_bind_keyseq_if_unbound ("\033OH", rl_beg_of_line);
1759+ rl_bind_keyseq_if_unbound ("\033OF", rl_end_of_line);
1760+
1761+#if defined (__MINGW32__)
1762+ rl_bind_keyseq_if_unbound ("\340H", rl_get_previous_history);
1763+ rl_bind_keyseq_if_unbound ("\340P", rl_get_next_history);
1764+ rl_bind_keyseq_if_unbound ("\340M", rl_forward_char);
1765+ rl_bind_keyseq_if_unbound ("\340K", rl_backward_char);
1766+ rl_bind_keyseq_if_unbound ("\340G", rl_beg_of_line);
1767+ rl_bind_keyseq_if_unbound ("\340O", rl_end_of_line);
1768+ rl_bind_keyseq_if_unbound ("\340S", rl_delete);
1769+ rl_bind_keyseq_if_unbound ("\340R", rl_overwrite_mode);
1770+
1771+ /* These may or may not work because of the embedded NUL. */
1772+ rl_bind_keyseq_if_unbound ("\\000H", rl_get_previous_history);
1773+ rl_bind_keyseq_if_unbound ("\\000P", rl_get_next_history);
1774+ rl_bind_keyseq_if_unbound ("\\000M", rl_forward_char);
1775+ rl_bind_keyseq_if_unbound ("\\000K", rl_backward_char);
1776+ rl_bind_keyseq_if_unbound ("\\000G", rl_beg_of_line);
1777+ rl_bind_keyseq_if_unbound ("\\000O", rl_end_of_line);
1778+ rl_bind_keyseq_if_unbound ("\\000S", rl_delete);
1779+ rl_bind_keyseq_if_unbound ("\\000R", rl_overwrite_mode);
1780+#endif
1781+
1782+ _rl_keymap = xkeymap;
1783+}
1784+
1785+/* Try and bind the common arrow key prefixes after giving termcap and
1786+ the inputrc file a chance to bind them and create `real' keymaps
1787+ for the arrow key prefix. */
1788+static void
1789+bind_arrow_keys ()
1790+{
1791+ bind_arrow_keys_internal (emacs_standard_keymap);
1792+
1793+#if defined (VI_MODE)
1794+ bind_arrow_keys_internal (vi_movement_keymap);
1795+ /* Unbind vi_movement_keymap[ESC] to allow users to repeatedly hit ESC
1796+ in vi command mode while still allowing the arrow keys to work. */
1797+ if (vi_movement_keymap[ESC].type == ISKMAP)
1798+ rl_bind_keyseq_in_map ("\033", (rl_command_func_t *)NULL, vi_movement_keymap);
1799+ bind_arrow_keys_internal (vi_insertion_keymap);
1800+#endif
1801+}
1802+
1803+/* **************************************************************** */
1804+/* */
1805+/* Saving and Restoring Readline's state */
1806+/* */
1807+/* **************************************************************** */
1808+
1809+int
1810+rl_save_state (sp)
1811+ struct readline_state *sp;
1812+{
1813+ if (sp == 0)
1814+ return -1;
1815+
1816+ sp->point = rl_point;
1817+ sp->end = rl_end;
1818+ sp->mark = rl_mark;
1819+ sp->buffer = rl_line_buffer;
1820+ sp->buflen = rl_line_buffer_len;
1821+ sp->ul = rl_undo_list;
1822+ sp->prompt = rl_prompt;
1823+
1824+ sp->rlstate = rl_readline_state;
1825+ sp->done = rl_done;
1826+ sp->kmap = _rl_keymap;
1827+
1828+ sp->lastfunc = rl_last_func;
1829+ sp->insmode = rl_insert_mode;
1830+ sp->edmode = rl_editing_mode;
1831+ sp->kseqlen = rl_key_sequence_length;
1832+ sp->inf = rl_instream;
1833+ sp->outf = rl_outstream;
1834+ sp->pendingin = rl_pending_input;
1835+ sp->macro = rl_executing_macro;
1836+
1837+ sp->catchsigs = rl_catch_signals;
1838+ sp->catchsigwinch = rl_catch_sigwinch;
1839+
1840+ return (0);
1841+}
1842+
1843+int
1844+rl_restore_state (sp)
1845+ struct readline_state *sp;
1846+{
1847+ if (sp == 0)
1848+ return -1;
1849+
1850+ rl_point = sp->point;
1851+ rl_end = sp->end;
1852+ rl_mark = sp->mark;
1853+ the_line = rl_line_buffer = sp->buffer;
1854+ rl_line_buffer_len = sp->buflen;
1855+ rl_undo_list = sp->ul;
1856+ rl_prompt = sp->prompt;
1857+
1858+ rl_readline_state = sp->rlstate;
1859+ rl_done = sp->done;
1860+ _rl_keymap = sp->kmap;
1861+
1862+ rl_last_func = sp->lastfunc;
1863+ rl_insert_mode = sp->insmode;
1864+ rl_editing_mode = sp->edmode;
1865+ rl_key_sequence_length = sp->kseqlen;
1866+ rl_instream = sp->inf;
1867+ rl_outstream = sp->outf;
1868+ rl_pending_input = sp->pendingin;
1869+ rl_executing_macro = sp->macro;
1870+
1871+ rl_catch_signals = sp->catchsigs;
1872+ rl_catch_sigwinch = sp->catchsigwinch;
1873+
1874+ return (0);
1875+}
1876diff -Naur bash-4.3.orig/lib/sh/shquote.c bash-4.3/lib/sh/shquote.c
1877--- bash-4.3.orig/lib/sh/shquote.c 2013-04-01 01:53:32.000000000 +0000
1878+++ bash-4.3/lib/sh/shquote.c 2014-10-10 14:40:53.230659509 +0000
1879@@ -311,3 +311,17 @@
1880
1881 return (0);
1882 }
1883+
1884+int
1885+sh_contains_quotes (string)
1886+ char *string;
1887+{
1888+ char *s;
1889+
1890+ for (s = string; s && *s; s++)
1891+ {
1892+ if (*s == '\'' || *s == '"' || *s == '\\')
1893+ return 1;
1894+ }
1895+ return 0;
1896+}
1897diff -Naur bash-4.3.orig/make_cmd.c bash-4.3/make_cmd.c
1898--- bash-4.3.orig/make_cmd.c 2011-12-16 13:08:01.000000000 +0000
1899+++ bash-4.3/make_cmd.c 2014-10-10 14:40:53.390659103 +0000
1900@@ -692,6 +692,7 @@
1901 /* First do the common cases. */
1902 temp->redirector = source;
1903 temp->redirectee = dest_and_filename;
1904+ temp->here_doc_eof = 0;
1905 temp->instruction = instruction;
1906 temp->flags = 0;
1907 temp->rflags = flags;
1908diff -Naur bash-4.3.orig/parse.y bash-4.3/parse.y
1909--- bash-4.3.orig/parse.y 2014-02-11 14:42:10.000000000 +0000
1910+++ bash-4.3/parse.y 2014-10-10 14:40:53.393992428 +0000
1911@@ -168,6 +168,9 @@
1912
1913 static int reserved_word_acceptable __P((int));
1914 static int yylex __P((void));
1915+
1916+static void push_heredoc __P((REDIRECT *));
1917+static char *mk_alexpansion __P((char *));
1918 static int alias_expand_token __P((char *));
1919 static int time_command_acceptable __P((void));
1920 static int special_case_tokens __P((char *));
1921@@ -265,7 +268,9 @@
1922
1923 /* Variables to manage the task of reading here documents, because we need to
1924 defer the reading until after a complete command has been collected. */
1925-static REDIRECT *redir_stack[10];
1926+#define HEREDOC_MAX 16
1927+
1928+static REDIRECT *redir_stack[HEREDOC_MAX];
1929 int need_here_doc;
1930
1931 /* Where shell input comes from. History expansion is performed on each
1932@@ -307,7 +312,7 @@
1933 or `for WORD' begins. This is a nested command maximum, since the array
1934 index is decremented after a case, select, or for command is parsed. */
1935 #define MAX_CASE_NEST 128
1936-static int word_lineno[MAX_CASE_NEST];
1937+static int word_lineno[MAX_CASE_NEST+1];
1938 static int word_top = -1;
1939
1940 /* If non-zero, it is the token that we want read_token to return
1941@@ -520,42 +525,42 @@
1942 source.dest = 0;
1943 redir.filename = $2;
1944 $$ = make_redirection (source, r_reading_until, redir, 0);
1945- redir_stack[need_here_doc++] = $$;
1946+ push_heredoc ($$);
1947 }
1948 | NUMBER LESS_LESS WORD
1949 {
1950 source.dest = $1;
1951 redir.filename = $3;
1952 $$ = make_redirection (source, r_reading_until, redir, 0);
1953- redir_stack[need_here_doc++] = $$;
1954+ push_heredoc ($$);
1955 }
1956 | REDIR_WORD LESS_LESS WORD
1957 {
1958 source.filename = $1;
1959 redir.filename = $3;
1960 $$ = make_redirection (source, r_reading_until, redir, REDIR_VARASSIGN);
1961- redir_stack[need_here_doc++] = $$;
1962+ push_heredoc ($$);
1963 }
1964 | LESS_LESS_MINUS WORD
1965 {
1966 source.dest = 0;
1967 redir.filename = $2;
1968 $$ = make_redirection (source, r_deblank_reading_until, redir, 0);
1969- redir_stack[need_here_doc++] = $$;
1970+ push_heredoc ($$);
1971 }
1972 | NUMBER LESS_LESS_MINUS WORD
1973 {
1974 source.dest = $1;
1975 redir.filename = $3;
1976 $$ = make_redirection (source, r_deblank_reading_until, redir, 0);
1977- redir_stack[need_here_doc++] = $$;
1978+ push_heredoc ($$);
1979 }
1980 | REDIR_WORD LESS_LESS_MINUS WORD
1981 {
1982 source.filename = $1;
1983 redir.filename = $3;
1984 $$ = make_redirection (source, r_deblank_reading_until, redir, REDIR_VARASSIGN);
1985- redir_stack[need_here_doc++] = $$;
1986+ push_heredoc ($$);
1987 }
1988 | LESS_LESS_LESS WORD
1989 {
1990@@ -2424,7 +2429,7 @@
1991 not already end in an EOF character. */
1992 if (shell_input_line_terminator != EOF)
1993 {
1994- if (shell_input_line_size < SIZE_MAX && shell_input_line_len > shell_input_line_size - 3)
1995+ if (shell_input_line_size < SIZE_MAX-3 && (shell_input_line_len+3 > shell_input_line_size))
1996 shell_input_line = (char *)xrealloc (shell_input_line,
1997 1 + (shell_input_line_size += 2));
1998
1999@@ -2533,6 +2538,16 @@
2000 eol_ungetc_lookahead = c;
2001 }
2002
2003+char *
2004+parser_remaining_input ()
2005+{
2006+ if (shell_input_line == 0)
2007+ return 0;
2008+ if (shell_input_line_index < 0 || shell_input_line_index >= shell_input_line_len)
2009+ return '\0'; /* XXX */
2010+ return (shell_input_line + shell_input_line_index);
2011+}
2012+
2013 #ifdef INCLUDE_UNUSED
2014 /* Back the input pointer up by one, effectively `ungetting' a character. */
2015 static void
2016@@ -2636,13 +2651,28 @@
2017 which allow ESAC to be the next one read. */
2018 static int esacs_needed_count;
2019
2020+static void
2021+push_heredoc (r)
2022+ REDIRECT *r;
2023+{
2024+ if (need_here_doc >= HEREDOC_MAX)
2025+ {
2026+ last_command_exit_value = EX_BADUSAGE;
2027+ need_here_doc = 0;
2028+ report_syntax_error (_("maximum here-document count exceeded"));
2029+ reset_parser ();
2030+ exit_shell (last_command_exit_value);
2031+ }
2032+ redir_stack[need_here_doc++] = r;
2033+}
2034+
2035 void
2036 gather_here_documents ()
2037 {
2038 int r;
2039
2040 r = 0;
2041- while (need_here_doc)
2042+ while (need_here_doc > 0)
2043 {
2044 parser_state |= PST_HEREDOC;
2045 make_here_document (redir_stack[r++], line_number);
2046@@ -2953,6 +2983,8 @@
2047 FREE (word_desc_to_read);
2048 word_desc_to_read = (WORD_DESC *)NULL;
2049
2050+ eol_ungetc_lookahead = 0;
2051+
2052 current_token = '\n'; /* XXX */
2053 last_read_token = '\n';
2054 token_to_read = '\n';
2055@@ -3398,7 +3430,7 @@
2056 within a double-quoted ${...} construct "an even number of
2057 unescaped double-quotes or single-quotes, if any, shall occur." */
2058 /* This was changed in Austin Group Interp 221 */
2059- if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'')
2060+ if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && dolbrace_state != DOLBRACE_QUOTE2 && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'')
2061 continue;
2062
2063 /* Could also check open == '`' if we want to parse grouping constructs
2064@@ -4005,8 +4037,8 @@
2065 reset_parser ();
2066 /* reset_parser clears shell_input_line and associated variables */
2067 restore_input_line_state (&ls);
2068- if (interactive)
2069- token_to_read = 0;
2070+
2071+ token_to_read = 0;
2072
2073 /* Need to find how many characters parse_and_execute consumed, update
2074 *indp, if flags != 0, copy the portion of the string parsed into RET
2075@@ -6075,6 +6107,7 @@
2076
2077 ps->expand_aliases = expand_aliases;
2078 ps->echo_input_at_read = echo_input_at_read;
2079+ ps->need_here_doc = need_here_doc;
2080
2081 ps->token = token;
2082 ps->token_buffer_size = token_buffer_size;
2083@@ -6123,6 +6156,7 @@
2084
2085 expand_aliases = ps->expand_aliases;
2086 echo_input_at_read = ps->echo_input_at_read;
2087+ need_here_doc = ps->need_here_doc;
2088
2089 FREE (token);
2090 token = ps->token;
2091diff -Naur bash-4.3.orig/patchlevel.h bash-4.3/patchlevel.h
2092--- bash-4.3.orig/patchlevel.h 2012-12-29 15:47:57.000000000 +0000
2093+++ bash-4.3/patchlevel.h 2014-10-10 14:40:53.400659078 +0000
2094@@ -25,6 +25,6 @@
2095 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
2096 looks for to find the patch level (for the sccs version string). */
2097
2098-#define PATCHLEVEL 0
2099+#define PATCHLEVEL 30
2100
2101 #endif /* _PATCHLEVEL_H_ */
2102diff -Naur bash-4.3.orig/pcomplete.c bash-4.3/pcomplete.c
2103--- bash-4.3.orig/pcomplete.c 2013-08-26 19:23:45.000000000 +0000
2104+++ bash-4.3/pcomplete.c 2014-10-10 14:40:53.230659509 +0000
2105@@ -183,6 +183,7 @@
2106
2107 COMPSPEC *pcomp_curcs;
2108 const char *pcomp_curcmd;
2109+const char *pcomp_curtxt;
2110
2111 #ifdef DEBUG
2112 /* Debugging code */
2113@@ -753,6 +754,32 @@
2114 quoted strings. */
2115 dfn = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character);
2116 }
2117+ /* Intended to solve a mismatched assumption by bash-completion. If
2118+ the text to be completed is empty, but bash-completion turns it into
2119+ a quoted string ('') assuming that this code will dequote it before
2120+ calling readline, do the dequoting. */
2121+ else if (iscompgen && iscompleting &&
2122+ pcomp_curtxt && *pcomp_curtxt == 0 &&
2123+ text && (*text == '\'' || *text == '"') && text[1] == text[0] && text[2] == 0 &&
2124+ rl_filename_dequoting_function)
2125+ dfn = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character);
2126+ /* Another mismatched assumption by bash-completion. If compgen is being
2127+ run as part of bash-completion, and the argument to compgen is not
2128+ the same as the word originally passed to the programmable completion
2129+ code, dequote the argument if it has quote characters. It's an
2130+ attempt to detect when bash-completion is quoting its filename
2131+ argument before calling compgen. */
2132+ /* We could check whether gen_shell_function_matches is in the call
2133+ stack by checking whether the gen-shell-function-matches tag is in
2134+ the unwind-protect stack, but there's no function to do that yet.
2135+ We could simply check whether we're executing in a function by
2136+ checking variable_context, and may end up doing that. */
2137+ else if (iscompgen && iscompleting && rl_filename_dequoting_function &&
2138+ pcomp_curtxt && text &&
2139+ STREQ (pcomp_curtxt, text) == 0 &&
2140+ variable_context &&
2141+ sh_contains_quotes (text)) /* guess */
2142+ dfn = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character);
2143 else
2144 dfn = savestring (text);
2145 }
2146@@ -1522,7 +1549,7 @@
2147 COMPSPEC **lastcs;
2148 {
2149 COMPSPEC *cs, *oldcs;
2150- const char *oldcmd;
2151+ const char *oldcmd, *oldtxt;
2152 STRINGLIST *ret;
2153
2154 cs = progcomp_search (ocmd);
2155@@ -1545,14 +1572,17 @@
2156
2157 oldcs = pcomp_curcs;
2158 oldcmd = pcomp_curcmd;
2159+ oldtxt = pcomp_curtxt;
2160
2161 pcomp_curcs = cs;
2162 pcomp_curcmd = cmd;
2163+ pcomp_curtxt = word;
2164
2165 ret = gen_compspec_completions (cs, cmd, word, start, end, foundp);
2166
2167 pcomp_curcs = oldcs;
2168 pcomp_curcmd = oldcmd;
2169+ pcomp_curtxt = oldtxt;
2170
2171 /* We need to conditionally handle setting *retryp here */
2172 if (retryp)
2173diff -Naur bash-4.3.orig/shell.h bash-4.3/shell.h
2174--- bash-4.3.orig/shell.h 2012-12-26 02:11:01.000000000 +0000
2175+++ bash-4.3/shell.h 2014-10-10 14:40:53.393992428 +0000
2176@@ -168,7 +168,8 @@
2177 /* flags state affecting the parser */
2178 int expand_aliases;
2179 int echo_input_at_read;
2180-
2181+ int need_here_doc;
2182+
2183 } sh_parser_state_t;
2184
2185 typedef struct _sh_input_line_state_t {
2186@@ -179,6 +180,8 @@
2187 } sh_input_line_state_t;
2188
2189 /* Let's try declaring these here. */
2190+extern char *parser_remaining_input __P((void));
2191+
2192 extern sh_parser_state_t *save_parser_state __P((sh_parser_state_t *));
2193 extern void restore_parser_state __P((sh_parser_state_t *));
2194
2195diff -Naur bash-4.3.orig/subst.c bash-4.3/subst.c
2196--- bash-4.3.orig/subst.c 2014-01-23 21:26:37.000000000 +0000
2197+++ bash-4.3/subst.c 2014-10-10 14:40:53.360659179 +0000
2198@@ -1192,12 +1192,18 @@
2199 Start extracting at (SINDEX) as if we had just seen "<(".
2200 Make (SINDEX) get the position of the matching ")". */ /*))*/
2201 char *
2202-extract_process_subst (string, starter, sindex)
2203+extract_process_subst (string, starter, sindex, xflags)
2204 char *string;
2205 char *starter;
2206 int *sindex;
2207+ int xflags;
2208 {
2209+#if 0
2210 return (extract_delimited_string (string, sindex, starter, "(", ")", SX_COMMAND));
2211+#else
2212+ xflags |= (no_longjmp_on_fatal_error ? SX_NOLONGJMP : 0);
2213+ return (xparse_dolparen (string, string+*sindex, sindex, xflags));
2214+#endif
2215 }
2216 #endif /* PROCESS_SUBSTITUTION */
2217
2218@@ -1785,7 +1791,7 @@
2219 si = i + 2;
2220 if (string[si] == '\0')
2221 CQ_RETURN(si);
2222- temp = extract_process_subst (string, (c == '<') ? "<(" : ">(", &si);
2223+ temp = extract_process_subst (string, (c == '<') ? "<(" : ">(", &si, 0);
2224 free (temp); /* no SX_ALLOC here */
2225 i = si;
2226 if (string[i] == '\0')
2227@@ -3248,8 +3254,10 @@
2228 if (w->word == 0 || w->word[0] == '\0')
2229 return ((char *)NULL);
2230
2231+ expand_no_split_dollar_star = 1;
2232 w->flags |= W_NOSPLIT2;
2233 l = call_expand_word_internal (w, 0, 0, (int *)0, (int *)0);
2234+ expand_no_split_dollar_star = 0;
2235 if (l)
2236 {
2237 if (special == 0) /* LHS */
2238@@ -7366,7 +7374,13 @@
2239 }
2240
2241 if (want_indir)
2242- tdesc = parameter_brace_expand_indir (name + 1, var_is_special, quoted, quoted_dollar_atp, contains_dollar_at);
2243+ {
2244+ tdesc = parameter_brace_expand_indir (name + 1, var_is_special, quoted, quoted_dollar_atp, contains_dollar_at);
2245+ /* Turn off the W_ARRAYIND flag because there is no way for this function
2246+ to return the index we're supposed to be using. */
2247+ if (tdesc && tdesc->flags)
2248+ tdesc->flags &= ~W_ARRAYIND;
2249+ }
2250 else
2251 tdesc = parameter_brace_expand_word (name, var_is_special, quoted, PF_IGNUNBOUND|(pflags&(PF_NOSPLIT2|PF_ASSIGNRHS)), &ind);
2252
2253@@ -7847,6 +7861,10 @@
2254 We also want to make sure that splitting is done no matter what --
2255 according to POSIX.2, this expands to a list of the positional
2256 parameters no matter what IFS is set to. */
2257+ /* XXX - what to do when in a context where word splitting is not
2258+ performed? Even when IFS is not the default, posix seems to imply
2259+ that we behave like unquoted $* ? Maybe we should use PF_NOSPLIT2
2260+ here. */
2261 temp = string_list_dollar_at (list, (pflags & PF_ASSIGNRHS) ? (quoted|Q_DOUBLE_QUOTES) : quoted);
2262
2263 tflag |= W_DOLLARAT;
2264@@ -8029,7 +8047,9 @@
2265
2266 goto return0;
2267 }
2268- else if (var = find_variable_last_nameref (temp1))
2269+ else if (var && (invisible_p (var) || var_isset (var) == 0))
2270+ temp = (char *)NULL;
2271+ else if ((var = find_variable_last_nameref (temp1)) && var_isset (var) && invisible_p (var) == 0)
2272 {
2273 temp = nameref_cell (var);
2274 #if defined (ARRAY_VARS)
2275@@ -8243,7 +8263,7 @@
2276 else
2277 t_index = sindex + 1; /* skip past both '<' and LPAREN */
2278
2279- temp1 = extract_process_subst (string, (c == '<') ? "<(" : ">(", &t_index); /*))*/
2280+ temp1 = extract_process_subst (string, (c == '<') ? "<(" : ">(", &t_index, 0); /*))*/
2281 sindex = t_index;
2282
2283 /* If the process substitution specification is `<()', we want to
2284@@ -8816,6 +8836,7 @@
2285 else
2286 {
2287 char *ifs_chars;
2288+ char *tstring;
2289
2290 ifs_chars = (quoted_dollar_at || has_dollar_at) ? ifs_value : (char *)NULL;
2291
2292@@ -8830,11 +8851,36 @@
2293 regardless of what else has happened to IFS since the expansion. */
2294 if (split_on_spaces)
2295 list = list_string (istring, " ", 1); /* XXX quoted == 1? */
2296+ /* If we have $@ (has_dollar_at != 0) and we are in a context where we
2297+ don't want to split the result (W_NOSPLIT2), and we are not quoted,
2298+ we have already separated the arguments with the first character of
2299+ $IFS. In this case, we want to return a list with a single word
2300+ with the separator possibly replaced with a space (it's what other
2301+ shells seem to do).
2302+ quoted_dollar_at is internal to this function and is set if we are
2303+ passed an argument that is unquoted (quoted == 0) but we encounter a
2304+ double-quoted $@ while expanding it. */
2305+ else if (has_dollar_at && quoted_dollar_at == 0 && ifs_chars && quoted == 0 && (word->flags & W_NOSPLIT2))
2306+ {
2307+ /* Only split and rejoin if we have to */
2308+ if (*ifs_chars && *ifs_chars != ' ')
2309+ {
2310+ list = list_string (istring, *ifs_chars ? ifs_chars : " ", 1);
2311+ tstring = string_list (list);
2312+ }
2313+ else
2314+ tstring = istring;
2315+ tword = make_bare_word (tstring);
2316+ if (tstring != istring)
2317+ free (tstring);
2318+ goto set_word_flags;
2319+ }
2320 else if (has_dollar_at && ifs_chars)
2321 list = list_string (istring, *ifs_chars ? ifs_chars : " ", 1);
2322 else
2323 {
2324 tword = make_bare_word (istring);
2325+set_word_flags:
2326 if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || (quoted_state == WHOLLY_QUOTED))
2327 tword->flags |= W_QUOTED;
2328 if (word->flags & W_ASSIGNMENT)
2329diff -Naur bash-4.3.orig/subst.h bash-4.3/subst.h
2330--- bash-4.3.orig/subst.h 2014-01-12 02:02:27.000000000 +0000
2331+++ bash-4.3/subst.h 2014-10-10 14:40:53.340659230 +0000
2332@@ -82,7 +82,7 @@
2333 /* Extract the <( or >( construct in STRING, and return a new string.
2334 Start extracting at (SINDEX) as if we had just seen "<(".
2335 Make (SINDEX) get the position just after the matching ")". */
2336-extern char *extract_process_subst __P((char *, char *, int *));
2337+extern char *extract_process_subst __P((char *, char *, int *, int));
2338 #endif /* PROCESS_SUBSTITUTION */
2339
2340 /* Extract the name of the variable to bind to from the assignment string. */
2341diff -Naur bash-4.3.orig/test.c bash-4.3/test.c
2342--- bash-4.3.orig/test.c 2014-02-04 21:52:58.000000000 +0000
2343+++ bash-4.3/test.c 2014-10-10 14:40:53.153993036 +0000
2344@@ -646,8 +646,8 @@
2345 return (v && invisible_p (v) == 0 && var_isset (v) ? TRUE : FALSE);
2346
2347 case 'R':
2348- v = find_variable (arg);
2349- return (v && invisible_p (v) == 0 && var_isset (v) && nameref_p (v) ? TRUE : FALSE);
2350+ v = find_variable_noref (arg);
2351+ return ((v && invisible_p (v) == 0 && var_isset (v) && nameref_p (v)) ? TRUE : FALSE);
2352 }
2353
2354 /* We can't actually get here, but this shuts up gcc. */
2355@@ -723,6 +723,7 @@
2356 case 'o': case 'p': case 'r': case 's': case 't':
2357 case 'u': case 'v': case 'w': case 'x': case 'z':
2358 case 'G': case 'L': case 'O': case 'S': case 'N':
2359+ case 'R':
2360 return (1);
2361 }
2362
2363diff -Naur bash-4.3.orig/trap.c bash-4.3/trap.c
2364--- bash-4.3.orig/trap.c 2014-02-05 15:03:21.000000000 +0000
2365+++ bash-4.3/trap.c 2014-10-10 14:40:53.157326361 +0000
2366@@ -920,7 +920,8 @@
2367 subst_assign_varlist = 0;
2368
2369 #if defined (JOB_CONTROL)
2370- save_pipeline (1); /* XXX only provides one save level */
2371+ if (sig != DEBUG_TRAP) /* run_debug_trap does this */
2372+ save_pipeline (1); /* XXX only provides one save level */
2373 #endif
2374
2375 /* If we're in a function, make sure return longjmps come here, too. */
2376@@ -940,7 +941,8 @@
2377 trap_exit_value = last_command_exit_value;
2378
2379 #if defined (JOB_CONTROL)
2380- restore_pipeline (1);
2381+ if (sig != DEBUG_TRAP) /* run_debug_trap does this */
2382+ restore_pipeline (1);
2383 #endif
2384
2385 subst_assign_varlist = save_subst_varlist;
2386diff -Naur bash-4.3.orig/variables.c bash-4.3/variables.c
2387--- bash-4.3.orig/variables.c 2014-02-14 16:55:12.000000000 +0000
2388+++ bash-4.3/variables.c 2014-10-10 14:40:53.377325804 +0000
2389@@ -83,6 +83,11 @@
2390
2391 #define ifsname(s) ((s)[0] == 'I' && (s)[1] == 'F' && (s)[2] == 'S' && (s)[3] == '\0')
2392
2393+#define BASHFUNC_PREFIX "BASH_FUNC_"
2394+#define BASHFUNC_PREFLEN 10 /* == strlen(BASHFUNC_PREFIX */
2395+#define BASHFUNC_SUFFIX "%%"
2396+#define BASHFUNC_SUFFLEN 2 /* == strlen(BASHFUNC_SUFFIX) */
2397+
2398 extern char **environ;
2399
2400 /* Variables used here and defined in other files. */
2401@@ -279,7 +284,7 @@
2402 static void propagate_temp_var __P((PTR_T));
2403 static void dispose_temporary_env __P((sh_free_func_t *));
2404
2405-static inline char *mk_env_string __P((const char *, const char *));
2406+static inline char *mk_env_string __P((const char *, const char *, int));
2407 static char **make_env_array_from_var_list __P((SHELL_VAR **));
2408 static char **make_var_export_array __P((VAR_CONTEXT *));
2409 static char **make_func_export_array __P((void));
2410@@ -349,24 +354,33 @@
2411
2412 /* If exported function, define it now. Don't import functions from
2413 the environment in privileged mode. */
2414- if (privmode == 0 && read_but_dont_execute == 0 && STREQN ("() {", string, 4))
2415+ if (privmode == 0 && read_but_dont_execute == 0 &&
2416+ STREQN (BASHFUNC_PREFIX, name, BASHFUNC_PREFLEN) &&
2417+ STREQ (BASHFUNC_SUFFIX, name + char_index - BASHFUNC_SUFFLEN) &&
2418+ STREQN ("() {", string, 4))
2419 {
2420- string_length = strlen (string);
2421- temp_string = (char *)xmalloc (3 + string_length + char_index);
2422+ size_t namelen;
2423+ char *tname; /* desired imported function name */
2424
2425- strcpy (temp_string, name);
2426- temp_string[char_index] = ' ';
2427- strcpy (temp_string + char_index + 1, string);
2428+ namelen = char_index - BASHFUNC_PREFLEN - BASHFUNC_SUFFLEN;
2429
2430- if (posixly_correct == 0 || legal_identifier (name))
2431- parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST);
2432+ tname = name + BASHFUNC_PREFLEN; /* start of func name */
2433+ tname[namelen] = '\0'; /* now tname == func name */
2434+
2435+ string_length = strlen (string);
2436+ temp_string = (char *)xmalloc (namelen + string_length + 2);
2437
2438- /* Ancient backwards compatibility. Old versions of bash exported
2439- functions like name()=() {...} */
2440- if (name[char_index - 1] == ')' && name[char_index - 2] == '(')
2441- name[char_index - 2] = '\0';
2442+ memcpy (temp_string, tname, namelen);
2443+ temp_string[namelen] = ' ';
2444+ memcpy (temp_string + namelen + 1, string, string_length + 1);
2445+
2446+ /* Don't import function names that are invalid identifiers from the
2447+ environment, though we still allow them to be defined as shell
2448+ variables. */
2449+ if (absolute_program (tname) == 0 && (posixly_correct == 0 || legal_identifier (tname)))
2450+ parse_and_execute (temp_string, tname, SEVAL_NONINT|SEVAL_NOHIST|SEVAL_FUNCDEF|SEVAL_ONECMD);
2451
2452- if (temp_var = find_function (name))
2453+ if (temp_var = find_function (tname))
2454 {
2455 VSETATTR (temp_var, (att_exported|att_imported));
2456 array_needs_making = 1;
2457@@ -379,12 +393,11 @@
2458 array_needs_making = 1;
2459 }
2460 last_command_exit_value = 1;
2461- report_error (_("error importing function definition for `%s'"), name);
2462+ report_error (_("error importing function definition for `%s'"), tname);
2463 }
2464
2465- /* ( */
2466- if (name[char_index - 1] == ')' && name[char_index - 2] == '\0')
2467- name[char_index - 2] = '('; /* ) */
2468+ /* Restore original suffix */
2469+ tname[namelen] = BASHFUNC_SUFFIX[0];
2470 }
2471 #if defined (ARRAY_VARS)
2472 # if ARRAY_EXPORT
2473@@ -2197,10 +2210,7 @@
2474 /* local foo; local foo; is a no-op. */
2475 old_var = find_variable (name);
2476 if (old_var && local_p (old_var) && old_var->context == variable_context)
2477- {
2478- VUNSETATTR (old_var, att_invisible); /* XXX */
2479- return (old_var);
2480- }
2481+ return (old_var);
2482
2483 was_tmpvar = old_var && tempvar_p (old_var);
2484 /* If we're making a local variable in a shell function, the temporary env
2485@@ -2963,7 +2973,7 @@
2486 var->context = variable_context; /* XXX */
2487
2488 INVALIDATE_EXPORTSTR (var);
2489- var->exportstr = mk_env_string (name, value);
2490+ var->exportstr = mk_env_string (name, value, 0);
2491
2492 array_needs_making = 1;
2493
2494@@ -3861,21 +3871,42 @@
2495 /* **************************************************************** */
2496
2497 static inline char *
2498-mk_env_string (name, value)
2499+mk_env_string (name, value, isfunc)
2500 const char *name, *value;
2501+ int isfunc;
2502 {
2503- int name_len, value_len;
2504- char *p;
2505+ size_t name_len, value_len;
2506+ char *p, *q;
2507
2508 name_len = strlen (name);
2509 value_len = STRLEN (value);
2510- p = (char *)xmalloc (2 + name_len + value_len);
2511- strcpy (p, name);
2512- p[name_len] = '=';
2513+
2514+ /* If we are exporting a shell function, construct the encoded function
2515+ name. */
2516+ if (isfunc && value)
2517+ {
2518+ p = (char *)xmalloc (BASHFUNC_PREFLEN + name_len + BASHFUNC_SUFFLEN + value_len + 2);
2519+ q = p;
2520+ memcpy (q, BASHFUNC_PREFIX, BASHFUNC_PREFLEN);
2521+ q += BASHFUNC_PREFLEN;
2522+ memcpy (q, name, name_len);
2523+ q += name_len;
2524+ memcpy (q, BASHFUNC_SUFFIX, BASHFUNC_SUFFLEN);
2525+ q += BASHFUNC_SUFFLEN;
2526+ }
2527+ else
2528+ {
2529+ p = (char *)xmalloc (2 + name_len + value_len);
2530+ memcpy (p, name, name_len);
2531+ q = p + name_len;
2532+ }
2533+
2534+ q[0] = '=';
2535 if (value && *value)
2536- strcpy (p + name_len + 1, value);
2537+ memcpy (q + 1, value, value_len + 1);
2538 else
2539- p[name_len + 1] = '\0';
2540+ q[1] = '\0';
2541+
2542 return (p);
2543 }
2544
2545@@ -3961,7 +3992,7 @@
2546 /* Gee, I'd like to get away with not using savestring() if we're
2547 using the cached exportstr... */
2548 list[list_index] = USE_EXPORTSTR ? savestring (value)
2549- : mk_env_string (var->name, value);
2550+ : mk_env_string (var->name, value, function_p (var));
2551
2552 if (USE_EXPORTSTR == 0)
2553 SAVE_EXPORTSTR (var, list[list_index]);
2554diff -Naur bash-4.3.orig/y.tab.c bash-4.3/y.tab.c
2555--- bash-4.3.orig/y.tab.c 2014-02-11 15:57:47.000000000 +0000
2556+++ bash-4.3/y.tab.c 2014-10-10 14:40:53.400659078 +0000
2557@@ -168,7 +168,7 @@
2558
2559
2560 /* Copy the first part of user declarations. */
2561-#line 21 "/usr/homes/chet/src/bash/src/parse.y"
2562+#line 21 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2563
2564 #include "config.h"
2565
2566@@ -319,6 +319,9 @@
2567
2568 static int reserved_word_acceptable __P((int));
2569 static int yylex __P((void));
2570+
2571+static void push_heredoc __P((REDIRECT *));
2572+static char *mk_alexpansion __P((char *));
2573 static int alias_expand_token __P((char *));
2574 static int time_command_acceptable __P((void));
2575 static int special_case_tokens __P((char *));
2576@@ -416,7 +419,9 @@
2577
2578 /* Variables to manage the task of reading here documents, because we need to
2579 defer the reading until after a complete command has been collected. */
2580-static REDIRECT *redir_stack[10];
2581+#define HEREDOC_MAX 16
2582+
2583+static REDIRECT *redir_stack[HEREDOC_MAX];
2584 int need_here_doc;
2585
2586 /* Where shell input comes from. History expansion is performed on each
2587@@ -458,7 +463,7 @@
2588 or `for WORD' begins. This is a nested command maximum, since the array
2589 index is decremented after a case, select, or for command is parsed. */
2590 #define MAX_CASE_NEST 128
2591-static int word_lineno[MAX_CASE_NEST];
2592+static int word_lineno[MAX_CASE_NEST+1];
2593 static int word_top = -1;
2594
2595 /* If non-zero, it is the token that we want read_token to return
2596@@ -492,7 +497,7 @@
2597
2598 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
2599 typedef union YYSTYPE
2600-#line 324 "/usr/homes/chet/src/bash/src/parse.y"
2601+#line 329 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2602 {
2603 WORD_DESC *word; /* the word that we read. */
2604 int number; /* the number that we read. */
2605@@ -503,7 +508,7 @@
2606 PATTERN_LIST *pattern;
2607 }
2608 /* Line 193 of yacc.c. */
2609-#line 507 "y.tab.c"
2610+#line 512 "y.tab.c"
2611 YYSTYPE;
2612 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
2613 # define YYSTYPE_IS_DECLARED 1
2614@@ -516,7 +521,7 @@
2615
2616
2617 /* Line 216 of yacc.c. */
2618-#line 520 "y.tab.c"
2619+#line 525 "y.tab.c"
2620
2621 #ifdef short
2622 # undef short
2623@@ -886,23 +891,23 @@
2624 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
2625 static const yytype_uint16 yyrline[] =
2626 {
2627- 0, 377, 377, 388, 397, 412, 422, 424, 428, 434,
2628- 440, 446, 452, 458, 464, 470, 476, 482, 488, 494,
2629- 500, 506, 512, 518, 525, 532, 539, 546, 553, 560,
2630- 566, 572, 578, 584, 590, 596, 602, 608, 614, 620,
2631- 626, 632, 638, 644, 650, 656, 662, 668, 674, 680,
2632- 686, 692, 700, 702, 704, 708, 712, 723, 725, 729,
2633- 731, 733, 749, 751, 755, 757, 759, 761, 763, 765,
2634- 767, 769, 771, 773, 775, 779, 784, 789, 794, 799,
2635- 804, 809, 814, 821, 826, 831, 836, 843, 848, 853,
2636- 858, 863, 868, 875, 880, 885, 892, 895, 898, 902,
2637- 904, 935, 942, 947, 964, 969, 986, 993, 995, 997,
2638- 1002, 1006, 1010, 1014, 1016, 1018, 1022, 1023, 1027, 1029,
2639- 1031, 1033, 1037, 1039, 1041, 1043, 1045, 1047, 1051, 1053,
2640- 1062, 1070, 1071, 1077, 1078, 1085, 1089, 1091, 1093, 1100,
2641- 1102, 1104, 1108, 1109, 1112, 1114, 1116, 1120, 1121, 1130,
2642- 1143, 1159, 1174, 1176, 1178, 1185, 1188, 1192, 1194, 1200,
2643- 1206, 1223, 1243, 1245, 1268, 1272, 1274, 1276
2644+ 0, 382, 382, 393, 402, 417, 427, 429, 433, 439,
2645+ 445, 451, 457, 463, 469, 475, 481, 487, 493, 499,
2646+ 505, 511, 517, 523, 530, 537, 544, 551, 558, 565,
2647+ 571, 577, 583, 589, 595, 601, 607, 613, 619, 625,
2648+ 631, 637, 643, 649, 655, 661, 667, 673, 679, 685,
2649+ 691, 697, 705, 707, 709, 713, 717, 728, 730, 734,
2650+ 736, 738, 754, 756, 760, 762, 764, 766, 768, 770,
2651+ 772, 774, 776, 778, 780, 784, 789, 794, 799, 804,
2652+ 809, 814, 819, 826, 831, 836, 841, 848, 853, 858,
2653+ 863, 868, 873, 880, 885, 890, 897, 900, 903, 907,
2654+ 909, 940, 947, 952, 969, 974, 991, 998, 1000, 1002,
2655+ 1007, 1011, 1015, 1019, 1021, 1023, 1027, 1028, 1032, 1034,
2656+ 1036, 1038, 1042, 1044, 1046, 1048, 1050, 1052, 1056, 1058,
2657+ 1067, 1075, 1076, 1082, 1083, 1090, 1094, 1096, 1098, 1105,
2658+ 1107, 1109, 1113, 1114, 1117, 1119, 1121, 1125, 1126, 1135,
2659+ 1148, 1164, 1179, 1181, 1183, 1190, 1193, 1197, 1199, 1205,
2660+ 1211, 1228, 1248, 1250, 1273, 1277, 1279, 1281
2661 };
2662 #endif
2663
2664@@ -2093,7 +2098,7 @@
2665 switch (yyn)
2666 {
2667 case 2:
2668-#line 378 "/usr/homes/chet/src/bash/src/parse.y"
2669+#line 383 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2670 {
2671 /* Case of regular command. Discard the error
2672 safety net,and return the command just parsed. */
2673@@ -2107,7 +2112,7 @@
2674 break;
2675
2676 case 3:
2677-#line 389 "/usr/homes/chet/src/bash/src/parse.y"
2678+#line 394 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2679 {
2680 /* Case of regular command, but not a very
2681 interesting one. Return a NULL command. */
2682@@ -2119,7 +2124,7 @@
2683 break;
2684
2685 case 4:
2686-#line 398 "/usr/homes/chet/src/bash/src/parse.y"
2687+#line 403 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2688 {
2689 /* Error during parsing. Return NULL command. */
2690 global_command = (COMMAND *)NULL;
2691@@ -2137,7 +2142,7 @@
2692 break;
2693
2694 case 5:
2695-#line 413 "/usr/homes/chet/src/bash/src/parse.y"
2696+#line 418 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2697 {
2698 /* Case of EOF seen by itself. Do ignoreeof or
2699 not. */
2700@@ -2148,17 +2153,17 @@
2701 break;
2702
2703 case 6:
2704-#line 423 "/usr/homes/chet/src/bash/src/parse.y"
2705+#line 428 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2706 { (yyval.word_list) = make_word_list ((yyvsp[(1) - (1)].word), (WORD_LIST *)NULL); }
2707 break;
2708
2709 case 7:
2710-#line 425 "/usr/homes/chet/src/bash/src/parse.y"
2711+#line 430 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2712 { (yyval.word_list) = make_word_list ((yyvsp[(2) - (2)].word), (yyvsp[(1) - (2)].word_list)); }
2713 break;
2714
2715 case 8:
2716-#line 429 "/usr/homes/chet/src/bash/src/parse.y"
2717+#line 434 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2718 {
2719 source.dest = 1;
2720 redir.filename = (yyvsp[(2) - (2)].word);
2721@@ -2167,7 +2172,7 @@
2722 break;
2723
2724 case 9:
2725-#line 435 "/usr/homes/chet/src/bash/src/parse.y"
2726+#line 440 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2727 {
2728 source.dest = 0;
2729 redir.filename = (yyvsp[(2) - (2)].word);
2730@@ -2176,7 +2181,7 @@
2731 break;
2732
2733 case 10:
2734-#line 441 "/usr/homes/chet/src/bash/src/parse.y"
2735+#line 446 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2736 {
2737 source.dest = (yyvsp[(1) - (3)].number);
2738 redir.filename = (yyvsp[(3) - (3)].word);
2739@@ -2185,7 +2190,7 @@
2740 break;
2741
2742 case 11:
2743-#line 447 "/usr/homes/chet/src/bash/src/parse.y"
2744+#line 452 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2745 {
2746 source.dest = (yyvsp[(1) - (3)].number);
2747 redir.filename = (yyvsp[(3) - (3)].word);
2748@@ -2194,7 +2199,7 @@
2749 break;
2750
2751 case 12:
2752-#line 453 "/usr/homes/chet/src/bash/src/parse.y"
2753+#line 458 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2754 {
2755 source.filename = (yyvsp[(1) - (3)].word);
2756 redir.filename = (yyvsp[(3) - (3)].word);
2757@@ -2203,7 +2208,7 @@
2758 break;
2759
2760 case 13:
2761-#line 459 "/usr/homes/chet/src/bash/src/parse.y"
2762+#line 464 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2763 {
2764 source.filename = (yyvsp[(1) - (3)].word);
2765 redir.filename = (yyvsp[(3) - (3)].word);
2766@@ -2212,7 +2217,7 @@
2767 break;
2768
2769 case 14:
2770-#line 465 "/usr/homes/chet/src/bash/src/parse.y"
2771+#line 470 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2772 {
2773 source.dest = 1;
2774 redir.filename = (yyvsp[(2) - (2)].word);
2775@@ -2221,7 +2226,7 @@
2776 break;
2777
2778 case 15:
2779-#line 471 "/usr/homes/chet/src/bash/src/parse.y"
2780+#line 476 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2781 {
2782 source.dest = (yyvsp[(1) - (3)].number);
2783 redir.filename = (yyvsp[(3) - (3)].word);
2784@@ -2230,7 +2235,7 @@
2785 break;
2786
2787 case 16:
2788-#line 477 "/usr/homes/chet/src/bash/src/parse.y"
2789+#line 482 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2790 {
2791 source.filename = (yyvsp[(1) - (3)].word);
2792 redir.filename = (yyvsp[(3) - (3)].word);
2793@@ -2239,7 +2244,7 @@
2794 break;
2795
2796 case 17:
2797-#line 483 "/usr/homes/chet/src/bash/src/parse.y"
2798+#line 488 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2799 {
2800 source.dest = 1;
2801 redir.filename = (yyvsp[(2) - (2)].word);
2802@@ -2248,7 +2253,7 @@
2803 break;
2804
2805 case 18:
2806-#line 489 "/usr/homes/chet/src/bash/src/parse.y"
2807+#line 494 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2808 {
2809 source.dest = (yyvsp[(1) - (3)].number);
2810 redir.filename = (yyvsp[(3) - (3)].word);
2811@@ -2257,7 +2262,7 @@
2812 break;
2813
2814 case 19:
2815-#line 495 "/usr/homes/chet/src/bash/src/parse.y"
2816+#line 500 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2817 {
2818 source.filename = (yyvsp[(1) - (3)].word);
2819 redir.filename = (yyvsp[(3) - (3)].word);
2820@@ -2266,7 +2271,7 @@
2821 break;
2822
2823 case 20:
2824-#line 501 "/usr/homes/chet/src/bash/src/parse.y"
2825+#line 506 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2826 {
2827 source.dest = 0;
2828 redir.filename = (yyvsp[(2) - (2)].word);
2829@@ -2275,7 +2280,7 @@
2830 break;
2831
2832 case 21:
2833-#line 507 "/usr/homes/chet/src/bash/src/parse.y"
2834+#line 512 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2835 {
2836 source.dest = (yyvsp[(1) - (3)].number);
2837 redir.filename = (yyvsp[(3) - (3)].word);
2838@@ -2284,7 +2289,7 @@
2839 break;
2840
2841 case 22:
2842-#line 513 "/usr/homes/chet/src/bash/src/parse.y"
2843+#line 518 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2844 {
2845 source.filename = (yyvsp[(1) - (3)].word);
2846 redir.filename = (yyvsp[(3) - (3)].word);
2847@@ -2293,67 +2298,67 @@
2848 break;
2849
2850 case 23:
2851-#line 519 "/usr/homes/chet/src/bash/src/parse.y"
2852+#line 524 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2853 {
2854 source.dest = 0;
2855 redir.filename = (yyvsp[(2) - (2)].word);
2856 (yyval.redirect) = make_redirection (source, r_reading_until, redir, 0);
2857- redir_stack[need_here_doc++] = (yyval.redirect);
2858+ push_heredoc ((yyval.redirect));
2859 }
2860 break;
2861
2862 case 24:
2863-#line 526 "/usr/homes/chet/src/bash/src/parse.y"
2864+#line 531 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2865 {
2866 source.dest = (yyvsp[(1) - (3)].number);
2867 redir.filename = (yyvsp[(3) - (3)].word);
2868 (yyval.redirect) = make_redirection (source, r_reading_until, redir, 0);
2869- redir_stack[need_here_doc++] = (yyval.redirect);
2870+ push_heredoc ((yyval.redirect));
2871 }
2872 break;
2873
2874 case 25:
2875-#line 533 "/usr/homes/chet/src/bash/src/parse.y"
2876+#line 538 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2877 {
2878 source.filename = (yyvsp[(1) - (3)].word);
2879 redir.filename = (yyvsp[(3) - (3)].word);
2880 (yyval.redirect) = make_redirection (source, r_reading_until, redir, REDIR_VARASSIGN);
2881- redir_stack[need_here_doc++] = (yyval.redirect);
2882+ push_heredoc ((yyval.redirect));
2883 }
2884 break;
2885
2886 case 26:
2887-#line 540 "/usr/homes/chet/src/bash/src/parse.y"
2888+#line 545 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2889 {
2890 source.dest = 0;
2891 redir.filename = (yyvsp[(2) - (2)].word);
2892 (yyval.redirect) = make_redirection (source, r_deblank_reading_until, redir, 0);
2893- redir_stack[need_here_doc++] = (yyval.redirect);
2894+ push_heredoc ((yyval.redirect));
2895 }
2896 break;
2897
2898 case 27:
2899-#line 547 "/usr/homes/chet/src/bash/src/parse.y"
2900+#line 552 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2901 {
2902 source.dest = (yyvsp[(1) - (3)].number);
2903 redir.filename = (yyvsp[(3) - (3)].word);
2904 (yyval.redirect) = make_redirection (source, r_deblank_reading_until, redir, 0);
2905- redir_stack[need_here_doc++] = (yyval.redirect);
2906+ push_heredoc ((yyval.redirect));
2907 }
2908 break;
2909
2910 case 28:
2911-#line 554 "/usr/homes/chet/src/bash/src/parse.y"
2912+#line 559 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2913 {
2914 source.filename = (yyvsp[(1) - (3)].word);
2915 redir.filename = (yyvsp[(3) - (3)].word);
2916 (yyval.redirect) = make_redirection (source, r_deblank_reading_until, redir, REDIR_VARASSIGN);
2917- redir_stack[need_here_doc++] = (yyval.redirect);
2918+ push_heredoc ((yyval.redirect));
2919 }
2920 break;
2921
2922 case 29:
2923-#line 561 "/usr/homes/chet/src/bash/src/parse.y"
2924+#line 566 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2925 {
2926 source.dest = 0;
2927 redir.filename = (yyvsp[(2) - (2)].word);
2928@@ -2362,7 +2367,7 @@
2929 break;
2930
2931 case 30:
2932-#line 567 "/usr/homes/chet/src/bash/src/parse.y"
2933+#line 572 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2934 {
2935 source.dest = (yyvsp[(1) - (3)].number);
2936 redir.filename = (yyvsp[(3) - (3)].word);
2937@@ -2371,7 +2376,7 @@
2938 break;
2939
2940 case 31:
2941-#line 573 "/usr/homes/chet/src/bash/src/parse.y"
2942+#line 578 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2943 {
2944 source.filename = (yyvsp[(1) - (3)].word);
2945 redir.filename = (yyvsp[(3) - (3)].word);
2946@@ -2380,7 +2385,7 @@
2947 break;
2948
2949 case 32:
2950-#line 579 "/usr/homes/chet/src/bash/src/parse.y"
2951+#line 584 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2952 {
2953 source.dest = 0;
2954 redir.dest = (yyvsp[(2) - (2)].number);
2955@@ -2389,7 +2394,7 @@
2956 break;
2957
2958 case 33:
2959-#line 585 "/usr/homes/chet/src/bash/src/parse.y"
2960+#line 590 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2961 {
2962 source.dest = (yyvsp[(1) - (3)].number);
2963 redir.dest = (yyvsp[(3) - (3)].number);
2964@@ -2398,7 +2403,7 @@
2965 break;
2966
2967 case 34:
2968-#line 591 "/usr/homes/chet/src/bash/src/parse.y"
2969+#line 596 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2970 {
2971 source.filename = (yyvsp[(1) - (3)].word);
2972 redir.dest = (yyvsp[(3) - (3)].number);
2973@@ -2407,7 +2412,7 @@
2974 break;
2975
2976 case 35:
2977-#line 597 "/usr/homes/chet/src/bash/src/parse.y"
2978+#line 602 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2979 {
2980 source.dest = 1;
2981 redir.dest = (yyvsp[(2) - (2)].number);
2982@@ -2416,7 +2421,7 @@
2983 break;
2984
2985 case 36:
2986-#line 603 "/usr/homes/chet/src/bash/src/parse.y"
2987+#line 608 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2988 {
2989 source.dest = (yyvsp[(1) - (3)].number);
2990 redir.dest = (yyvsp[(3) - (3)].number);
2991@@ -2425,7 +2430,7 @@
2992 break;
2993
2994 case 37:
2995-#line 609 "/usr/homes/chet/src/bash/src/parse.y"
2996+#line 614 "/usr/src/local/bash/bash-4.3-patched/parse.y"
2997 {
2998 source.filename = (yyvsp[(1) - (3)].word);
2999 redir.dest = (yyvsp[(3) - (3)].number);
3000@@ -2434,7 +2439,7 @@
3001 break;
3002
3003 case 38:
3004-#line 615 "/usr/homes/chet/src/bash/src/parse.y"
3005+#line 620 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3006 {
3007 source.dest = 0;
3008 redir.filename = (yyvsp[(2) - (2)].word);
3009@@ -2443,7 +2448,7 @@
3010 break;
3011
3012 case 39:
3013-#line 621 "/usr/homes/chet/src/bash/src/parse.y"
3014+#line 626 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3015 {
3016 source.dest = (yyvsp[(1) - (3)].number);
3017 redir.filename = (yyvsp[(3) - (3)].word);
3018@@ -2452,7 +2457,7 @@
3019 break;
3020
3021 case 40:
3022-#line 627 "/usr/homes/chet/src/bash/src/parse.y"
3023+#line 632 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3024 {
3025 source.filename = (yyvsp[(1) - (3)].word);
3026 redir.filename = (yyvsp[(3) - (3)].word);
3027@@ -2461,7 +2466,7 @@
3028 break;
3029
3030 case 41:
3031-#line 633 "/usr/homes/chet/src/bash/src/parse.y"
3032+#line 638 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3033 {
3034 source.dest = 1;
3035 redir.filename = (yyvsp[(2) - (2)].word);
3036@@ -2470,7 +2475,7 @@
3037 break;
3038
3039 case 42:
3040-#line 639 "/usr/homes/chet/src/bash/src/parse.y"
3041+#line 644 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3042 {
3043 source.dest = (yyvsp[(1) - (3)].number);
3044 redir.filename = (yyvsp[(3) - (3)].word);
3045@@ -2479,7 +2484,7 @@
3046 break;
3047
3048 case 43:
3049-#line 645 "/usr/homes/chet/src/bash/src/parse.y"
3050+#line 650 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3051 {
3052 source.filename = (yyvsp[(1) - (3)].word);
3053 redir.filename = (yyvsp[(3) - (3)].word);
3054@@ -2488,7 +2493,7 @@
3055 break;
3056
3057 case 44:
3058-#line 651 "/usr/homes/chet/src/bash/src/parse.y"
3059+#line 656 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3060 {
3061 source.dest = 1;
3062 redir.dest = 0;
3063@@ -2497,7 +2502,7 @@
3064 break;
3065
3066 case 45:
3067-#line 657 "/usr/homes/chet/src/bash/src/parse.y"
3068+#line 662 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3069 {
3070 source.dest = (yyvsp[(1) - (3)].number);
3071 redir.dest = 0;
3072@@ -2506,7 +2511,7 @@
3073 break;
3074
3075 case 46:
3076-#line 663 "/usr/homes/chet/src/bash/src/parse.y"
3077+#line 668 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3078 {
3079 source.filename = (yyvsp[(1) - (3)].word);
3080 redir.dest = 0;
3081@@ -2515,7 +2520,7 @@
3082 break;
3083
3084 case 47:
3085-#line 669 "/usr/homes/chet/src/bash/src/parse.y"
3086+#line 674 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3087 {
3088 source.dest = 0;
3089 redir.dest = 0;
3090@@ -2524,7 +2529,7 @@
3091 break;
3092
3093 case 48:
3094-#line 675 "/usr/homes/chet/src/bash/src/parse.y"
3095+#line 680 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3096 {
3097 source.dest = (yyvsp[(1) - (3)].number);
3098 redir.dest = 0;
3099@@ -2533,7 +2538,7 @@
3100 break;
3101
3102 case 49:
3103-#line 681 "/usr/homes/chet/src/bash/src/parse.y"
3104+#line 686 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3105 {
3106 source.filename = (yyvsp[(1) - (3)].word);
3107 redir.dest = 0;
3108@@ -2542,7 +2547,7 @@
3109 break;
3110
3111 case 50:
3112-#line 687 "/usr/homes/chet/src/bash/src/parse.y"
3113+#line 692 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3114 {
3115 source.dest = 1;
3116 redir.filename = (yyvsp[(2) - (2)].word);
3117@@ -2551,7 +2556,7 @@
3118 break;
3119
3120 case 51:
3121-#line 693 "/usr/homes/chet/src/bash/src/parse.y"
3122+#line 698 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3123 {
3124 source.dest = 1;
3125 redir.filename = (yyvsp[(2) - (2)].word);
3126@@ -2560,29 +2565,29 @@
3127 break;
3128
3129 case 52:
3130-#line 701 "/usr/homes/chet/src/bash/src/parse.y"
3131+#line 706 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3132 { (yyval.element).word = (yyvsp[(1) - (1)].word); (yyval.element).redirect = 0; }
3133 break;
3134
3135 case 53:
3136-#line 703 "/usr/homes/chet/src/bash/src/parse.y"
3137+#line 708 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3138 { (yyval.element).word = (yyvsp[(1) - (1)].word); (yyval.element).redirect = 0; }
3139 break;
3140
3141 case 54:
3142-#line 705 "/usr/homes/chet/src/bash/src/parse.y"
3143+#line 710 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3144 { (yyval.element).redirect = (yyvsp[(1) - (1)].redirect); (yyval.element).word = 0; }
3145 break;
3146
3147 case 55:
3148-#line 709 "/usr/homes/chet/src/bash/src/parse.y"
3149+#line 714 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3150 {
3151 (yyval.redirect) = (yyvsp[(1) - (1)].redirect);
3152 }
3153 break;
3154
3155 case 56:
3156-#line 713 "/usr/homes/chet/src/bash/src/parse.y"
3157+#line 718 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3158 {
3159 register REDIRECT *t;
3160
3161@@ -2594,27 +2599,27 @@
3162 break;
3163
3164 case 57:
3165-#line 724 "/usr/homes/chet/src/bash/src/parse.y"
3166+#line 729 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3167 { (yyval.command) = make_simple_command ((yyvsp[(1) - (1)].element), (COMMAND *)NULL); }
3168 break;
3169
3170 case 58:
3171-#line 726 "/usr/homes/chet/src/bash/src/parse.y"
3172+#line 731 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3173 { (yyval.command) = make_simple_command ((yyvsp[(2) - (2)].element), (yyvsp[(1) - (2)].command)); }
3174 break;
3175
3176 case 59:
3177-#line 730 "/usr/homes/chet/src/bash/src/parse.y"
3178+#line 735 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3179 { (yyval.command) = clean_simple_command ((yyvsp[(1) - (1)].command)); }
3180 break;
3181
3182 case 60:
3183-#line 732 "/usr/homes/chet/src/bash/src/parse.y"
3184+#line 737 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3185 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3186 break;
3187
3188 case 61:
3189-#line 734 "/usr/homes/chet/src/bash/src/parse.y"
3190+#line 739 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3191 {
3192 COMMAND *tc;
3193
3194@@ -2633,72 +2638,72 @@
3195 break;
3196
3197 case 62:
3198-#line 750 "/usr/homes/chet/src/bash/src/parse.y"
3199+#line 755 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3200 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3201 break;
3202
3203 case 63:
3204-#line 752 "/usr/homes/chet/src/bash/src/parse.y"
3205+#line 757 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3206 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3207 break;
3208
3209 case 64:
3210-#line 756 "/usr/homes/chet/src/bash/src/parse.y"
3211+#line 761 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3212 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3213 break;
3214
3215 case 65:
3216-#line 758 "/usr/homes/chet/src/bash/src/parse.y"
3217+#line 763 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3218 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3219 break;
3220
3221 case 66:
3222-#line 760 "/usr/homes/chet/src/bash/src/parse.y"
3223+#line 765 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3224 { (yyval.command) = make_while_command ((yyvsp[(2) - (5)].command), (yyvsp[(4) - (5)].command)); }
3225 break;
3226
3227 case 67:
3228-#line 762 "/usr/homes/chet/src/bash/src/parse.y"
3229+#line 767 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3230 { (yyval.command) = make_until_command ((yyvsp[(2) - (5)].command), (yyvsp[(4) - (5)].command)); }
3231 break;
3232
3233 case 68:
3234-#line 764 "/usr/homes/chet/src/bash/src/parse.y"
3235+#line 769 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3236 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3237 break;
3238
3239 case 69:
3240-#line 766 "/usr/homes/chet/src/bash/src/parse.y"
3241+#line 771 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3242 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3243 break;
3244
3245 case 70:
3246-#line 768 "/usr/homes/chet/src/bash/src/parse.y"
3247+#line 773 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3248 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3249 break;
3250
3251 case 71:
3252-#line 770 "/usr/homes/chet/src/bash/src/parse.y"
3253+#line 775 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3254 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3255 break;
3256
3257 case 72:
3258-#line 772 "/usr/homes/chet/src/bash/src/parse.y"
3259+#line 777 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3260 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3261 break;
3262
3263 case 73:
3264-#line 774 "/usr/homes/chet/src/bash/src/parse.y"
3265+#line 779 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3266 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3267 break;
3268
3269 case 74:
3270-#line 776 "/usr/homes/chet/src/bash/src/parse.y"
3271+#line 781 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3272 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3273 break;
3274
3275 case 75:
3276-#line 780 "/usr/homes/chet/src/bash/src/parse.y"
3277+#line 785 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3278 {
3279 (yyval.command) = make_for_command ((yyvsp[(2) - (6)].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[(5) - (6)].command), word_lineno[word_top]);
3280 if (word_top > 0) word_top--;
3281@@ -2706,7 +2711,7 @@
3282 break;
3283
3284 case 76:
3285-#line 785 "/usr/homes/chet/src/bash/src/parse.y"
3286+#line 790 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3287 {
3288 (yyval.command) = make_for_command ((yyvsp[(2) - (6)].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[(5) - (6)].command), word_lineno[word_top]);
3289 if (word_top > 0) word_top--;
3290@@ -2714,7 +2719,7 @@
3291 break;
3292
3293 case 77:
3294-#line 790 "/usr/homes/chet/src/bash/src/parse.y"
3295+#line 795 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3296 {
3297 (yyval.command) = make_for_command ((yyvsp[(2) - (7)].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[(6) - (7)].command), word_lineno[word_top]);
3298 if (word_top > 0) word_top--;
3299@@ -2722,7 +2727,7 @@
3300 break;
3301
3302 case 78:
3303-#line 795 "/usr/homes/chet/src/bash/src/parse.y"
3304+#line 800 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3305 {
3306 (yyval.command) = make_for_command ((yyvsp[(2) - (7)].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[(6) - (7)].command), word_lineno[word_top]);
3307 if (word_top > 0) word_top--;
3308@@ -2730,7 +2735,7 @@
3309 break;
3310
3311 case 79:
3312-#line 800 "/usr/homes/chet/src/bash/src/parse.y"
3313+#line 805 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3314 {
3315 (yyval.command) = make_for_command ((yyvsp[(2) - (10)].word), REVERSE_LIST ((yyvsp[(5) - (10)].word_list), WORD_LIST *), (yyvsp[(9) - (10)].command), word_lineno[word_top]);
3316 if (word_top > 0) word_top--;
3317@@ -2738,7 +2743,7 @@
3318 break;
3319
3320 case 80:
3321-#line 805 "/usr/homes/chet/src/bash/src/parse.y"
3322+#line 810 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3323 {
3324 (yyval.command) = make_for_command ((yyvsp[(2) - (10)].word), REVERSE_LIST ((yyvsp[(5) - (10)].word_list), WORD_LIST *), (yyvsp[(9) - (10)].command), word_lineno[word_top]);
3325 if (word_top > 0) word_top--;
3326@@ -2746,7 +2751,7 @@
3327 break;
3328
3329 case 81:
3330-#line 810 "/usr/homes/chet/src/bash/src/parse.y"
3331+#line 815 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3332 {
3333 (yyval.command) = make_for_command ((yyvsp[(2) - (9)].word), (WORD_LIST *)NULL, (yyvsp[(8) - (9)].command), word_lineno[word_top]);
3334 if (word_top > 0) word_top--;
3335@@ -2754,7 +2759,7 @@
3336 break;
3337
3338 case 82:
3339-#line 815 "/usr/homes/chet/src/bash/src/parse.y"
3340+#line 820 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3341 {
3342 (yyval.command) = make_for_command ((yyvsp[(2) - (9)].word), (WORD_LIST *)NULL, (yyvsp[(8) - (9)].command), word_lineno[word_top]);
3343 if (word_top > 0) word_top--;
3344@@ -2762,7 +2767,7 @@
3345 break;
3346
3347 case 83:
3348-#line 822 "/usr/homes/chet/src/bash/src/parse.y"
3349+#line 827 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3350 {
3351 (yyval.command) = make_arith_for_command ((yyvsp[(2) - (7)].word_list), (yyvsp[(6) - (7)].command), arith_for_lineno);
3352 if (word_top > 0) word_top--;
3353@@ -2770,7 +2775,7 @@
3354 break;
3355
3356 case 84:
3357-#line 827 "/usr/homes/chet/src/bash/src/parse.y"
3358+#line 832 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3359 {
3360 (yyval.command) = make_arith_for_command ((yyvsp[(2) - (7)].word_list), (yyvsp[(6) - (7)].command), arith_for_lineno);
3361 if (word_top > 0) word_top--;
3362@@ -2778,7 +2783,7 @@
3363 break;
3364
3365 case 85:
3366-#line 832 "/usr/homes/chet/src/bash/src/parse.y"
3367+#line 837 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3368 {
3369 (yyval.command) = make_arith_for_command ((yyvsp[(2) - (5)].word_list), (yyvsp[(4) - (5)].command), arith_for_lineno);
3370 if (word_top > 0) word_top--;
3371@@ -2786,7 +2791,7 @@
3372 break;
3373
3374 case 86:
3375-#line 837 "/usr/homes/chet/src/bash/src/parse.y"
3376+#line 842 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3377 {
3378 (yyval.command) = make_arith_for_command ((yyvsp[(2) - (5)].word_list), (yyvsp[(4) - (5)].command), arith_for_lineno);
3379 if (word_top > 0) word_top--;
3380@@ -2794,7 +2799,7 @@
3381 break;
3382
3383 case 87:
3384-#line 844 "/usr/homes/chet/src/bash/src/parse.y"
3385+#line 849 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3386 {
3387 (yyval.command) = make_select_command ((yyvsp[(2) - (6)].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[(5) - (6)].command), word_lineno[word_top]);
3388 if (word_top > 0) word_top--;
3389@@ -2802,7 +2807,7 @@
3390 break;
3391
3392 case 88:
3393-#line 849 "/usr/homes/chet/src/bash/src/parse.y"
3394+#line 854 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3395 {
3396 (yyval.command) = make_select_command ((yyvsp[(2) - (6)].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[(5) - (6)].command), word_lineno[word_top]);
3397 if (word_top > 0) word_top--;
3398@@ -2810,7 +2815,7 @@
3399 break;
3400
3401 case 89:
3402-#line 854 "/usr/homes/chet/src/bash/src/parse.y"
3403+#line 859 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3404 {
3405 (yyval.command) = make_select_command ((yyvsp[(2) - (7)].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[(6) - (7)].command), word_lineno[word_top]);
3406 if (word_top > 0) word_top--;
3407@@ -2818,7 +2823,7 @@
3408 break;
3409
3410 case 90:
3411-#line 859 "/usr/homes/chet/src/bash/src/parse.y"
3412+#line 864 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3413 {
3414 (yyval.command) = make_select_command ((yyvsp[(2) - (7)].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[(6) - (7)].command), word_lineno[word_top]);
3415 if (word_top > 0) word_top--;
3416@@ -2826,7 +2831,7 @@
3417 break;
3418
3419 case 91:
3420-#line 864 "/usr/homes/chet/src/bash/src/parse.y"
3421+#line 869 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3422 {
3423 (yyval.command) = make_select_command ((yyvsp[(2) - (10)].word), REVERSE_LIST ((yyvsp[(5) - (10)].word_list), WORD_LIST *), (yyvsp[(9) - (10)].command), word_lineno[word_top]);
3424 if (word_top > 0) word_top--;
3425@@ -2834,7 +2839,7 @@
3426 break;
3427
3428 case 92:
3429-#line 869 "/usr/homes/chet/src/bash/src/parse.y"
3430+#line 874 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3431 {
3432 (yyval.command) = make_select_command ((yyvsp[(2) - (10)].word), REVERSE_LIST ((yyvsp[(5) - (10)].word_list), WORD_LIST *), (yyvsp[(9) - (10)].command), word_lineno[word_top]);
3433 if (word_top > 0) word_top--;
3434@@ -2842,7 +2847,7 @@
3435 break;
3436
3437 case 93:
3438-#line 876 "/usr/homes/chet/src/bash/src/parse.y"
3439+#line 881 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3440 {
3441 (yyval.command) = make_case_command ((yyvsp[(2) - (6)].word), (PATTERN_LIST *)NULL, word_lineno[word_top]);
3442 if (word_top > 0) word_top--;
3443@@ -2850,7 +2855,7 @@
3444 break;
3445
3446 case 94:
3447-#line 881 "/usr/homes/chet/src/bash/src/parse.y"
3448+#line 886 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3449 {
3450 (yyval.command) = make_case_command ((yyvsp[(2) - (7)].word), (yyvsp[(5) - (7)].pattern), word_lineno[word_top]);
3451 if (word_top > 0) word_top--;
3452@@ -2858,7 +2863,7 @@
3453 break;
3454
3455 case 95:
3456-#line 886 "/usr/homes/chet/src/bash/src/parse.y"
3457+#line 891 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3458 {
3459 (yyval.command) = make_case_command ((yyvsp[(2) - (6)].word), (yyvsp[(5) - (6)].pattern), word_lineno[word_top]);
3460 if (word_top > 0) word_top--;
3461@@ -2866,27 +2871,27 @@
3462 break;
3463
3464 case 96:
3465-#line 893 "/usr/homes/chet/src/bash/src/parse.y"
3466+#line 898 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3467 { (yyval.command) = make_function_def ((yyvsp[(1) - (5)].word), (yyvsp[(5) - (5)].command), function_dstart, function_bstart); }
3468 break;
3469
3470 case 97:
3471-#line 896 "/usr/homes/chet/src/bash/src/parse.y"
3472+#line 901 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3473 { (yyval.command) = make_function_def ((yyvsp[(2) - (6)].word), (yyvsp[(6) - (6)].command), function_dstart, function_bstart); }
3474 break;
3475
3476 case 98:
3477-#line 899 "/usr/homes/chet/src/bash/src/parse.y"
3478+#line 904 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3479 { (yyval.command) = make_function_def ((yyvsp[(2) - (4)].word), (yyvsp[(4) - (4)].command), function_dstart, function_bstart); }
3480 break;
3481
3482 case 99:
3483-#line 903 "/usr/homes/chet/src/bash/src/parse.y"
3484+#line 908 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3485 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3486 break;
3487
3488 case 100:
3489-#line 905 "/usr/homes/chet/src/bash/src/parse.y"
3490+#line 910 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3491 {
3492 COMMAND *tc;
3493
3494@@ -2918,7 +2923,7 @@
3495 break;
3496
3497 case 101:
3498-#line 936 "/usr/homes/chet/src/bash/src/parse.y"
3499+#line 941 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3500 {
3501 (yyval.command) = make_subshell_command ((yyvsp[(2) - (3)].command));
3502 (yyval.command)->flags |= CMD_WANT_SUBSHELL;
3503@@ -2926,7 +2931,7 @@
3504 break;
3505
3506 case 102:
3507-#line 943 "/usr/homes/chet/src/bash/src/parse.y"
3508+#line 948 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3509 {
3510 (yyval.command) = make_coproc_command ("COPROC", (yyvsp[(2) - (2)].command));
3511 (yyval.command)->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;
3512@@ -2934,7 +2939,7 @@
3513 break;
3514
3515 case 103:
3516-#line 948 "/usr/homes/chet/src/bash/src/parse.y"
3517+#line 953 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3518 {
3519 COMMAND *tc;
3520
3521@@ -2954,7 +2959,7 @@
3522 break;
3523
3524 case 104:
3525-#line 965 "/usr/homes/chet/src/bash/src/parse.y"
3526+#line 970 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3527 {
3528 (yyval.command) = make_coproc_command ((yyvsp[(2) - (3)].word)->word, (yyvsp[(3) - (3)].command));
3529 (yyval.command)->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;
3530@@ -2962,7 +2967,7 @@
3531 break;
3532
3533 case 105:
3534-#line 970 "/usr/homes/chet/src/bash/src/parse.y"
3535+#line 975 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3536 {
3537 COMMAND *tc;
3538
3539@@ -2982,7 +2987,7 @@
3540 break;
3541
3542 case 106:
3543-#line 987 "/usr/homes/chet/src/bash/src/parse.y"
3544+#line 992 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3545 {
3546 (yyval.command) = make_coproc_command ("COPROC", clean_simple_command ((yyvsp[(2) - (2)].command)));
3547 (yyval.command)->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;
3548@@ -2990,117 +2995,117 @@
3549 break;
3550
3551 case 107:
3552-#line 994 "/usr/homes/chet/src/bash/src/parse.y"
3553+#line 999 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3554 { (yyval.command) = make_if_command ((yyvsp[(2) - (5)].command), (yyvsp[(4) - (5)].command), (COMMAND *)NULL); }
3555 break;
3556
3557 case 108:
3558-#line 996 "/usr/homes/chet/src/bash/src/parse.y"
3559+#line 1001 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3560 { (yyval.command) = make_if_command ((yyvsp[(2) - (7)].command), (yyvsp[(4) - (7)].command), (yyvsp[(6) - (7)].command)); }
3561 break;
3562
3563 case 109:
3564-#line 998 "/usr/homes/chet/src/bash/src/parse.y"
3565+#line 1003 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3566 { (yyval.command) = make_if_command ((yyvsp[(2) - (6)].command), (yyvsp[(4) - (6)].command), (yyvsp[(5) - (6)].command)); }
3567 break;
3568
3569 case 110:
3570-#line 1003 "/usr/homes/chet/src/bash/src/parse.y"
3571+#line 1008 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3572 { (yyval.command) = make_group_command ((yyvsp[(2) - (3)].command)); }
3573 break;
3574
3575 case 111:
3576-#line 1007 "/usr/homes/chet/src/bash/src/parse.y"
3577+#line 1012 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3578 { (yyval.command) = make_arith_command ((yyvsp[(1) - (1)].word_list)); }
3579 break;
3580
3581 case 112:
3582-#line 1011 "/usr/homes/chet/src/bash/src/parse.y"
3583+#line 1016 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3584 { (yyval.command) = (yyvsp[(2) - (3)].command); }
3585 break;
3586
3587 case 113:
3588-#line 1015 "/usr/homes/chet/src/bash/src/parse.y"
3589+#line 1020 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3590 { (yyval.command) = make_if_command ((yyvsp[(2) - (4)].command), (yyvsp[(4) - (4)].command), (COMMAND *)NULL); }
3591 break;
3592
3593 case 114:
3594-#line 1017 "/usr/homes/chet/src/bash/src/parse.y"
3595+#line 1022 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3596 { (yyval.command) = make_if_command ((yyvsp[(2) - (6)].command), (yyvsp[(4) - (6)].command), (yyvsp[(6) - (6)].command)); }
3597 break;
3598
3599 case 115:
3600-#line 1019 "/usr/homes/chet/src/bash/src/parse.y"
3601+#line 1024 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3602 { (yyval.command) = make_if_command ((yyvsp[(2) - (5)].command), (yyvsp[(4) - (5)].command), (yyvsp[(5) - (5)].command)); }
3603 break;
3604
3605 case 117:
3606-#line 1024 "/usr/homes/chet/src/bash/src/parse.y"
3607+#line 1029 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3608 { (yyvsp[(2) - (2)].pattern)->next = (yyvsp[(1) - (2)].pattern); (yyval.pattern) = (yyvsp[(2) - (2)].pattern); }
3609 break;
3610
3611 case 118:
3612-#line 1028 "/usr/homes/chet/src/bash/src/parse.y"
3613+#line 1033 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3614 { (yyval.pattern) = make_pattern_list ((yyvsp[(2) - (4)].word_list), (yyvsp[(4) - (4)].command)); }
3615 break;
3616
3617 case 119:
3618-#line 1030 "/usr/homes/chet/src/bash/src/parse.y"
3619+#line 1035 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3620 { (yyval.pattern) = make_pattern_list ((yyvsp[(2) - (4)].word_list), (COMMAND *)NULL); }
3621 break;
3622
3623 case 120:
3624-#line 1032 "/usr/homes/chet/src/bash/src/parse.y"
3625+#line 1037 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3626 { (yyval.pattern) = make_pattern_list ((yyvsp[(3) - (5)].word_list), (yyvsp[(5) - (5)].command)); }
3627 break;
3628
3629 case 121:
3630-#line 1034 "/usr/homes/chet/src/bash/src/parse.y"
3631+#line 1039 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3632 { (yyval.pattern) = make_pattern_list ((yyvsp[(3) - (5)].word_list), (COMMAND *)NULL); }
3633 break;
3634
3635 case 122:
3636-#line 1038 "/usr/homes/chet/src/bash/src/parse.y"
3637+#line 1043 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3638 { (yyval.pattern) = (yyvsp[(1) - (2)].pattern); }
3639 break;
3640
3641 case 123:
3642-#line 1040 "/usr/homes/chet/src/bash/src/parse.y"
3643+#line 1045 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3644 { (yyvsp[(2) - (3)].pattern)->next = (yyvsp[(1) - (3)].pattern); (yyval.pattern) = (yyvsp[(2) - (3)].pattern); }
3645 break;
3646
3647 case 124:
3648-#line 1042 "/usr/homes/chet/src/bash/src/parse.y"
3649+#line 1047 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3650 { (yyvsp[(1) - (2)].pattern)->flags |= CASEPAT_FALLTHROUGH; (yyval.pattern) = (yyvsp[(1) - (2)].pattern); }
3651 break;
3652
3653 case 125:
3654-#line 1044 "/usr/homes/chet/src/bash/src/parse.y"
3655+#line 1049 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3656 { (yyvsp[(2) - (3)].pattern)->flags |= CASEPAT_FALLTHROUGH; (yyvsp[(2) - (3)].pattern)->next = (yyvsp[(1) - (3)].pattern); (yyval.pattern) = (yyvsp[(2) - (3)].pattern); }
3657 break;
3658
3659 case 126:
3660-#line 1046 "/usr/homes/chet/src/bash/src/parse.y"
3661+#line 1051 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3662 { (yyvsp[(1) - (2)].pattern)->flags |= CASEPAT_TESTNEXT; (yyval.pattern) = (yyvsp[(1) - (2)].pattern); }
3663 break;
3664
3665 case 127:
3666-#line 1048 "/usr/homes/chet/src/bash/src/parse.y"
3667+#line 1053 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3668 { (yyvsp[(2) - (3)].pattern)->flags |= CASEPAT_TESTNEXT; (yyvsp[(2) - (3)].pattern)->next = (yyvsp[(1) - (3)].pattern); (yyval.pattern) = (yyvsp[(2) - (3)].pattern); }
3669 break;
3670
3671 case 128:
3672-#line 1052 "/usr/homes/chet/src/bash/src/parse.y"
3673+#line 1057 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3674 { (yyval.word_list) = make_word_list ((yyvsp[(1) - (1)].word), (WORD_LIST *)NULL); }
3675 break;
3676
3677 case 129:
3678-#line 1054 "/usr/homes/chet/src/bash/src/parse.y"
3679+#line 1059 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3680 { (yyval.word_list) = make_word_list ((yyvsp[(3) - (3)].word), (yyvsp[(1) - (3)].word_list)); }
3681 break;
3682
3683 case 130:
3684-#line 1063 "/usr/homes/chet/src/bash/src/parse.y"
3685+#line 1068 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3686 {
3687 (yyval.command) = (yyvsp[(2) - (2)].command);
3688 if (need_here_doc)
3689@@ -3109,14 +3114,14 @@
3690 break;
3691
3692 case 132:
3693-#line 1072 "/usr/homes/chet/src/bash/src/parse.y"
3694+#line 1077 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3695 {
3696 (yyval.command) = (yyvsp[(2) - (2)].command);
3697 }
3698 break;
3699
3700 case 134:
3701-#line 1079 "/usr/homes/chet/src/bash/src/parse.y"
3702+#line 1084 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3703 {
3704 if ((yyvsp[(1) - (3)].command)->type == cm_connection)
3705 (yyval.command) = connect_async_list ((yyvsp[(1) - (3)].command), (COMMAND *)NULL, '&');
3706@@ -3126,17 +3131,17 @@
3707 break;
3708
3709 case 136:
3710-#line 1090 "/usr/homes/chet/src/bash/src/parse.y"
3711+#line 1095 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3712 { (yyval.command) = command_connect ((yyvsp[(1) - (4)].command), (yyvsp[(4) - (4)].command), AND_AND); }
3713 break;
3714
3715 case 137:
3716-#line 1092 "/usr/homes/chet/src/bash/src/parse.y"
3717+#line 1097 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3718 { (yyval.command) = command_connect ((yyvsp[(1) - (4)].command), (yyvsp[(4) - (4)].command), OR_OR); }
3719 break;
3720
3721 case 138:
3722-#line 1094 "/usr/homes/chet/src/bash/src/parse.y"
3723+#line 1099 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3724 {
3725 if ((yyvsp[(1) - (4)].command)->type == cm_connection)
3726 (yyval.command) = connect_async_list ((yyvsp[(1) - (4)].command), (yyvsp[(4) - (4)].command), '&');
3727@@ -3146,37 +3151,37 @@
3728 break;
3729
3730 case 139:
3731-#line 1101 "/usr/homes/chet/src/bash/src/parse.y"
3732+#line 1106 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3733 { (yyval.command) = command_connect ((yyvsp[(1) - (4)].command), (yyvsp[(4) - (4)].command), ';'); }
3734 break;
3735
3736 case 140:
3737-#line 1103 "/usr/homes/chet/src/bash/src/parse.y"
3738+#line 1108 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3739 { (yyval.command) = command_connect ((yyvsp[(1) - (4)].command), (yyvsp[(4) - (4)].command), ';'); }
3740 break;
3741
3742 case 141:
3743-#line 1105 "/usr/homes/chet/src/bash/src/parse.y"
3744+#line 1110 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3745 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3746 break;
3747
3748 case 144:
3749-#line 1113 "/usr/homes/chet/src/bash/src/parse.y"
3750+#line 1118 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3751 { (yyval.number) = '\n'; }
3752 break;
3753
3754 case 145:
3755-#line 1115 "/usr/homes/chet/src/bash/src/parse.y"
3756+#line 1120 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3757 { (yyval.number) = ';'; }
3758 break;
3759
3760 case 146:
3761-#line 1117 "/usr/homes/chet/src/bash/src/parse.y"
3762+#line 1122 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3763 { (yyval.number) = yacc_EOF; }
3764 break;
3765
3766 case 149:
3767-#line 1131 "/usr/homes/chet/src/bash/src/parse.y"
3768+#line 1136 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3769 {
3770 (yyval.command) = (yyvsp[(1) - (1)].command);
3771 if (need_here_doc)
3772@@ -3192,7 +3197,7 @@
3773 break;
3774
3775 case 150:
3776-#line 1144 "/usr/homes/chet/src/bash/src/parse.y"
3777+#line 1149 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3778 {
3779 if ((yyvsp[(1) - (2)].command)->type == cm_connection)
3780 (yyval.command) = connect_async_list ((yyvsp[(1) - (2)].command), (COMMAND *)NULL, '&');
3781@@ -3211,7 +3216,7 @@
3782 break;
3783
3784 case 151:
3785-#line 1160 "/usr/homes/chet/src/bash/src/parse.y"
3786+#line 1165 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3787 {
3788 (yyval.command) = (yyvsp[(1) - (2)].command);
3789 if (need_here_doc)
3790@@ -3227,17 +3232,17 @@
3791 break;
3792
3793 case 152:
3794-#line 1175 "/usr/homes/chet/src/bash/src/parse.y"
3795+#line 1180 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3796 { (yyval.command) = command_connect ((yyvsp[(1) - (4)].command), (yyvsp[(4) - (4)].command), AND_AND); }
3797 break;
3798
3799 case 153:
3800-#line 1177 "/usr/homes/chet/src/bash/src/parse.y"
3801+#line 1182 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3802 { (yyval.command) = command_connect ((yyvsp[(1) - (4)].command), (yyvsp[(4) - (4)].command), OR_OR); }
3803 break;
3804
3805 case 154:
3806-#line 1179 "/usr/homes/chet/src/bash/src/parse.y"
3807+#line 1184 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3808 {
3809 if ((yyvsp[(1) - (3)].command)->type == cm_connection)
3810 (yyval.command) = connect_async_list ((yyvsp[(1) - (3)].command), (yyvsp[(3) - (3)].command), '&');
3811@@ -3247,22 +3252,22 @@
3812 break;
3813
3814 case 155:
3815-#line 1186 "/usr/homes/chet/src/bash/src/parse.y"
3816+#line 1191 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3817 { (yyval.command) = command_connect ((yyvsp[(1) - (3)].command), (yyvsp[(3) - (3)].command), ';'); }
3818 break;
3819
3820 case 156:
3821-#line 1189 "/usr/homes/chet/src/bash/src/parse.y"
3822+#line 1194 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3823 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3824 break;
3825
3826 case 157:
3827-#line 1193 "/usr/homes/chet/src/bash/src/parse.y"
3828+#line 1198 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3829 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3830 break;
3831
3832 case 158:
3833-#line 1195 "/usr/homes/chet/src/bash/src/parse.y"
3834+#line 1200 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3835 {
3836 if ((yyvsp[(2) - (2)].command))
3837 (yyvsp[(2) - (2)].command)->flags ^= CMD_INVERT_RETURN; /* toggle */
3838@@ -3271,7 +3276,7 @@
3839 break;
3840
3841 case 159:
3842-#line 1201 "/usr/homes/chet/src/bash/src/parse.y"
3843+#line 1206 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3844 {
3845 if ((yyvsp[(2) - (2)].command))
3846 (yyvsp[(2) - (2)].command)->flags |= (yyvsp[(1) - (2)].number);
3847@@ -3280,7 +3285,7 @@
3848 break;
3849
3850 case 160:
3851-#line 1207 "/usr/homes/chet/src/bash/src/parse.y"
3852+#line 1212 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3853 {
3854 ELEMENT x;
3855
3856@@ -3300,7 +3305,7 @@
3857 break;
3858
3859 case 161:
3860-#line 1224 "/usr/homes/chet/src/bash/src/parse.y"
3861+#line 1229 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3862 {
3863 ELEMENT x;
3864
3865@@ -3321,12 +3326,12 @@
3866 break;
3867
3868 case 162:
3869-#line 1244 "/usr/homes/chet/src/bash/src/parse.y"
3870+#line 1249 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3871 { (yyval.command) = command_connect ((yyvsp[(1) - (4)].command), (yyvsp[(4) - (4)].command), '|'); }
3872 break;
3873
3874 case 163:
3875-#line 1246 "/usr/homes/chet/src/bash/src/parse.y"
3876+#line 1251 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3877 {
3878 /* Make cmd1 |& cmd2 equivalent to cmd1 2>&1 | cmd2 */
3879 COMMAND *tc;
3880@@ -3352,28 +3357,28 @@
3881 break;
3882
3883 case 164:
3884-#line 1269 "/usr/homes/chet/src/bash/src/parse.y"
3885+#line 1274 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3886 { (yyval.command) = (yyvsp[(1) - (1)].command); }
3887 break;
3888
3889 case 165:
3890-#line 1273 "/usr/homes/chet/src/bash/src/parse.y"
3891+#line 1278 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3892 { (yyval.number) = CMD_TIME_PIPELINE; }
3893 break;
3894
3895 case 166:
3896-#line 1275 "/usr/homes/chet/src/bash/src/parse.y"
3897+#line 1280 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3898 { (yyval.number) = CMD_TIME_PIPELINE|CMD_TIME_POSIX; }
3899 break;
3900
3901 case 167:
3902-#line 1277 "/usr/homes/chet/src/bash/src/parse.y"
3903+#line 1282 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3904 { (yyval.number) = CMD_TIME_PIPELINE|CMD_TIME_POSIX; }
3905 break;
3906
3907
3908 /* Line 1267 of yacc.c. */
3909-#line 3377 "y.tab.c"
3910+#line 3382 "y.tab.c"
3911 default: break;
3912 }
3913 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
3914@@ -3587,7 +3592,7 @@
3915 }
3916
3917
3918-#line 1279 "/usr/homes/chet/src/bash/src/parse.y"
3919+#line 1284 "/usr/src/local/bash/bash-4.3-patched/parse.y"
3920
3921
3922 /* Initial size to allocate for tokens, and the
3923@@ -4736,7 +4741,7 @@
3924 not already end in an EOF character. */
3925 if (shell_input_line_terminator != EOF)
3926 {
3927- if (shell_input_line_size < SIZE_MAX && shell_input_line_len > shell_input_line_size - 3)
3928+ if (shell_input_line_size < SIZE_MAX-3 && (shell_input_line_len+3 > shell_input_line_size))
3929 shell_input_line = (char *)xrealloc (shell_input_line,
3930 1 + (shell_input_line_size += 2));
3931
3932@@ -4845,6 +4850,16 @@
3933 eol_ungetc_lookahead = c;
3934 }
3935
3936+char *
3937+parser_remaining_input ()
3938+{
3939+ if (shell_input_line == 0)
3940+ return 0;
3941+ if (shell_input_line_index < 0 || shell_input_line_index >= shell_input_line_len)
3942+ return '\0'; /* XXX */
3943+ return (shell_input_line + shell_input_line_index);
3944+}
3945+
3946 #ifdef INCLUDE_UNUSED
3947 /* Back the input pointer up by one, effectively `ungetting' a character. */
3948 static void
3949@@ -4948,13 +4963,28 @@
3950 which allow ESAC to be the next one read. */
3951 static int esacs_needed_count;
3952
3953+static void
3954+push_heredoc (r)
3955+ REDIRECT *r;
3956+{
3957+ if (need_here_doc >= HEREDOC_MAX)
3958+ {
3959+ last_command_exit_value = EX_BADUSAGE;
3960+ need_here_doc = 0;
3961+ report_syntax_error (_("maximum here-document count exceeded"));
3962+ reset_parser ();
3963+ exit_shell (last_command_exit_value);
3964+ }
3965+ redir_stack[need_here_doc++] = r;
3966+}
3967+
3968 void
3969 gather_here_documents ()
3970 {
3971 int r;
3972
3973 r = 0;
3974- while (need_here_doc)
3975+ while (need_here_doc > 0)
3976 {
3977 parser_state |= PST_HEREDOC;
3978 make_here_document (redir_stack[r++], line_number);
3979@@ -5265,6 +5295,8 @@
3980 FREE (word_desc_to_read);
3981 word_desc_to_read = (WORD_DESC *)NULL;
3982
3983+ eol_ungetc_lookahead = 0;
3984+
3985 current_token = '\n'; /* XXX */
3986 last_read_token = '\n';
3987 token_to_read = '\n';
3988@@ -5710,7 +5742,7 @@
3989 within a double-quoted ${...} construct "an even number of
3990 unescaped double-quotes or single-quotes, if any, shall occur." */
3991 /* This was changed in Austin Group Interp 221 */
3992- if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'')
3993+ if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && dolbrace_state != DOLBRACE_QUOTE2 && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'')
3994 continue;
3995
3996 /* Could also check open == '`' if we want to parse grouping constructs
3997@@ -6317,8 +6349,8 @@
3998 reset_parser ();
3999 /* reset_parser clears shell_input_line and associated variables */
4000 restore_input_line_state (&ls);
4001- if (interactive)
4002- token_to_read = 0;
4003+
4004+ token_to_read = 0;
4005
4006 /* Need to find how many characters parse_and_execute consumed, update
4007 *indp, if flags != 0, copy the portion of the string parsed into RET
4008@@ -8387,6 +8419,7 @@
4009
4010 ps->expand_aliases = expand_aliases;
4011 ps->echo_input_at_read = echo_input_at_read;
4012+ ps->need_here_doc = need_here_doc;
4013
4014 ps->token = token;
4015 ps->token_buffer_size = token_buffer_size;
4016@@ -8435,6 +8468,7 @@
4017
4018 expand_aliases = ps->expand_aliases;
4019 echo_input_at_read = ps->echo_input_at_read;
4020+ need_here_doc = ps->need_here_doc;
4021
4022 FREE (token);
4023 token = ps->token;
Note: See TracBrowser for help on using the repository browser.