Skip to content

Conversation

@rwdj
Copy link
Contributor

@rwdj rwdj commented Feb 16, 2025

Went through the list in #5692 and found inconsistencies for unlink, runcon, test, and hashsum.

runcon uutils:

runcon [CONTEXT COMMAND [ARG...]]

but runcon requires a context command to function:

runcon: No command is specified

unlink uutils:

unlink [FILE]

but unlink requires a file to unlink:

error: the following required arguments were not provided:
  <FILE>

hashsum:

hashsum [OPTIONS] [FILE]...

but hashsum requires a digest to operate and may take multiple options:

hashsum: Needs an algorithm to hash with.

test uutils:

test EXPRESSION
[
[ EXPRESSION ]
[ ]
[ OPTION
]

but:

  1. [ alone is not a valid test command:

     [: missing ']'
    
  2. test alone is a valid test command.

  3. ] alone is not a valid test command.

As appropriate, this matches GNU behavior.

rwdj added 3 commits February 15, 2025 18:51
runcon requires a context command. Update usage string to match GNU
behavior.
unlink must either take an option or a file. Update usage string to
match GNU behavior.
hashsum requires a --<digest> and may accept multiple options.
@rwdj rwdj changed the title Fix 5692 usage strings Fix #5692 usage strings Feb 16, 2025
@rwdj rwdj changed the title Fix #5692 usage strings Fix some usage strings Feb 16, 2025
@rwdj rwdj changed the title Fix some usage strings Fix some usage strings for #5692 Feb 16, 2025
@rwdj
Copy link
Contributor Author

rwdj commented Feb 16, 2025

Just noticed test in that list. Trying to figure out how to get it to spit out the usage message.

@rwdj
Copy link
Contributor Author

rwdj commented Feb 16, 2025

Added test usage string fixes.

`[` alone is not a valid test command.
`test` alone is a valid test command.
`]` alone is not a valid test command.

Update usage string to match GNU behavior.
@rwdj rwdj force-pushed the fix-5692-usage-strings branch from 3350345 to 55502cb Compare February 16, 2025 01:27
@rwdj rwdj changed the title Fix some usage strings for #5692 Fix usage strings for #5692 Feb 16, 2025
@sylvestre
Copy link
Contributor

[ alone is not a valid test command:

I think it is legit :)

test can be symlink to [
which is used in bash like in

if [ foo ]; then

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)

@rwdj
Copy link
Contributor Author

rwdj commented Feb 16, 2025

@sylvestre While true, I think you misunderstood me. I'm not saying [, but only [.

Neither Bash nor uutil will accept only [ as a command. They both result in:

[: missing `]'

I'm willing to bet uutil's behavior here was actually modeled after Bash than GNU.

GNU test, from what I can figure, will accept only [, although it isn't documented. But I'll double check that in a bit. Either way, uutils's documented usage is different from GNU's test documented usage.

So, (assuming I'm correct about GNU test behavior which I'm going to double check) there's one of two options: match with GNU's undocumented acceptance of just [, or update uutil to match GNU's documentation and uutil's behavior.

@rwdj
Copy link
Contributor Author

rwdj commented Feb 16, 2025

I figured out how to disable the [ builtin in bash:

enable -n [

And then it can be checked with:

$ [ --version

uutils, Bash, and GNU [ all report:

$ [
[: missing ‘]’

So, it's only uutil's documentation that's inconsistent

@sylvestre sylvestre merged commit 511590a into uutils:main Feb 16, 2025
64 of 65 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants