From: Omar Polo Subject: Re: ksh: use strtonum() To: "Todd C. Miller" Cc: tech@openbsd.org Date: Mon, 26 Aug 2024 23:43:54 +0200 On 2024/08/26 13:32:34 -0600, Todd C. Miller wrote: > On Mon, 26 Aug 2024 10:47:42 +0200, Omar Polo wrote: > > > atoi() is only used in findhistrel(), which in turn is only used if you > > enable csh-like history. findhistrel() is used only once in lex.c. it > > is expected to return the item in the history array to lookup. > > > > Regress still passes (not suprising since csh-history is not tested) and > > runtime testing seems to behave just like before. I do enable and use > > csh-style history expansion, but admittedly only in the most basic > > forms. > > Shouldn't the low limit for strtonum() be 1 in this case? > It looks like findhistrel() returns success for values > 0. I don't think, because it is expected to handle also !-N which is different from !N. It's the `start + rec + 1' part at the end of the function that handles the negative numbers turning them into the offset of the _last_ nth command, instead of the nth command.