From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7743 invoked from network); 7 May 2003 09:27:14 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 7 May 2003 09:27:14 -0000 Received: (qmail 5210 invoked by alias); 7 May 2003 09:27:07 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18508 Received: (qmail 5202 invoked from network); 7 May 2003 09:27:07 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 7 May 2003 09:27:07 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [62.189.183.235] by sunsite.dk (MessageWall 1.0.8) with SMTP; 7 May 2003 9:27:6 -0000 Received: from exchange01.csr.com (unverified) by (Content Technologies SMTPRS 4.2.1) with ESMTP id ; Wed, 7 May 2003 10:36:42 +0100 Received: from csr.com (TINKY-WINKY [192.168.144.127]) by exchange01.csr.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id JWCPYNLT; Wed, 7 May 2003 10:25:09 +0100 To: =?iso-8859-2?Q?Micha=B3?= Politowski , zsh-workers@sunsite.dk Subject: Re: remote files completion for scp In-reply-to: "=?iso-8859-2?Q?Micha=B3?= Politowski"'s message of "Tue, 06 May 2003 23:34:16 +0200." <20030506213416.GA30800@Amber.lab.icm.edu.pl> Date: Wed, 07 May 2003 10:27:04 +0100 Message-ID: <29689.1052299624@csr.com> From: Peter Stephenson =?iso-8859-2?Q?Micha=B3?= Politowski wrote: > I believe that this completion needs something, maybe dequoting like > this, to work correctly. I'm leaving this, it's hard enough decoding your own hieroglyphics in zsh and I don't use this. > One other thing. I obviously don't understand something about quoting. > Why with foo='a\string\with\some\backslashes' > echo "${foo//'\'/-}" > and > echo "${foo//"\\"/-}" > work but > echo "${foo//\\/-}" > doesn't do any substitutions, > no matter how many backslashes do I actually put in the last one? This seems to be because I screwed up. There's some code to allow you to quote the slash in the middle itself but it's not obvious to the user how it's supposed to work and any way it doesn't in this case, it swallows up the wrong number of backslashes. Here's some alternative code and a test. Index: Src/subst.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/subst.c,v retrieving revision 1.31 diff -u -r1.31 subst.c --- Src/subst.c 6 May 2002 14:46:11 -0000 1.31 +++ Src/subst.c 7 May 2003 09:23:06 -0000 @@ -1437,15 +1437,20 @@ * If there isn't one, we're just going to delete that, * i.e. replace it with an empty string. * - * This allows quotation of the slash with '\\/'. Why - * two? Well, for a non-quoted string we can check for - * Bnull+/, which is what you get from `\/', but inside - * double quotes the Bnull isn't there, so it's not - * consistent. + * We used to use double backslashes to quote slashes, + * but actually that was buggy and using a single backslash + * is easier and more obvious. */ for (ptr = s; (c = *ptr) && c != '/'; ptr++) - if (c == '\\' && ptr[1] == '/') - chuck(ptr); + { + if ((c == Bnull || c == '\\') && ptr[1]) + { + if (ptr[1] == '/') + chuck(ptr); + else + ptr++; + } + } replstr = (*ptr && ptr[1]) ? ptr+1 : ""; *ptr = '\0'; } Index: Test/D04parameter.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v retrieving revision 1.7 diff -u -r1.7 D04parameter.ztst --- Test/D04parameter.ztst 1 Apr 2003 14:04:11 -0000 1.7 +++ Test/D04parameter.ztst 7 May 2003 09:23:06 -0000 @@ -146,6 +146,18 @@ 0:array ${...:/...} >expletive deleted boldly claws dogs expletive deleted fight + str1='a\string\with\backslashes' + str2='a/string/with/slashes' + print "${str1//\\/-}" + print ${str1//\\/-} + print "${str2//\//-}" + print ${str2//\//-} +0:use of backslashes in //-substitutions +>a-string-with-backslashes +>a-string-with-backslashes +>a-string-with-slashes +>a-string-with-slashes + str1='twocubed' array=(the number of protons in an oxygen nucleus) print $#str1 ${#str1} "$#str1 ${#str1}" $#array ${#array} "$#array ${#array}" ********************************************************************** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. **********************************************************************