Skip to content

Commit

Permalink
cat: ignore -u flag, just like GNU does
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWiederhake committed Mar 1, 2024
1 parent 44cd7b4 commit 31e8e3a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/uu/cat/src/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ mod options {
pub static SHOW_NONPRINTING_TABS: &str = "t";
pub static SHOW_TABS: &str = "show-tabs";
pub static SHOW_NONPRINTING: &str = "show-nonprinting";
pub static IGNORED_U: &str = "ignored-u";
}

#[uucore::main]
Expand Down Expand Up @@ -302,6 +303,12 @@ pub fn uu_app() -> Command {
.help("use ^ and M- notation, except for LF (\\n) and TAB (\\t)")
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::IGNORED_U)
.short('u')
.help("(ignored)")
.action(ArgAction::SetTrue),
)
}

fn cat_handle<R: FdReadable>(
Expand Down
11 changes: 11 additions & 0 deletions tests/by-util/test_cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,3 +612,14 @@ fn test_error_loop() {
.fails()
.stderr_is("cat: 1: Too many levels of symbolic links\n");
}

#[test]
fn test_u_ignored() {
for same_param in ["-u", "-uu"] {
new_ucmd!()
.arg(same_param)
.pipe_in("hello")
.succeeds()
.stdout_only("hello");
}
}

0 comments on commit 31e8e3a

Please sign in to comment.