Re: test -lt inconsistent about white space

2023-10-30 Thread Paul Eggert
On 2023-10-30 08:09, Chet Ramey wrote: The fact that this whitespace issue hasn't been reported since then shows how obscure it is. Yes, I noticed it only because coreutils 'test' was incompatible with Bash. (It was also incompatible with everybody else!) I recently changed bleeding-edge

Re: test -lt inconsistent about white space

2023-10-30 Thread Chet Ramey
On 10/29/23 6:18 AM, Oğuz wrote: legal_number was isint, which skipped both leading and trailing space using the whitespace macro. Yes, 30 years ago. legal_number switched to using strtol(3) in 1997 (bash-2.02) and strtoimax in 2002 (bash-2.05b). The fact that this whitespace issue hasn't

Re: test -lt inconsistent about white space

2023-10-30 Thread Chet Ramey
On 10/28/23 3:08 PM, Paul Eggert wrote: The problem occurs because strtoimax accepts all forms of leading whitespace, whereas Bash accepts only space and tab after the integer. This is inconsistent: Bash should treat trailing whitespace the same way it treats leading whitespace, and should

Re: test -lt inconsistent about white space

2023-10-30 Thread Chet Ramey
On 10/29/23 3:43 AM, Martin D Kealey wrote: I'm more concerned that the error message is misleading; "integer expression expected" is NOT true; rather an integer LITERAL is expected (meaning an optional sign followed by one or more digits). This got changed about a year ago, after

Re: test -lt inconsistent about white space

2023-10-29 Thread Paul Eggert
On 2023-10-29 03:18, Oğuz wrote: I think the intented behavior was skipping both leading and trailing horizontal whitespace, which makes sense as a QOL feature, and switching over to strtoimax changed this. If that's the intent, which is self-consistent but which disagrees with all other

Re: test -lt inconsistent about white space

2023-10-29 Thread Oğuz
On Sun, Oct 29, 2023 at 8:49 AM Paul Eggert wrote: > My understanding is that Bash was intended to allow both leading and > trailing whitespace. This is compatible with ksh and with Dash. If > that's the intent, Bash should be consistent about it, just as ksh and > Dash are. There seems little

Re: test -lt inconsistent about white space

2023-10-29 Thread Martin D Kealey
I'm more concerned that the error message is misleading; "integer expression expected" is NOT true; rather an integer LITERAL is expected (meaning an optional sign followed by one or more digits). As for fixing the inconsistency, I would rather get rid of whitespace skipping entirely, perhaps

Re: test -lt inconsistent about white space

2023-10-29 Thread Robert Elz
Date:Sat, 28 Oct 2023 22:49:13 -0700 From:Paul Eggert Message-ID: | I don't know what bosh is. bosh is a modernised (updated) variant of the SysVR4 Bourne shell I believe - it used to be maintained by Joerg Schilling (and still contains bugs). | PS. As I

Re: test -lt inconsistent about white space

2023-10-28 Thread Paul Eggert
On 2023-10-28 18:41, Oğuz wrote: Why? The same commands fail on bosh, yash, and zsh too. I don't know what bosh is. zsh and yash prohibit trailing spaces in integers, but allow leading spaces: % test ' 3' -lt ' 4' % test ' 3 ' -lt ' 4 ' test: integer expression expected: 3

Re: test -lt inconsistent about white space

2023-10-28 Thread Oğuz
On Saturday, October 28, 2023, Paul Eggert wrote: > Bash should treat trailing whitespace the same way it treats leading > whitespace, Why? The same commands fail on bosh, yash, and zsh too. -- Oğuz

test -lt inconsistent about white space

2023-10-28 Thread Paul Eggert
Consider the following shell script 'doit': sp=' ' nl=' ' test "${sp}1${sp}" -lt "${sp}2${sp}" test "${nl}3${sp}" -lt "${nl}4${sp}" test "${sp}5${nl}" -lt "${sp}6${nl}" test "${nl}7${nl}" -lt "${nl}8${nl}" Running the command "bash doit" outputs: doit: line 6: test: 5 : integer expression