Repository navigation
Conversation
|
I'm not sure if we really want to support this. |
| The utility can also be selected with `--coreutils-prog=UTIL`, including when | ||
| the binary is invoked under an unrecognized name. This supports script wrappers | ||
| that use the multi-call binary as their interpreter. | ||
|
|
There was a problem hiding this comment.
I think we don't need to document this since this option is needed only for creating shebangs at build time.
fd3dbe1 to
e957d89
Compare
| .into_owned() | ||
| .to_string_lossy(); | ||
| if get_utility_is_second_arg() { | ||
| name.strip_prefix("--coreutils-prog=") |
There was a problem hiding this comment.
uucore can be used as a library. So this logic should be part of coreutils itself.
e957d89 to
71d7d8f
Compare
|
|
||
| #[test] | ||
| #[cfg(all(unix, feature = "echo"))] | ||
| fn coreutils_prog_shebang() { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
ab063ca to
5a943b1
Compare
| } else if let Some(util) = args | ||
| .peek() | ||
| .and_then(|arg| arg.to_str()) | ||
| .and_then(|arg| arg.strip_prefix("--coreutils-prog=")) |
There was a problem hiding this comment.
--coreutils-prog=--list prints the list and --coreutils-prog=--version the multicall version, is that intended?
I would only accept names that are in utils here
| .and_then(|arg| arg.to_str()) | ||
| .and_then(|arg| arg.strip_prefix("--coreutils-prog=")) | ||
| { | ||
| uucore::set_utility_name(util.to_owned()); |
There was a problem hiding this comment.
this also sets the name for --coreutils-prog=missing_program or an empty one, could it be set only once we know the util exists?
|
please also remove the |
| } | ||
|
|
||
| #[test] | ||
| #[cfg(all(feature = "echo", feature = "true", feature = "false"))] |
There was a problem hiding this comment.
please add a test that an error message uses the selected name, e.g. --coreutils-prog=ls /nonexistent should start with ls:
that's the whole point of the uucore change
| assert_eq!(output.stdout, b"hello world\n"); | ||
| assert!(output.stderr.is_empty()); | ||
| for (name, expected) in [("true", 0), ("false", 1), ("missing_program", 1), ("", 1)] { | ||
| let output = Command::new(&scene.bin_path) |
There was a problem hiding this comment.
please also check stderr for the invalid cases, an exit code of 1 alone is weak
There was a problem hiding this comment.
But we use different error message with GNU at coreutils currently which does not affect to its meaning.
5a943b1 to
93118c8
Compare
| @@ -211,7 +211,6 @@ sed -i 's/^print_ver_.*/require_selinux_/' tests/runcon/runcon-no-reorder.sh | |||
| sed -i 's/^print_ver_.*/require_selinux_/' tests/chcon/chcon-fail.sh | |||
|
|
|||
| # We use coreutils yes | |||
There was a problem hiding this comment.
| # We use coreutils yes |
Remove this too.
Accept --coreutils-prog=UTIL for explicit utility selection, including when the executable has an unrecognized name. Parse the option in the multicall entry point and provide the selected display name through a generic uucore override. Cover argument forwarding, exit status, invalid utilities, and aliases. Closes uutils#9575.
93118c8 to
81e68ed
Compare
Support --coreutils-prog=UTIL when invoking the multicall binary, including under an unrecognized name or through a shebang wrapper. Help and diagnostics use the selected utility name.
Add coverage for argument forwarding, exit status, invalid utilities, aliases, and shebang execution. All 20 multicall tests pass.
Closes #9575.