From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: wrong array range with (r) flag on scalar?
Date: Mon, 9 Mar 2015 09:37:18 -0700 [thread overview]
Message-ID: <150309093718.ZM12425@torch.brasslantern.com> (raw)
In-Reply-To: <20150308225336.GA2746@localhost.localdomain>
On Mar 9, 6:53am, Han Pingtian wrote:
}
} Looks like this is also the case for (i):
}
} localhost% foo=abcdefgh
} localhost% print $foo[(r)ab,(i)fg]
} abcdefg
} localhost%
}
} Though
}
} localhost% print $foo[(i)fg]
} 6
} localhost%
}
} But according to the new contents of manual, this is the same case as
} "(r)fg".
You can't use (i) in ranges. $s[(i)ab,(i)fg] is an "invalid subscript";
the end of the range is not treated the same as the start.
So although $s[(r)fg] is the same as $s[$s[(i)fg]], $s[(r)ab,(r)fg] is
not the same as $s[$s[(i)ab],$s[(i)fg]].
The foregoing of course all applies only to indexes on scalars; for an
index on an array, the pattern match and resulting index values apply
to entire array elements, so there are no substrings to extract.
prev parent reply other threads:[~2015-03-09 16:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20150305083000.GA3294@localhost.localdomain>
[not found] ` <150305084408.ZM20963@torch.brasslantern.com>
2015-03-05 17:06 ` Peter Stephenson
2015-03-08 22:53 ` Han Pingtian
2015-03-09 16:37 ` Bart Schaefer [this message]
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=150309093718.ZM12425@torch.brasslantern.com \
--to=schaefer@brasslantern.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).