mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
-o posix: always recognise octals in "let" builtin
Though the "let" builtin is not itself a POSIX standard command, it processes standard shell arithmetic, so it should recognise octals by leading zeros as POSIX requires if the 'posix' option is on. This overrides the setting of the 'letoctal' option. Note that none of this applies to the ((...)) arithmetic command, which has always recognised leading-octal zeros and does not listen to 'letoctal'. So setting the posix mode makes this consistent. src/cmd/ksh93/sh/arith.c: - When running the 'let' builtin, test that both SH_LETOCTAL and SH_POSIX are off before stripping leading zeros to disable octal number recognition. - Cosmetic: fix spurious newline. src/cmd/ksh93/sh.1: - Document the change. src/cmd/ksh93/tests/shtests: - Make sure to disable posix mode by default for regression tests.
This commit is contained in:
parent
921bbcaeb7
commit
b301d41731
5 changed files with 19 additions and 10 deletions
|
@ -390,8 +390,11 @@ static Sfdouble_t arith(const char **ptr, struct lval *lvalue, int type, Sfdoubl
|
|||
char lastbase=0, *val = xp, oerrno = errno;
|
||||
lvalue->eflag = 0;
|
||||
errno = 0;
|
||||
if(shp->bltindata.bnode==SYSLET && !sh_isoption(SH_LETOCTAL))
|
||||
{
|
||||
if(shp->bltindata.bnode==SYSLET && !sh_isoption(SH_LETOCTAL) && !sh_isoption(SH_POSIX))
|
||||
{ /*
|
||||
* Since we're running the "let" builtin, disable octal number processing by
|
||||
* skipping all initial zeros, unless the 'letoctal' or 'posix' option is on.
|
||||
*/
|
||||
while(*val=='0' && isdigit(val[1]))
|
||||
val++;
|
||||
}
|
||||
|
@ -415,8 +418,7 @@ static Sfdouble_t arith(const char **ptr, struct lval *lvalue, int type, Sfdoubl
|
|||
c='e';
|
||||
else
|
||||
c = *str;
|
||||
if(c==GETDECIMAL(0) || c=='e' || c == 'E' || lastbase ==
|
||||
16 && (c == 'p' || c == 'P'))
|
||||
if(c==GETDECIMAL(0) || c=='e' || c == 'E' || lastbase == 16 && (c == 'p' || c == 'P'))
|
||||
{
|
||||
lvalue->isfloat=1;
|
||||
r = strtold(val,&str);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue