mirror of
https://github.com/uutils/coreutils.git
synced 2025-12-23 08:47:37 +00:00
echo: show version when using --version
This commit is contained in:
parent
afbe90feaf
commit
9c08dd9851
2 changed files with 12 additions and 0 deletions
|
|
@ -167,6 +167,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
// echo --help
|
||||
uu_app().print_help()?;
|
||||
return Ok(());
|
||||
} else if args.len() == 1 && args[0] == "--version" {
|
||||
print!("{}", uu_app().render_version());
|
||||
return Ok(());
|
||||
} else {
|
||||
// if POSIXLY_CORRECT is not set we filter the flags normally
|
||||
filter_flags(args.into_iter())
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore (words) araba merci efjkow
|
||||
|
||||
use regex::Regex;
|
||||
use uutests::new_ucmd;
|
||||
use uutests::util::TestScenario;
|
||||
use uutests::util::UCommand;
|
||||
|
|
@ -514,6 +515,14 @@ fn partial_help_argument() {
|
|||
new_ucmd!().arg("--he").succeeds().stdout_is("--he\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn full_version_argument() {
|
||||
new_ucmd!()
|
||||
.arg("--version")
|
||||
.succeeds()
|
||||
.stdout_matches(&Regex::new(r"^echo \(uutils coreutils\) (\d+\.\d+\.\d+)\n$").unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_help_argument_prints_help() {
|
||||
assert_ne!(new_ucmd!().arg("--help").succeeds().stdout(), b"--help\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue