From 113f0bd92be284a5c00c9b4848601755349a147c Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 28 Jun 2022 15:58:16 +0200 Subject: [PATCH] realpath: add "--no-symlinks" alias --- src/uu/realpath/src/realpath.rs | 1 + tests/by-util/test_realpath.rs | 58 ++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/uu/realpath/src/realpath.rs b/src/uu/realpath/src/realpath.rs index 403e7c456..320545d41 100644 --- a/src/uu/realpath/src/realpath.rs +++ b/src/uu/realpath/src/realpath.rs @@ -86,6 +86,7 @@ pub fn uu_app<'a>() -> Command<'a> { Arg::new(OPT_STRIP) .short('s') .long(OPT_STRIP) + .visible_alias("no-symlinks") .help("Only strip '.' and '..' components, but don't resolve symbolic links"), ) .arg( diff --git a/tests/by-util/test_realpath.rs b/tests/by-util/test_realpath.rs index e0875cc77..c469eb0da 100644 --- a/tests/by-util/test_realpath.rs +++ b/tests/by-util/test_realpath.rs @@ -65,50 +65,56 @@ fn test_realpath_file_and_links_zero() { #[test] fn test_realpath_file_and_links_strip() { + let strip_args = ["-s", "--strip", "--no-symlinks"]; let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; at.touch("foo"); at.symlink_file("foo", "bar"); - scene - .ucmd() - .arg("foo") - .arg("-s") - .succeeds() - .stdout_contains("foo\n"); + for strip_arg in strip_args { + scene + .ucmd() + .arg("foo") + .arg(strip_arg) + .succeeds() + .stdout_contains("foo\n"); - scene - .ucmd() - .arg("bar") - .arg("-s") - .succeeds() - .stdout_contains("bar\n"); + scene + .ucmd() + .arg("bar") + .arg(strip_arg) + .succeeds() + .stdout_contains("bar\n"); + } } #[test] fn test_realpath_file_and_links_strip_zero() { + let strip_args = ["-s", "--strip", "--no-symlinks"]; let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; at.touch("foo"); at.symlink_file("foo", "bar"); - scene - .ucmd() - .arg("foo") - .arg("-s") - .arg("-z") - .succeeds() - .stdout_contains("foo\u{0}"); + for strip_arg in strip_args { + scene + .ucmd() + .arg("foo") + .arg(strip_arg) + .arg("-z") + .succeeds() + .stdout_contains("foo\u{0}"); - scene - .ucmd() - .arg("bar") - .arg("-s") - .arg("-z") - .succeeds() - .stdout_contains("bar\u{0}"); + scene + .ucmd() + .arg("bar") + .arg(strip_arg) + .arg("-z") + .succeeds() + .stdout_contains("bar\u{0}"); + } } #[test]