evalvar() records empty expansion results (varlen == 0) as string regions that need to be scanned for IFS characters. This is pointless, because there is nothing to split. This patch fixes the following bug, which is apparently a side effect of the above: $ dash -c 'IFS=; set -- set -- $@ $*; printf $#, set -- $@ $*; printf $#, set -- $@ $*; echo $#' 2,4,8 Expected output: 0,0,0. Given set & empty IFS and no positional parameters, unquoted $@ and $* incorrectly generate one empty field (they should generate no fields). - M.
diff --git a/src/expand.c b/src/expand.c index 705fef7..03a9b0c 100644 --- a/src/expand.c +++ b/src/expand.c @@ -771,7 +771,7 @@ vsplus: if (subtype == VSNORMAL) { record: - if (!easy) + if (!easy || varlen == 0) goto end; recordregion(startloc, expdest - (char *)stackblock(), quoted); goto end;