add -n for path expand, so it doesn't follow symlink (#6255)

* add -p for path expand, so it doesn't follow symlink

* fix arg name

* rename from no-dereferenct to no-follow-link

* rename from no-follow-link to no-symlink, and change short -p to -n

* follow strict first

* fix

* simplify test

* fix clippy

* fix test on windows
This commit is contained in:
WindSoilder
2022-08-10 21:43:56 +08:00
committed by GitHub
parent 2e5d981a09
commit 0f10d984c3
4 changed files with 90 additions and 20 deletions

View File

@ -57,9 +57,9 @@ impl Command for Cp {
// .switch("force", "suppress error when no file", Some('f'))
.switch("interactive", "ask user to confirm action", Some('i'))
.switch(
"no-dereference",
"If the -r option is specified, no symbolic links are followed.",
Some('p'),
"no-symlink",
"no symbolic links are followed, only works if -r is active",
Some('n'),
)
.category(Category::FileSystem)
}
@ -218,7 +218,7 @@ impl Command for Cp {
)
})?;
let not_follow_symlink = call.has_flag("no-dereference");
let not_follow_symlink = call.has_flag("no-symlink");
let sources = sources.paths_applying_with(|(source_file, depth_level)| {
let mut dest = destination.clone();