Skip to content

Commit

Permalink
ls: silently ignore -T option (uutils#3718)
Browse files Browse the repository at this point in the history
* ls: silently ignore `-T` option
  • Loading branch information
Stonks3141 authored Jul 26, 2022
1 parent eeb4cda commit 4e72e28
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/uu/ls/src/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// For the full copyright and license information, please view the LICENSE file
// that was distributed with this source code.

// spell-checker:ignore (ToDO) cpio svgz webm somegroup nlink rmvb xspf
// spell-checker:ignore (ToDO) cpio svgz webm somegroup nlink rmvb xspf tabsize

#[macro_use]
extern crate uucore;
Expand Down Expand Up @@ -62,6 +62,7 @@ pub mod options {
pub static LONG: &str = "long";
pub static COLUMNS: &str = "C";
pub static ACROSS: &str = "x";
pub static TAB_SIZE: &str = "tabsize"; // silently ignored (see #3624)
pub static COMMAS: &str = "m";
pub static LONG_NO_OWNER: &str = "g";
pub static LONG_NO_GROUP: &str = "o";
Expand Down Expand Up @@ -891,6 +892,15 @@ pub fn uu_app<'a>() -> Command<'a> {
options::format::COLUMNS,
]),
)
.arg( // silently ignored (see #3624)
Arg::new(options::format::TAB_SIZE)
.short('T')
.long(options::format::TAB_SIZE)
.env("TABSIZE")
.takes_value(true)
.value_name("COLS")
.help("Assume tab stops at each COLS instead of 8 (unimplemented)")
)
.arg(
Arg::new(options::format::COMMAS)
.short('m')
Expand Down
35 changes: 34 additions & 1 deletion tests/by-util/test_ls.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup lrwx somefile somegroup somehiddenbackup somehiddenfile
// spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup lrwx somefile somegroup somehiddenbackup somehiddenfile tabsize aaaaaaaa bbbb cccc dddddddd ncccc

#[cfg(not(windows))]
extern crate libc;
Expand Down Expand Up @@ -3117,3 +3117,36 @@ fn test_dereference_symlink_file_color() {
.succeeds()
.stdout_is(out_exp);
}

#[test]
fn test_tabsize_option() {
let scene = TestScenario::new(util_name!());

scene.ucmd().args(&["-T", "3"]).succeeds();
scene.ucmd().args(&["--tabsize", "0"]).succeeds();
scene.ucmd().arg("-T").fails();
}

#[ignore = "issue #3624"]
#[test]
fn test_tabsize_formatting() {
let (at, mut ucmd) = at_and_ucmd!();

at.touch("aaaaaaaa");
at.touch("bbbb");
at.touch("cccc");
at.touch("dddddddd");

ucmd.args(&["-T", "4"])
.succeeds()
.stdout_is("aaaaaaaa bbbb\ncccc\t dddddddd");

ucmd.args(&["-T", "2"])
.succeeds()
.stdout_is("aaaaaaaa bbbb\ncccc\t\t dddddddd");

// use spaces
ucmd.args(&["-T", "0"])
.succeeds()
.stdout_is("aaaaaaaa bbbb\ncccc dddddddd");
}

0 comments on commit 4e72e28

Please sign in to comment.