Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Quoting problem and crashes with ${(#)var}



With zsh -f from the latest CVS as of 2007-02-10 10:28 AM PST:

torch% for x in {1..255}; echo -n ${(#)x}; echo ''


123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ÿÿÿÿÿÿ-n#$^BUILD Completion Config config.cache config.h config.h-xx config.log config.modules config.modules.sh config.status core.6537 core.6551 core.6555 core.6571 core.6573 core.6575 core.6577 core.6583 core.6587 Doc Etc Functions Makefile Src stamp-h stamp-h.in Test ulzsh: bad pattern: (
torch% for x in {1..255}; echo -n ${(V#)x}; echo ''
^A^B^C^D^E^F^G^H
^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_ !"#$%&'()*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~^? #$^*()$=|{}[]`<>?~`,'"\\torch% 

Note that with the ${(V#)x} incantation, the newline that should
be output by the final echo is not printed.  In fact, if I replace that
last echo with "cat config.h" there is STILL nothing output, so it's not
just that a single line is somehow being swallowed.  But if I replace the
final echo with "sleep 30" the shell does pause for 30 seconds, so the
command is in fact being executed.  Where is the output going?

On we go:

torch% for x in {1..255}; echo -n ${(q#)x}; echo ''

I can't show the output because at this point the terminal window vanished
as zsh dumped core:

#0  0x080bc534 in quotestring (s=0xb7d674d0 "\203", e=0x0, instring=1)
    at ../../zsh-4.0/Src/utils.c:4282
#1  0x080b1822 in paramsubst (l=0xb7d67470, n=0xb7d67494, str=0xbff167b8, 
    qt=0, ssub=0) at ../../zsh-4.0/Src/subst.c:2896
#2  0x080ac095 in stringsubst (list=0xb7d67470, node=0xb7d67494, ssub=0, 
    asssub=0) at ../../zsh-4.0/Src/subst.c:193
#3  0x080aba08 in prefork (list=0xb7d67470, flags=0)
    at ../../zsh-4.0/Src/subst.c:91
#4  0x08063189 in execcmd (state=0xbff17020, input=0, output=0, how=18, 
    last1=2) at ../../zsh-4.0/Src/exec.c:2005

Set's try again slightly differently:

torch% setopt nopromptcr nopromptsp
torch% for x in {1..255}; do echo -n ${(#)x}; done |& cat -nv; echo ''
     1  ^A^B^C^D^E^F^G^H
     2  ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_ !"#$%&'()*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-^@M-^AM-^B M-^?M-^?M-^?M-^?M-^?M-^?#$^BUILD Completion Config config.cache config.h config.h-xx config.log config.modules config.modules.sh config.status core.6537 core.6551 core.6555 core.6571 core.6573 core.6575 core.6577 core.6583 core.6587 Doc Etc Functions Makefile Src stamp-h stamp-h.in Test ulzsh: bad pattern: (

torch% for x in {1..255}; do echo -n ${(V#)x}; done | cat -nv; echo ''
     1  ^A^B^C^D^E^F^G^H
     2  ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_ !"#$%&'()*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-^@M-^AM-^B #$^*()$=|{}[]`<>?~`,'"\\M-^]M-^^M-^_M- M-!M-"M-#M-$M-%M-&M-'M-(M-)M-*M-+M-,M--M-.M-/M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9M-:M-;M-<M-=M->M-?M-@M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-ZM-[M-\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?
torch% for x in {1..255}; do echo -n ${(q#)x}; done | cat -nv; echo ''
     1  ^A^B^C^D^E^F^G^H\       '
     2  '^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_\ \!\"\#\$%\&\'\(\)\*+,./0123456789:\;\<\=\>\?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\]\^_\`abcdefghijklmnopqrstuvwxyz\{\|\}\~^?M-^@M-^AM-^Bzsh: segmentation fault (core dumped)  for x in {1..255}; do; echo -n ${(q#)x}; done | 
zsh: done                              cat -nv

torch% 

OK, there was a "bad pattern" error so:

torch% setopt noglob
torch% for x in {1..255}; do echo -n ${(#)x}; done |& cat -nv; echo ''
     1  ^A^B^C^D^E^F^G^H
     2  ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_ !"#$%&'()*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-^@M-^AM-^B M-^?M-^?M-^?M-^?M-^?M-^?#$^*()$=|{}[] ../../zsh-4.0/Src/subst.c:221: BUG: parse error in command substitution
     3   ../../zsh-4.0/Src/subst.c:221: BUG: parse error in command substitution
    <<thousands of lines of output suppressed>>
  9394   ../../zsh-4.0/Src/subst.c:221: BUG: parse error in command substitution
  9395   ../../zsh-4.0/Src/subst.c:221: BUG: parse error in command substitution
zsh: segmentation fault (core dumped)  for x in {1..255}; do; echo -n ${(#)x}; done 2>&1 | 
zsh: done                              cat -nv

torch% setopt glob
torch% setopt nobadpattern
torch% for x in {1..255}; do echo -n ${(#)x}; done |& cat -nv; echo ''
     1  ^A^B^C^D^E^F^G^H
     2  ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_ !"#$%&'()*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-^@M-^AM-^B M-^?M-^?M-^?M-^?M-^?M-^?#$^BUILD Completion Config config.cache config.h config.h-xx config.log config.modules config.modules.sh config.status core.6587 Doc Etc Functions Makefile Src stamp-h stamp-h.in Test ul()$=zsh: no matches found: |

torch% 

So part of the problem appears to be attempting to interpet an unmatched
backtick as the beginning of a command substitution, but we never get that
far if globbing is enabled.



Messages sorted by: Reverse Date, Date, Thread, Author