Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: wrong array range with (r) flag on scalar?
- X-seq: zsh-workers 34687
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: wrong array range with (r) flag on scalar?
- Date: Mon, 9 Mar 2015 09:37:18 -0700
- In-reply-to: <20150308225336.GA2746@localhost.localdomain>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20150305083000.GA3294@localhost.localdomain> <150305084408.ZM20963@torch.brasslantern.com> <20150305170638.0d10ba1b@pwslap01u.europe.root.pri> <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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author