1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

realpath: add "--no-symlinks" alias

This commit is contained in:
Daniel Hofstetter 2022-06-28 15:58:16 +02:00 committed by Sylvestre Ledru
parent a66527e3e2
commit 113f0bd92b
2 changed files with 33 additions and 26 deletions

View file

@ -86,6 +86,7 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(OPT_STRIP) Arg::new(OPT_STRIP)
.short('s') .short('s')
.long(OPT_STRIP) .long(OPT_STRIP)
.visible_alias("no-symlinks")
.help("Only strip '.' and '..' components, but don't resolve symbolic links"), .help("Only strip '.' and '..' components, but don't resolve symbolic links"),
) )
.arg( .arg(

View file

@ -65,50 +65,56 @@ fn test_realpath_file_and_links_zero() {
#[test] #[test]
fn test_realpath_file_and_links_strip() { fn test_realpath_file_and_links_strip() {
let strip_args = ["-s", "--strip", "--no-symlinks"];
let scene = TestScenario::new(util_name!()); let scene = TestScenario::new(util_name!());
let at = &scene.fixtures; let at = &scene.fixtures;
at.touch("foo"); at.touch("foo");
at.symlink_file("foo", "bar"); at.symlink_file("foo", "bar");
scene for strip_arg in strip_args {
.ucmd() scene
.arg("foo") .ucmd()
.arg("-s") .arg("foo")
.succeeds() .arg(strip_arg)
.stdout_contains("foo\n"); .succeeds()
.stdout_contains("foo\n");
scene scene
.ucmd() .ucmd()
.arg("bar") .arg("bar")
.arg("-s") .arg(strip_arg)
.succeeds() .succeeds()
.stdout_contains("bar\n"); .stdout_contains("bar\n");
}
} }
#[test] #[test]
fn test_realpath_file_and_links_strip_zero() { fn test_realpath_file_and_links_strip_zero() {
let strip_args = ["-s", "--strip", "--no-symlinks"];
let scene = TestScenario::new(util_name!()); let scene = TestScenario::new(util_name!());
let at = &scene.fixtures; let at = &scene.fixtures;
at.touch("foo"); at.touch("foo");
at.symlink_file("foo", "bar"); at.symlink_file("foo", "bar");
scene for strip_arg in strip_args {
.ucmd() scene
.arg("foo") .ucmd()
.arg("-s") .arg("foo")
.arg("-z") .arg(strip_arg)
.succeeds() .arg("-z")
.stdout_contains("foo\u{0}"); .succeeds()
.stdout_contains("foo\u{0}");
scene scene
.ucmd() .ucmd()
.arg("bar") .arg("bar")
.arg("-s") .arg(strip_arg)
.arg("-z") .arg("-z")
.succeeds() .succeeds()
.stdout_contains("bar\u{0}"); .stdout_contains("bar\u{0}");
}
} }
#[test] #[test]