Skip to content

Commit

Permalink
arith.c: fix: cmd with radix point error not recorded in history
Browse files Browse the repository at this point in the history
Reproducer on interactive shell:

    $ LC_NUMERIC=nl_NL
    $ ((x=1.2))
    -ksh: 1.2: radix point '.' requires LC_NUMERIC=C
    $ ▂    ← arrow up: ((x=1.2)) not retrieved from history

The errormsg() call on arith.c:463 prevented the command from being
entered into the command history. This problem is similar to the
one fixed in 9348ceb.

A partial call stack to this errormsg() call is:

	arith.c:463	arith()
	streval.c:857	expr() calls arith() via *vp->convert
	streval.c:673	expr() calls expr()
	streval.c:906	arith_compile() calls expr()

Error messages are handled in streval.c:906 by checking if
cur.errmsg.value is set; errmsg is a struct lvalue. Error
messages can be passed from arith() via the lvalue pointer;
arith_compile() then does proper error message handling.

src/cmd/ksh93/sh/arith.c: arith():
- Pass the error message back to arith_compile() via lvalue->value.
  • Loading branch information
McDutchie committed Nov 3, 2024
1 parent ff73450 commit 2010caa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/cmd/ksh93/sh/arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,9 @@ static Sfdouble_t arith(const char **ptr, struct lval *lvalue, int type, Sfdoubl
c = *str;
if(c=='.' && sh.radixpoint!='.')
{
errormsg(SH_DICT,ERROR_exit(1),"%s: radix point '.' requires LC_NUMERIC=C",val);
UNREACHABLE();
sfprintf(sh.strbuf, "%s: radix point '.' requires LC_NUMERIC=C", val);
lvalue->value = sfstruse(sh.strbuf);
return r;
}
if(c==sh.radixpoint || c=='e' || c == 'E' || lastbase == 16 && (c == 'p' || c == 'P'))
{
Expand Down

0 comments on commit 2010caa

Please sign in to comment.