From: Zoltan Hidvegi <hzoli@cs.elte.hu>
To: zsh-workers@math.gatech.edu (zsh-workers)
Subject: Re: hzoli change: $foo:s//r/
Date: Wed, 16 Aug 1995 13:59:09 +0200 (MET DST) [thread overview]
Message-ID: <199508161159.NAA01707@bolyai.cs.elte.hu> (raw)
In-Reply-To: <m0siXbD-00007BC@aglaia.snafu.DE> from "Thorsten Meinecke" at Aug 16, 95 03:48:54 am
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;
next prev parent reply other threads:[~1995-08-16 12:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-08-15 12:49 Heading, Anthony
1995-08-15 17:02 ` Zoltan Hidvegi
1995-08-16 1:48 ` Thorsten Meinecke
1995-08-16 11:59 ` Zoltan Hidvegi [this message]
1995-08-16 14:49 ` Thorsten Meinecke
1995-08-16 15:20 ` Zoltan Hidvegi
1995-08-16 16:01 ` Barton E. Schaefer
1995-08-16 18:18 ` Wayne Davison
1995-08-16 18:24 ` Zoltan Hidvegi
1995-08-16 22:22 ` Zefram
1995-08-15 18:36 Heading, Anthony
1995-08-15 17:52 ` Zoltan Hidvegi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199508161159.NAA01707@bolyai.cs.elte.hu \
--to=hzoli@cs.elte.hu \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).