zsh-workers
 help / color / mirror / code / Atom feed
* Global-alias problem with _expand
@ 2000-10-09 16:17 Wayne Davison
  0 siblings, 0 replies; 5+ messages in thread
From: Wayne Davison @ 2000-10-09 16:17 UTC (permalink / raw)
  To: Zsh Workers

Global aliases can cause a problem in the _expand completer:

% zsh -f

% autoload -U compinit
% compinit
% zstyle ':completion:*' completer _expand
% alias -g T='|tail'
% l T<TAB>
_expand:-1: parse error near `|'

..wayne..


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Global-alias problem with _expand
  2000-10-10 15:04 Sven Wischnowsky
@ 2000-10-10 15:47 ` Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2000-10-10 15:47 UTC (permalink / raw)
  To: zsh-workers

On Oct 10,  5:04pm, Sven Wischnowsky wrote:
} 
} Bart Schaefer wrote:
} 
} > By redirecting stderr on the eval?
} 
} Sigh.

I've been wondering whether _main_complete shouldn't do something like

[[ -t 2 ]] && exec 2>/dev/null

The problem of course is that there's no way to guarantee that the FD is
restored properly when the function exits.  ZLE itself closes and then
later restores stdin, so the `exec </dev/null' is safe, but anything that
triggers a zerr() can potentially prevent the function from restoring any
other FDs.

Maybe we've finally got a good enough handle on the zerr/zwarn thing that
we don't need to worry about this ... but I do anyway.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Global-alias problem with _expand
@ 2000-10-10 15:04 Sven Wischnowsky
  2000-10-10 15:47 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Sven Wischnowsky @ 2000-10-10 15:04 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Oct 10, 10:13am, Sven Wischnowsky wrote:
> }
> } Rats. Look:
> } 
> }   % alias -g 'T=|foo'
> }   % eval 'exp=( T )'
> }   zsh: parse error near `|'
> } 
> } Anyone know how to avoid that?
> 
> By redirecting stderr on the eval?

Now where did I get the impression from that the error kept the rest
from the function from being executed? Sigh.

Bye
 Sven

Index: Completion/Core/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_expand,v
retrieving revision 1.31
diff -u -r1.31 _expand
--- Completion/Core/_expand	2000/10/10 09:00:15	1.31
+++ Completion/Core/_expand	2000/10/10 15:03:52
@@ -12,7 +12,6 @@
 [[ _matcher_num -gt 1 ]] && return 1
 
 local exp word sort expr expl subd suf=" " force opt asp tmp opre pre epre
-local gal
 
 (( $# )) &&
     while getopts gsco opt; do
@@ -49,12 +48,6 @@
        ( "$word" = *\$[a-zA-Z0-9_]## && 
          ${#parameters[(I)${word##*\$}*]} -ne 1 ) ]] && return 1 }
 
-# We have to temporarily remove the global aliases because they can make
-# the evals fail.
-
-gal=( ${(kv)galiases} )
-(( $#gal )) && builtin unalias ${(k)galiases}
-
 # In exp we will collect the expansions.
 
 exp=("$word")
@@ -66,7 +59,7 @@
 if [[ "$force" = *s* ]] ||
    zstyle -T ":completion:${curcontext}:" substitute; then
   [[ ! -o ignorebraces && "${#${exp}//[^\{]}" = "${#${exp}//[^\}]}" ]] &&
-      eval exp\=\( ${${(q)exp}:gs/\\{/\{/:gs/\\}/\}/} \)
+      eval exp\=\( ${${(q)exp}:gs/\\{/\{/:gs/\\}/\}/} \) 2>/dev/null
   eval 'exp=( ${${(e)exp//\\[ 	
 ]/ }//(#b)([ 	
 ])/\\$match[1]} )' 2>/dev/null
@@ -90,20 +83,14 @@
 
 (( $#exp )) || exp=("$subd[@]")
 
-if [[ $#exp -eq 1 && "${exp[1]//\\}" = "${word//\\}"(|\(N\)) ]]; then
-  galiases=( $gal )
-  return 1
-fi
+[[ $#exp -eq 1 && "${exp[1]//\\}" = "${word//\\}"(|\(N\)) ]] && return 1
 
 # With subst-globs-only we bail out if there were no glob expansions,
 # regardless of any substitutions
 
-if { [[ "$force" = *o* ]] ||
-    zstyle -t ":completion:${curcontext}:" subst-globs-only } &&
-    [[ "$subd" = "$exp"(|\(N\)) ]]; then
-  galiases=( $gal )
-  return 1
-fi
+{ [[ "$force" = *o* ]] ||
+  zstyle -t ":completion:${curcontext}:" subst-globs-only } &&
+  [[ "$subd" = "$exp"(|\(N\)) ]] &&  return 1
 
 zstyle -s ":completion:${curcontext}:" keep-prefix tmp || tmp=changed
 if [[ "$word" = [\~\$]*/* && "$tmp" = (yes|true|on|1|changed) ]]; then
@@ -114,12 +101,7 @@
     [[ "$tmp" != changed || $#exp -gt 1 ||
        "${opre}${exp[1]#${pre}}" != "$word" ]] && exp=( ${opre}${^exp#${pre}} )
   fi
-
-  galiases=( $gal )
-
   [[ $#exp -eq 1 && "$exp[1]" = "$word" ]] && return 1
-else
-  galiases=( $gal )
 fi
 
 # Now add as matches whatever the user requested.

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Global-alias problem with _expand
  2000-10-10  8:13 Sven Wischnowsky
@ 2000-10-10 14:29 ` Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2000-10-10 14:29 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

On Oct 10, 10:13am, Sven Wischnowsky wrote:
}
} Rats. Look:
} 
}   % alias -g 'T=|foo'
}   % eval 'exp=( T )'
}   zsh: parse error near `|'
} 
} Anyone know how to avoid that?

By redirecting stderr on the eval?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Global-alias problem with _expand
@ 2000-10-10  8:13 Sven Wischnowsky
  2000-10-10 14:29 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Sven Wischnowsky @ 2000-10-10  8:13 UTC (permalink / raw)
  To: zsh-workers


Wayne Davison wrote:

> Global aliases can cause a problem in the _expand completer:
> 
> % zsh -f
> 
> % autoload -U compinit
> % compinit
> % zstyle ':completion:*' completer _expand
> % alias -g T='|tail'
> % l T<TAB>
> _expand:-1: parse error near `|'

Rats. Look:

  % alias -g 'T=|foo'
  % eval 'exp=( T )'
  zsh: parse error near `|'

Anyone know how to avoid that?

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2000-10-10 15:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-09 16:17 Global-alias problem with _expand Wayne Davison
2000-10-10  8:13 Sven Wischnowsky
2000-10-10 14:29 ` Bart Schaefer
2000-10-10 15:04 Sven Wischnowsky
2000-10-10 15:47 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).