From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14658 invoked from network); 10 Feb 2007 19:07:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 10 Feb 2007 19:07:34 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 50332 invoked from network); 10 Feb 2007 19:07:28 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Feb 2007 19:07:28 -0000 Received: (qmail 4530 invoked by alias); 10 Feb 2007 19:07:25 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23161 Received: (qmail 4518 invoked from network); 10 Feb 2007 19:07:24 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 10 Feb 2007 19:07:24 -0000 Received: (qmail 50031 invoked from network); 10 Feb 2007 19:07:24 -0000 Received: from vms040pub.verizon.net (206.46.252.40) by a.mx.sunsite.dk with SMTP; 10 Feb 2007 19:07:17 -0000 Received: from torch.brasslantern.com ([71.116.79.148]) by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JD9003BBH3V4EPC@vms040.mailsrvcs.net> for zsh-workers@sunsite.dk; Sat, 10 Feb 2007 13:07:08 -0600 (CST) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id l1AJ76CO006631 for ; Sat, 10 Feb 2007 11:07:07 -0800 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id l1AJ76FM006630 for zsh-workers@sunsite.dk; Sat, 10 Feb 2007 11:07:06 -0800 Date: Sat, 10 Feb 2007 11:07:05 -0800 From: Bart Schaefer Subject: Quoting problem and crashes with ${(#)var} To: zsh-workers@sunsite.dk Message-id: <070210110706.ZM6627@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable 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:;<=3D>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxy= z{|}~ =FF=FF=FF=FF=FF=FF-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:;<=3D>?= @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~^? #$^*()$= =3D|{}[]`<>?~`,'"\\torch%=20 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=3D0xb7d674d0 "\203", e=3D0x0, instring=3D1) at ../../zsh-4.0/Src/utils.c:4282 #1 0x080b1822 in paramsubst (l=3D0xb7d67470, n=3D0xb7d67494, str=3D0xbff16= 7b8,=20 qt=3D0, ssub=3D0) at ../../zsh-4.0/Src/subst.c:2896 #2 0x080ac095 in stringsubst (list=3D0xb7d67470, node=3D0xb7d67494, ssub= =3D0,=20 asssub=3D0) at ../../zsh-4.0/Src/subst.c:193 #3 0x080aba08 in prefork (list=3D0xb7d67470, flags=3D0) at ../../zsh-4.0/Src/subst.c:91 #4 0x08063189 in execcmd (state=3D0xbff17020, input=3D0, output=3D0, how= =3D18,=20 last1=3D2) 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= :;<=3D>?@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.sta= tus core.6537 core.6551 core.6555 core.6571 core.6573 core.6575 core.6577 c= ore.6583 core.6587 Doc Etc Functions Makefile Src stamp-h stamp-h.in Test u= lzsh: 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= :;<=3D>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-= ^@M-^AM-^B #$^*()$=3D|{}[]`<>?~`,'"\\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-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-Y= M-ZM-[M-\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-r= M-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:\;\<\=3D\>\?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\]\^_\`abcdefghijklmn= opqrstuvwxyz\{\|\}\~^?M-^@M-^AM-^Bzsh: segmentation fault (core dumped) fo= r x in {1..255}; do; echo -n ${(q#)x}; done |=20 zsh: done cat -nv torch%=20 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= :;<=3D>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-= ^@M-^AM-^B M-^?M-^?M-^?M-^?M-^?M-^?#$^*()$=3D|{}[] ../../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 substit= ution <> 9394 ../../zsh-4.0/Src/subst.c:221: BUG: parse error in command substit= ution 9395 ../../zsh-4.0/Src/subst.c:221: BUG: parse error in command substit= ution zsh: segmentation fault (core dumped) for x in {1..255}; do; echo -n ${(#)= x}; done 2>&1 |=20 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= :;<=3D>?@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.sta= tus core.6587 Doc Etc Functions Makefile Src stamp-h stamp-h.in Test ul()$= =3Dzsh: no matches found: | torch%=20 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.