mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 10:01:11 +02:00
(14350)
This commit is contained in:
parent
231f077a75
commit
dc9d78c659
3 changed files with 57 additions and 10 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2001-05-15 Sven Wischnowsky <wischnow@zsh.org>
|
||||||
|
|
||||||
|
* 14350: Completion/Base/Completer/_expand, Src/Zle/zle_tricky.c:
|
||||||
|
don't remove single and double quotes that are inside parameter
|
||||||
|
expansions; hopefully better handling of brace expansions in
|
||||||
|
_expand
|
||||||
|
|
||||||
2001-05-15 Peter Stephenson <pws@csr.com>
|
2001-05-15 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
* 14348: Src/builtin.c: some idiot forgot to make GLOBAL_EXPORT
|
* 14348: Src/builtin.c: some idiot forgot to make GLOBAL_EXPORT
|
||||||
|
|
|
@ -55,8 +55,31 @@ exp=("$word")
|
||||||
|
|
||||||
if [[ "$force" = *s* ]] ||
|
if [[ "$force" = *s* ]] ||
|
||||||
zstyle -T ":completion:${curcontext}:" substitute; then
|
zstyle -T ":completion:${curcontext}:" substitute; then
|
||||||
[[ ! -o ignorebraces && "${#${exp}//[^\{]}" = "${#${exp}//[^\}]}" ]] &&
|
|
||||||
eval exp\=\( ${${(q)exp}:gs/\\{/\{/:gs/\\}/\}/} \) 2>/dev/null
|
### We once used this:
|
||||||
|
###
|
||||||
|
### [[ ! -o ignorebraces && "${#${exp}//[^\{]}" = "${#${exp}//[^\}]}" ]] &&
|
||||||
|
### eval exp\=\( ${${(q)exp}:gs/\\{/\{/:gs/\\}/\}/} \) 2>/dev/null
|
||||||
|
###
|
||||||
|
### instead of the following loop to expand braces. But that made
|
||||||
|
### parameter expressions such as ${foo} be expanded like brace
|
||||||
|
### expansions, too (and with braceccl set...).
|
||||||
|
|
||||||
|
if [[ ! -o ignorebraces && "${#${exp}//[^\{]}" = "${#${exp}//[^\}]}" ]]; then
|
||||||
|
local otmp
|
||||||
|
|
||||||
|
tmp=${(q)word}
|
||||||
|
while [[ $#tmp != $#otmp ]]; do
|
||||||
|
otmp=$tmp
|
||||||
|
tmp=${tmp//(#b)\\\$\\\{(([^\{\}]|\\\\{|\\\\})#)([^\\])\\\}/\\$\\\\{${match[1]}${match[3]}\\\\}}
|
||||||
|
done
|
||||||
|
eval exp\=\( ${tmp:gs/\\{/\{/:gs/\\}/\}/} \) 2>/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
### There's a bug: spaces resulting from brace expansion are quoted in
|
||||||
|
### the following expression, too. We don't want that, but I have no
|
||||||
|
### idea how to fix it.
|
||||||
|
|
||||||
eval 'exp=( ${${(e)exp//\\[
|
eval 'exp=( ${${(e)exp//\\[
|
||||||
]/ }//(#b)([
|
]/ }//(#b)([
|
||||||
])/\\$match[1]} )' 2>/dev/null
|
])/\\$match[1]} )' 2>/dev/null
|
||||||
|
|
|
@ -1020,13 +1020,10 @@ get_comp_string(void)
|
||||||
* the previously massaged command line using the lexer. It stores *
|
* the previously massaged command line using the lexer. It stores *
|
||||||
* each token in each command (commands being regarded, roughly, as *
|
* each token in each command (commands being regarded, roughly, as *
|
||||||
* being separated by tokens | & &! |& || &&). The loop stops when *
|
* being separated by tokens | & &! |& || &&). The loop stops when *
|
||||||
* the end of the command containing the cursor is reached. It's a *
|
* the end of the command containing the cursor is reached. What *
|
||||||
* simple way to do things, but suffers from an inability to *
|
* makes this messy is checking for things like redirections, loops *
|
||||||
* distinguish actual command arguments from, for example, *
|
* and whatnot. */
|
||||||
* filenames in redirections. (But note that code elsewhere checks *
|
|
||||||
* if we are completing *in* a redirection.) The only way to fix *
|
|
||||||
* this would be to pass the command line through the parser too, *
|
|
||||||
* and get the arguments that way. Maybe in 3.1... */
|
|
||||||
do {
|
do {
|
||||||
lincmd = ((incmdpos && !ins && !incond) || (oins == 2 && i == 2) ||
|
lincmd = ((incmdpos && !ins && !incond) || (oins == 2 && i == 2) ||
|
||||||
(ins == 3 && i == 1));
|
(ins == 3 && i == 1));
|
||||||
|
@ -1343,6 +1340,19 @@ get_comp_string(void)
|
||||||
*p = '"';
|
*p = '"';
|
||||||
else if (*p == Snull)
|
else if (*p == Snull)
|
||||||
*p = '\'';
|
*p = '\'';
|
||||||
|
} else {
|
||||||
|
int level = 0;
|
||||||
|
|
||||||
|
for (p = s; *p; p++) {
|
||||||
|
if (level && *p == Snull)
|
||||||
|
*p = '\'';
|
||||||
|
else if (level && *p == Dnull)
|
||||||
|
*p = '"';
|
||||||
|
else if (*p == String && p[1] == Inbrace)
|
||||||
|
level++;
|
||||||
|
else if (*p == Outbrace)
|
||||||
|
level--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((*s == Snull || *s == Dnull) && !has_real_token(s + 1)) {
|
if ((*s == Snull || *s == Dnull) && !has_real_token(s + 1)) {
|
||||||
char *q = (*s == Snull ? "'" : "\""), *n = tricat(qipre, q, "");
|
char *q = (*s == Snull ? "'" : "\""), *n = tricat(qipre, q, "");
|
||||||
|
@ -1673,11 +1683,18 @@ doexpansion(char *s, int lst, int olst, int explincmd)
|
||||||
{
|
{
|
||||||
int ret = 1, first = 1;
|
int ret = 1, first = 1;
|
||||||
LinkList vl;
|
LinkList vl;
|
||||||
char *ss;
|
char *ss, *ts;
|
||||||
|
|
||||||
pushheap();
|
pushheap();
|
||||||
vl = newlinklist();
|
vl = newlinklist();
|
||||||
ss = dupstring(s);
|
ss = dupstring(s);
|
||||||
|
/* get_comp_string() leaves these quotes unchanged when they are
|
||||||
|
* inside parameter expansions. */
|
||||||
|
for (ts = ss; *ts; ts++)
|
||||||
|
if (*ts == '"')
|
||||||
|
*ts = Dnull;
|
||||||
|
else if (*ts == '\'')
|
||||||
|
*ts = Snull;
|
||||||
addlinknode(vl, ss);
|
addlinknode(vl, ss);
|
||||||
prefork(vl, 0);
|
prefork(vl, 0);
|
||||||
if (errflag)
|
if (errflag)
|
||||||
|
|
Loading…
Reference in a new issue