zsh-workers
 help / color / mirror / code / Atom feed
* zsh-4.3.2 fails to run .zcompdump when an "alias -g" is in it
@ 2007-06-05 21:58 Zrajm C Akfohg
  2007-06-05 22:59 ` Phil Pennock
  0 siblings, 1 reply; 3+ messages in thread
From: Zrajm C Akfohg @ 2007-06-05 21:58 UTC (permalink / raw)
  To: zsh-workers

I reported this bug via the Gentoo Bugzilla in November 2006, however noone
there [http://bugs.gentoo.org/show_bug.cgi?id=155525] has commented on it, much
less passed it on "upstream", as they claim they do. So now I've tried to track
down the relevant ppl and direct by bugreport directly to you. I cincerely hope
this is the right place for this stuff. Here is a copy of my original bug report
on bugs.gentoo.org:


A couple of zsh versions ago I started to sometimes get the following error
message each time I opened up a new (z)shell:

    /home/zrajm/.zcompdump:3: bad set of key/value pairs for associative array

And after this message, all tab completion stops working in that shell. Once
the problem has appeared, all new shells get the exact same symptoms. If I
erase the ~/.zcompdump file, however, the shell I start after that will work
just fine (but start a little slow, since it is generating a new .zcompdump).
Upon starting a new shell after that, though, the problem is back.

I.e. *all* shells which source an existing .zcompdump show this problem.

At the time I did some experimenting, and found that if I removed the line "cp
_cp" inside the associative array assignment of _comps the problem I had went
away.

Today I realized that this might have something with the global alias "cp" that
I have. And sure enough, if I remove the line

     alias -g cp='cp -b'

from my .zshrc the problem goes away.

HOWEVER instead of removing the alias, I can also edit the .zcompdump file,
quoting the word "cp" on the faulty line. If I replace

_comps=(
   ...
   cp _cp
   ...
)

with

_comps=(
   ...
   'cp' _cp
   ...
)

the problem goes away completely. -- Until zsh generates a new (faulty)
.zcompdump file.

Thus, zsh should generate a .zcompdump file in which the keys in all
associative arrays are quoted, to avoid having them expanded as aliases.


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

* Re: zsh-4.3.2 fails to run .zcompdump when an "alias -g" is in it
  2007-06-05 21:58 zsh-4.3.2 fails to run .zcompdump when an "alias -g" is in it Zrajm C Akfohg
@ 2007-06-05 22:59 ` Phil Pennock
  2007-06-06  8:56   ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Pennock @ 2007-06-05 22:59 UTC (permalink / raw)
  To: Zrajm C Akfohg; +Cc: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 678 bytes --]

On 2007-06-05 at 21:58 +0000, Zrajm C Akfohg wrote:
[ zcompdump broken ]
> Today I realized that this might have something with the global alias "cp" that
> I have. And sure enough, if I remove the line
> 
>      alias -g cp='cp -b'
> 
> from my .zshrc the problem goes away.

> the problem goes away completely. -- Until zsh generates a new (faulty)
> .zcompdump file.
> 
> Thus, zsh should generate a .zcompdump file in which the keys in all
> associative arrays are quoted, to avoid having them expanded as aliases.

Try this; fortunately, it's an easy change: the parameter expansion flag
'q' can be doubled to use single-quote quoting instead of backslash
escaping.

-Phil

[-- Attachment #2: zcompdump-quoting.patch --]
[-- Type: text/x-diff, Size: 1734 bytes --]

Index: Completion/compdump
===================================================================
RCS file: /home/cvsroot/zsh/Completion/compdump,v
retrieving revision 1.7
diff -p -u -r1.7 compdump
--- Completion/compdump	16 Jun 2004 15:10:21 -0000	1.7
+++ Completion/compdump	5 Jun 2007 22:55:46 -0000
@@ -41,32 +41,32 @@ print "#files: $#_d_files\tversion: $ZSH
 
 print "\n_comps=(" >> $_d_file
 for _d_f in ${(ok)_comps}; do
-  print -r - "${(q)_d_f}" "${(q)_comps[$_d_f]}"
+  print -r - "${(qq)_d_f}" "${(qq)_comps[$_d_f]}"
 done >> $_d_file
 print ")" >> $_d_file
 
 print "\n_services=(" >> $_d_file
 for _d_f in ${(ok)_services}; do
-  print -r - "${(q)_d_f}" "${(q)_services[$_d_f]}"
+  print -r - "${(qq)_d_f}" "${(qq)_services[$_d_f]}"
 done >> $_d_file
 print ")" >> $_d_file
 
 print "\n_patcomps=(" >> $_d_file
 for _d_f in ${(ok)_patcomps}; do
-  print -r - "${(q)_d_f}" "${(q)_patcomps[$_d_f]}"
+  print -r - "${(qq)_d_f}" "${(qq)_patcomps[$_d_f]}"
 done >> $_d_file
 print ")" >> $_d_file
 
 _d_tmp="_postpatcomps"
 print "\n_postpatcomps=(" >> $_d_file
 for _d_f in ${(ok)_postpatcomps}; do
-  print -r - "${(q)_d_f}" "${(q)_postpatcomps[$_d_f]}"
+  print -r - "${(qq)_d_f}" "${(qq)_postpatcomps[$_d_f]}"
 done >> $_d_file
 print ")" >> $_d_file
 
 print "\n_compautos=(" >> $_d_file
 for _d_f in "${(ok@)_compautos}"; do
-  print -r - "${(q)_d_f}" "${(q)_compautos[$_d_f]}"
+  print -r - "${(qq)_d_f}" "${(qq)_compautos[$_d_f]}"
 done >> $_d_file
 print ")" >> $_d_file
 
@@ -129,7 +129,7 @@ done
 print >> $_d_file
 
 print "typeset -gUa _comp_assocs" >> $_d_file
-print "_comp_assocs=( ${(q)_comp_assocs} )" >> $_d_file
+print "_comp_assocs=( ${(qq)_comp_assocs} )" >> $_d_file
 
 mv $_d_file ${_d_file%.$HOST.$$}
 

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

* Re: zsh-4.3.2 fails to run .zcompdump when an "alias -g" is in it
  2007-06-05 22:59 ` Phil Pennock
@ 2007-06-06  8:56   ` Peter Stephenson
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2007-06-06  8:56 UTC (permalink / raw)
  To: Zrajm C Akfohg, zsh-workers

Phil Pennock wrote:
> > Thus, zsh should generate a .zcompdump file in which the keys in all
> > associative arrays are quoted, to avoid having them expanded as aliases.
> 
> Try this; fortunately, it's an easy change: the parameter expansion flag
> 'q' can be doubled to use single-quote quoting instead of backslash
> escaping.

I've committed this, but in principle you can have a global alias for
anything, even a quoted expression; it might be better to have the shell
save and restore the state of the noaliases option for the dumpfile,
something like:


integer aliases
{
[[ -o aliases ]] && aliases=1
setopt noaliases

...

} always {
  (( aliases )) && setopt aliases
}


It's a pity this isn't easier in a dot file.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview


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

end of thread, other threads:[~2007-06-06  8:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-05 21:58 zsh-4.3.2 fails to run .zcompdump when an "alias -g" is in it Zrajm C Akfohg
2007-06-05 22:59 ` Phil Pennock
2007-06-06  8:56   ` Peter Stephenson

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).