1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-26 18:01:03 +02:00

30041: fix bash-style offsets for positional parameters when scalars

This commit is contained in:
Peter Stephenson 2011-12-21 22:39:28 +00:00
parent 1ea6009209
commit ae146b0fe2
2 changed files with 23 additions and 16 deletions

View file

@ -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 $
*****************************************************

View file

@ -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)