summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2011-12-21 22:39:28 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2011-12-21 22:39:28 +0000
commitae146b0fe238a693e51233da1650004c2eb32b19 (patch)
tree6bcbda9f99ac4b8d884a7e5fc7a507f75846da0b
parent1ea6009209a7aae69188d70fa3cb7d260346f059 (diff)
downloadzsh-ae146b0fe238a693e51233da1650004c2eb32b19.tar.gz
zsh-ae146b0fe238a693e51233da1650004c2eb32b19.zip
30041: fix bash-style offsets for positional parameters when scalars
-rw-r--r--ChangeLog7
-rw-r--r--Src/subst.c32
2 files changed, 23 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 4298f83d0..52e672f88 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2011-12-21 Peter Stephenson <p.w.stephenson@ntlworld.com>
+ * 30041: Src/subst.c: the offset hack to make
+ ${foo:offset:length} bash compatible with positional parameters
+ doesn't apply when we're indexing into characters of one
+ positional parameter.
+
* T.C. Hollingsworth: 30036: Completion/Unix/Command/_systemctl:
new arguments.
@@ -15786,5 +15791,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5547 $
+* $Revision: 1.5548 $
*****************************************************
diff --git a/Src/subst.c b/Src/subst.c
index 4e8ed721d..ea6bf3af2 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2878,24 +2878,26 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
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)