source: npl/system/bash/bash-4.3-patches/bash43-010 @ f9ce31e

perl-5.22
Last change on this file since f9ce31e was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 5.2 KB
Line 
1                             BASH PATCH REPORT
2                             =================
3
4Bash-Release:   4.3
5Patch-ID:       bash43-010
6
7Bug-Reported-by:        Albert Shih <Albert.Shih@obspm.fr>
8Bug-Reference-ID:       Wed, 5 Mar 2014 23:01:40 +0100
9Bug-Reference-URL:      http://lists.gnu.org/archive/html/bug-bash/2014-03/msg00028.html
10
11Bug-Description:
12
13Patch (apply with `patch -p0'):
14
15This patch changes the behavior of programmable completion to compensate
16for two assumptions made by the bash-completion package.  Bash-4.3 changed
17to dequote the argument to programmable completion only under certain
18circumstances, to make the behavior of compgen more consistent when run
19from the command line -- closer to the behavior when run by a shell function
20run as part of programmable completion.  Bash-completion can pass quoted
21arguments to compgen when the original word to be completed was not quoted,
22expecting programmable completion to dequote the word before attempting
23completion.
24
25This patch fixes two cases:
26
271.  An empty string that bash-completion passes to compgen as a quoted null
28    string ('').
29
302.  An unquoted word that bash-completion quotes using single quotes or
31    backslashes before passing it to compgen.
32
33In these cases, since readline did not detect a quote character in the original
34word to be completed, bash-4.3
35
36*** ../bash-4.3/externs.h       2014-01-02 14:58:20.000000000 -0500
37--- externs.h   2014-03-13 14:42:57.000000000 -0400
38***************
39*** 325,328 ****
40--- 325,329 ----
41  extern char *sh_backslash_quote_for_double_quotes __P((char *));
42  extern int sh_contains_shell_metas __P((char *));
43+ extern int sh_contains_quotes __P((char *));
44 
45  /* declarations for functions defined in lib/sh/spell.c */
46*** ../bash-4.3/lib/sh/shquote.c        2013-03-31 21:53:32.000000000 -0400
47--- lib/sh/shquote.c    2014-03-13 14:42:57.000000000 -0400
48***************
49*** 312,313 ****
50--- 312,327 ----
51    return (0);
52  }
53+
54+ int
55+ sh_contains_quotes (string)
56+      char *string;
57+ {
58+   char *s;
59+
60+   for (s = string; s && *s; s++)
61+     {
62+       if (*s == '\'' || *s == '"' || *s == '\\')
63+       return 1;
64+     }
65+   return 0;
66+ }
67*** ../bash-4.3/pcomplete.c     2013-08-26 15:23:45.000000000 -0400
68--- pcomplete.c 2014-03-25 17:23:23.000000000 -0400
69***************
70*** 184,187 ****
71--- 184,188 ----
72  COMPSPEC *pcomp_curcs;
73  const char *pcomp_curcmd;
74+ const char *pcomp_curtxt;
75 
76  #ifdef DEBUG
77***************
78*** 754,757 ****
79--- 755,784 ----
80          dfn = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character);
81        }
82+       /* Intended to solve a mismatched assumption by bash-completion.  If
83+        the text to be completed is empty, but bash-completion turns it into
84+        a quoted string ('') assuming that this code will dequote it before
85+        calling readline, do the dequoting. */
86+       else if (iscompgen && iscompleting &&
87+              pcomp_curtxt && *pcomp_curtxt == 0 &&
88+              text && (*text == '\'' || *text == '"') && text[1] == text[0] && text[2] == 0 &&
89+              rl_filename_dequoting_function)
90+       dfn = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character);
91+       /* Another mismatched assumption by bash-completion.  If compgen is being
92+                run as part of bash-completion, and the argument to compgen is not
93+                the same as the word originally passed to the programmable completion
94+                code, dequote the argument if it has quote characters.  It's an
95+                attempt to detect when bash-completion is quoting its filename
96+                argument before calling compgen. */
97+       /* We could check whether gen_shell_function_matches is in the call
98+        stack by checking whether the gen-shell-function-matches tag is in
99+        the unwind-protect stack, but there's no function to do that yet.
100+        We could simply check whether we're executing in a function by
101+        checking variable_context, and may end up doing that. */
102+       else if (iscompgen && iscompleting && rl_filename_dequoting_function &&
103+              pcomp_curtxt && text &&
104+              STREQ (pcomp_curtxt, text) == 0 &&
105+              variable_context &&
106+              sh_contains_quotes (text))       /* guess */
107+       dfn = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character);
108        else
109        dfn = savestring (text);
110***************
111*** 1523,1527 ****
112  {
113    COMPSPEC *cs, *oldcs;
114!   const char *oldcmd;
115    STRINGLIST *ret;
116 
117--- 1550,1554 ----
118  {
119    COMPSPEC *cs, *oldcs;
120!   const char *oldcmd, *oldtxt;
121    STRINGLIST *ret;
122 
123***************
124*** 1546,1552 ****
125--- 1573,1581 ----
126    oldcs = pcomp_curcs;
127    oldcmd = pcomp_curcmd;
128+   oldtxt = pcomp_curtxt;
129 
130    pcomp_curcs = cs;
131    pcomp_curcmd = cmd;
132+   pcomp_curtxt = word;
133 
134    ret = gen_compspec_completions (cs, cmd, word, start, end, foundp);
135***************
136*** 1554,1557 ****
137--- 1583,1587 ----
138    pcomp_curcs = oldcs;
139    pcomp_curcmd = oldcmd;
140+   pcomp_curtxt = oldtxt;
141 
142    /* We need to conditionally handle setting *retryp here */
143*** ../bash-4.3/patchlevel.h    2012-12-29 10:47:57.000000000 -0500
144--- patchlevel.h        2014-03-20 20:01:28.000000000 -0400
145***************
146*** 26,30 ****
147     looks for to find the patch level (for the sccs version string). */
148 
149! #define PATCHLEVEL 9
150 
151  #endif /* _PATCHLEVEL_H_ */
152--- 26,30 ----
153     looks for to find the patch level (for the sccs version string). */
154 
155! #define PATCHLEVEL 10
156 
157  #endif /* _PATCHLEVEL_H_ */
Note: See TracBrowser for help on using the repository browser.