Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: _complete_debug crashes in zsh_directory_name
On Wed, 3 Aug 2011 05:26:53 +0200
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> Any ideas? It doesn't crash if I don't have the zsh_directory_name function.
This seems to depend on your set-up, so there's nothing I can do without
more clues. I'm wondering if the wrapper function is getting called at
multiple levels in a way that's confusing it, but that's pure guess.
It appears to have something to do with some prompt but simply putting
%~ in all my prompts and letting that call the zsh_directory_name hooks
didn't seem to do anything.
While we're here, however, we can do a lot better with _complete_debug.
For a start, it could use a more standard syntax. Then it can use the
facility to generate its own file descriptor, so it doesn't need to
trash anyone else's (which is what the new error is from). Then it can
use the try/always syntax to ensure the fd gets tidied up reliably.
I think this is still working but completion depends on side-effects in
unexpected ways so I may have missed something...
Index: Completion/Base/Widget/_complete_debug
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Widget/_complete_debug,v
retrieving revision 1.6
diff -p -u -r1.6 _complete_debug
--- Completion/Base/Widget/_complete_debug 19 Jun 2007 09:28:07 -0000 1.6
+++ Completion/Base/Widget/_complete_debug 3 Aug 2011 09:07:18 -0000
@@ -6,21 +6,27 @@ eval "$_comp_setup"
local tmp=${TMPPREFIX}${$}${words[1]:t}$[++_debug_count]
local pager w="${(qq)words}"
-exec 3>&- # Too bad if somebody else is using it ...
-[[ -t 2 ]] && { exec 3>&2 2>| $tmp ; trap 'exec 2>&3 3>&-' EXIT INT }
+integer debug_fd=-1
+{
+ if [[ -t 2 ]]; then
+ exec {debug_fd}>&2 2>| $tmp
+ fi
-setopt xtrace
-: $ZSH_NAME $ZSH_VERSION
-${1:-_main_complete}
-integer ret=$?
-unsetopt xtrace
+ setopt xtrace
+ : $ZSH_NAME $ZSH_VERSION
+ ${1:-_main_complete}
+ integer ret=$?
+ unsetopt xtrace
-[[ -t 3 ]] && {
+ if (( debug_fd != -1 )); then
zstyle -s ':completion:complete-debug::::' pager pager
print -sR "${pager:-${PAGER:-${VISUAL:-${EDITOR:-more}}}} ${(q)tmp} ;: $w"
_message -r "Trace output left in $tmp (up-history to view)"
- [[ $compstate[nmatches] -le 1 && $compstate[list] != *force* ]] &&
+ if [[ $compstate[nmatches] -le 1 && $compstate[list] != *force* ]]; then
compstate[list]='list force messages'
+ fi
+ fi
+} always {
+ (( debug_fd != -1 )) && exec 2>&$debug_fd {debug_fd}>&-
}
-
return ret
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
Messages sorted by:
Reverse Date,
Date,
Thread,
Author