Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9c08dd9

Browse files
committed
echo: show version when using --version
1 parentafbe90f commit9c08dd9

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

‎src/uu/echo/src/echo.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
167167
// echo --help
168168
uu_app().print_help()?;
169169
returnOk(());
170+
}elseif args.len() ==1 && args[0] =="--version"{
171+
print!("{}", uu_app().render_version());
172+
returnOk(());
170173
}else{
171174
// if POSIXLY_CORRECT is not set we filter the flags normally
172175
filter_flags(args.into_iter())

‎tests/by-util/test_echo.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// file that was distributed with this source code.
55
// spell-checker:ignore (words) araba merci efjkow
66

7+
use regex::Regex;
78
use uutests::new_ucmd;
89
use uutests::util::TestScenario;
910
use uutests::util::UCommand;
@@ -514,6 +515,14 @@ fn partial_help_argument() {
514515
new_ucmd!().arg("--he").succeeds().stdout_is("--he\n");
515516
}
516517

518+
#[test]
519+
fnfull_version_argument(){
520+
new_ucmd!()
521+
.arg("--version")
522+
.succeeds()
523+
.stdout_matches(&Regex::new(r"^echo \(uutils coreutils\) (\d+\.\d+\.\d+)\n$").unwrap());
524+
}
525+
517526
#[test]
518527
fnonly_help_argument_prints_help(){
519528
assert_ne!(new_ucmd!().arg("--help").succeeds().stdout(),b"--help\n");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp