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:
parent
0c7b5530d6
commit
5ddabb8348
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
4
bin/sh/tests/parameters/positional4.0
Normal file
4
bin/sh/tests/parameters/positional4.0
Normal file
@ -0,0 +1,4 @@
|
||||
# $FreeBSD$
|
||||
|
||||
set -- "x$0" 2 3 4 5 6 7 8 9 "y$0"
|
||||
[ "${01}.${010}" = "$1.${10}" ]
|
Loading…
Reference in New Issue
Block a user