From ae146b0fe238a693e51233da1650004c2eb32b19 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 21 Dec 2011 22:39:28 +0000 Subject: 30041: fix bash-style offsets for positional parameters when scalars --- Src/subst.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'Src/subst.c') 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) -- cgit 1.4.1