summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/uu/ls/src/ls.rs12
-rw-r--r--tests/by-util/test_ls.rs35
2 files changed, 45 insertions, 2 deletions
diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs
index d06bfe360..5da64abe5 100644
--- a/src/uu/ls/src/ls.rs
+++ b/src/uu/ls/src/ls.rs
@@ -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;
@@ -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";
@@ -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')
diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs
index 4c14024c4..dc6ce3bd1 100644
--- a/tests/by-util/test_ls.rs
+++ b/tests/by-util/test_ls.rs
@@ -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;
@@ -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");
+}