coreutils
coreutils copied to clipboard
test: Show error when using a binary operator without two operands
When preforming a binary operation with the test
command, GNU coreutils gives an error if only one operands exist:
$ /bin/test -o blah
/bin/test: ‘-o’: unary operator expected
$ /bin/test -a blah
/bin/test: ‘-a’: unary operator expected
$ /bin/test blah -a
/bin/test: missing argument after ‘-a’
$ /bin/test blah -o
/bin/test: missing argument after ‘-o’
This PR adds the error messages for the first set, where the first operand is missing. The second operand missing does not appear as trivial, since Symbol::new
causes the operator to be treated as a literal as part of the parsing.
With this PR, tests/test/test-diag.pl
should pass.
This PR also fixes an integration test that says that -a !
should return an exit code of 1. GNU test
gives an error with a status code of 2.
GNU testsuite comparison:
Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/test/test-diag is no longer failing!
@sargas
The second operand missing does not appear as trivial, since Symbol::new causes the operator to be treated as a literal as part of the parsing.
This should still be done right? Should we open an issue for it in meantime?
@sargas
The second operand missing does not appear as trivial, since Symbol::new causes the operator to be treated as a literal as part of the parsing.
This should still be done right? Should we open an issue for it in meantime?
Agreed, especially since the GNU tests didn't check for this. I can have a go at this tonight
@sargas ping ? :)
@sargas ping ? :)
Sorry, busier than expected, still interested in this PR. Whether <blah> -a
shows an error is different for an arbitrary string and for !
, so I wanted to create some more test cases
GNU testsuite comparison:
Congrats! The gnu test tests/test/test-diag is no longer failing!