From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gatech.edu (gatech.edu [130.207.244.244]) by werple.mira.net.au (8.6.12/8.6.9) with SMTP id WAA14448 for ; Wed, 16 Aug 1995 22:07:25 +1000 Received: from math (math.skiles.gatech.edu) by gatech.edu with SMTP id AA27868 (5.65c/Gatech-10.0-IDA for ); Wed, 16 Aug 1995 08:05:40 -0400 Received: by math (5.x/SMI-SVR4) id AA14849; Wed, 16 Aug 1995 08:00:56 -0400 Resent-Date: Wed, 16 Aug 1995 13:59:09 +0200 (MET DST) Old-Return-Path: From: Zoltan Hidvegi Message-Id: <199508161159.NAA01707@bolyai.cs.elte.hu> Subject: Re: hzoli change: $foo:s//r/ To: zsh-workers@math.gatech.edu (zsh-workers) Date: Wed, 16 Aug 1995 13:59:09 +0200 (MET DST) In-Reply-To: from "Thorsten Meinecke" at Aug 16, 95 03:48:54 am X-Mailer: ELM [version 2.4 PL24] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-Id: <"H6GSN3.0.xd3.ttTCm"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/320 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Thorsten Meinecke wrote: > In plain unmodified hzoli10.3 the unadorned backslash does exactly that. > > $ ./zsh -fc 'echo $ZSH_VERSION > array=(a b c d e) > echo $array:s/\/\&-\&/ > ' > 2.6-beta10-hzoli10.3 > a-a b-b c-c d-d e-e > $ > > Is this just another undocumented feature? Since there's no real need > to escape the delimiter--just choose a different one--the backslash > seems one of the best choices to denote "substitute whole string/ele- > ments of array" to me. Yes, it really works. This is because the backslash is removed as a nularg. However it does not work if the substitution is quoted with double quotes. There is a bug here I discovered testing this: nulargs are not properly removed from the substitution strings. This bug is also present in stock beta10 zsh. The patch below fixes that. After the patch :s/''/\&-\&/ will also do the same as :s/\/\&-\&/ but the '' syntax is more readable I think (and also in the future \ may quote the separator string so I wouldn't recommend its usage). > Sincere apologies for my GNUisms breaking hzoli10.2. > Please forgive me. > Thorsten It is partially my mistake. I knew that -q is not a universal grep option but somehow I forgot it. If I had tried configure on all systems I have acess to befor releasing 10.2 I would have noticed it. > BTW it is "substitution", isn't it? Yes. Zoltan *** 1.14 1995/07/10 18:02:35 --- Src/subst.c 1995/08/16 11:48:46 *************** *** 1482,1491 **** } for (tt = hsubl; *tt; tt++) if (INULL(*tt)) ! chuck(tt); for (tt = hsubr = ztrdup(ptr2); *tt; tt++) if (INULL(*tt)) ! chuck(tt); ptr2[-1] = del; if (sav) ptr3[-1] = sav; --- 1482,1491 ---- } for (tt = hsubl; *tt; tt++) if (INULL(*tt)) ! chuck(tt--); for (tt = hsubr = ztrdup(ptr2); *tt; tt++) if (INULL(*tt)) ! chuck(tt--); ptr2[-1] = del; if (sav) ptr3[-1] = sav;