sh: Consistently treat ${01} like $1.

Leading zeroes were ignored when checking whether a positional parameter is
set, but not when expanding its value. Ignore leading zeroes in any case.
This commit is contained in:
Jilles Tjoelker 2014-07-12 10:27:30 +00:00
parent 0c7b5530d6
commit 5ddabb8348
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=268568
3 changed files with 11 additions and 7 deletions

View File

@ -928,17 +928,16 @@ varvalue(const char *name, int quoted, int subtype, int flag)
STPUTC(sep, expdest);
}
break;
case '0':
p = arg0;
strtodest(p, flag, subtype, quoted);
break;
default:
if (is_digit(*name)) {
num = atoi(name);
if (num > 0 && num <= shellparam.nparam) {
if (num == 0)
p = arg0;
else if (num > 0 && num <= shellparam.nparam)
p = shellparam.p[num - 1];
strtodest(p, flag, subtype, quoted);
}
else
break;
strtodest(p, flag, subtype, quoted);
}
break;
}

View File

@ -14,6 +14,7 @@ FILES+= optind2.0
FILES+= positional1.0
FILES+= positional2.0
FILES+= positional3.0
FILES+= positional4.0
FILES+= pwd1.0
FILES+= pwd2.0

View File

@ -0,0 +1,4 @@
# $FreeBSD$
set -- "x$0" 2 3 4 5 6 7 8 9 "y$0"
[ "${01}.${010}" = "$1.${10}" ]