From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: bug
Date: Wed, 21 Dec 2011 22:32:47 +0000 [thread overview]
Message-ID: <20111221223247.0d44eaf2@pws-pc.ntlworld.com> (raw)
In-Reply-To: <111220190511.ZM11868@torch.brasslantern.com>
On Tue, 20 Dec 2011 19:05:11 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Dec 20, 6:08pm, Ray Andrews wrote:
> }
> } function z
> } {
> } var=$1
> } echo "var:/${1:0:1}/${1:1:1}/${1:2:1}/"
> } }
> }
> } $ z abcde
> } var: /a/a/b/
>
> For further compatibility with other shells there is a special case
> for array offset 0. This usually accesses to the first element of
> the array. However, if the substitution refers the positional
> parameter array, e.g. $@ or $*, then offset 0 instead refers to
> $0, offset 1 refers to $1, and so on. In other words, the
> positional parameter array is effectively extended by prepending
> $0. Hence ${*:0:1} substitutes $0 and ${*:1:1} substitutes $1.
>
> So :0:1 is acting on the invisible $0 even though the reference is to
> an individual positional parameter rather than to the positional array.
Yes, it should only be doing that for array values.
Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.129
diff -p -u -r1.129 subst.c
--- Src/subst.c 28 Nov 2011 09:48:22 -0000 1.129
+++ Src/subst.c 21 Dec 2011 22:31:35 -0000
@@ -2878,24 +2878,26 @@ paramsubst(LinkList l, LinkNode n, char
return NULL;
}
}
- if (horrible_offset_hack) {
- /*
- * As part of the 'orrible hoffset 'ack,
- * (what hare you? Han 'orrible hoffset 'ack,
- * sergeant major), if we are given a ksh/bash/POSIX
- * style positional parameter array which includes
- * offset 0, we use $0.
- */
- if (offset == 0 && isarr) {
- offset_hack_argzero = 1;
- } else if (offset > 0) {
- offset--;
- }
- }
if (isarr) {
- int alen = arrlen(aval), count;
+ int alen, count;
char **srcptr, **dstptr, **newarr;
+ if (horrible_offset_hack) {
+ /*
+ * As part of the 'orrible hoffset 'ack,
+ * (what hare you? Han 'orrible hoffset 'ack,
+ * sergeant major), if we are given a ksh/bash/POSIX
+ * style positional parameter array which includes
+ * offset 0, we use $0.
+ */
+ if (offset == 0) {
+ offset_hack_argzero = 1;
+ } else if (offset > 0) {
+ offset--;
+ }
+ }
+
+ alen = arrlen(aval);
if (offset < 0) {
offset += alen;
if (offset < 0)
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
next prev parent reply other threads:[~2011-12-21 22:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-21 2:08 bug Ray Andrews
2011-12-21 3:05 ` bug Bart Schaefer
2011-12-21 22:32 ` Peter Stephenson [this message]
-- strict thread matches above, loose matches on Subject: below --
1999-08-20 8:17 BUG Sven Wischnowsky
1999-08-19 7:16 BUG Sven Wischnowsky
1999-08-19 15:32 ` BUG Brian Harvell
1999-08-19 2:51 BUG Brian Harvell
1996-06-20 15:26 Bug Ray Van_Tassle
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=20111221223247.0d44eaf2@pws-pc.ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@zsh.org \
/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).