mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 03:57:44 +00:00
ls: take -l
into account with dereference-command-line
This commit is contained in:
parent
5c28ac1b0d
commit
2c130ae7c0
2 changed files with 61 additions and 0 deletions
|
@ -501,6 +501,7 @@ impl Config {
|
||||||
Dereference::DirArgs
|
Dereference::DirArgs
|
||||||
} else if options.is_present(options::DIRECTORY)
|
} else if options.is_present(options::DIRECTORY)
|
||||||
|| indicator_style == IndicatorStyle::Classify
|
|| indicator_style == IndicatorStyle::Classify
|
||||||
|
|| format == Format::Long
|
||||||
{
|
{
|
||||||
Dereference::None
|
Dereference::None
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1353,6 +1353,13 @@ fn test_ls_deref_command_line() {
|
||||||
at.touch("some_file");
|
at.touch("some_file");
|
||||||
at.symlink_file("some_file", "sym_file");
|
at.symlink_file("some_file", "sym_file");
|
||||||
|
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("sym_file")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_is("sym_file\n");
|
||||||
|
|
||||||
|
// -l changes the default to no dereferencing
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg("-l")
|
.arg("-l")
|
||||||
|
@ -1360,6 +1367,13 @@ fn test_ls_deref_command_line() {
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_contains("sym_file ->");
|
.stdout_contains("sym_file ->");
|
||||||
|
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("--dereference-command-line-symlink-to-dir")
|
||||||
|
.arg("sym_file")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_is("sym_file\n");
|
||||||
|
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg("-l")
|
.arg("-l")
|
||||||
|
@ -1368,6 +1382,13 @@ fn test_ls_deref_command_line() {
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_contains("sym_file ->");
|
.stdout_contains("sym_file ->");
|
||||||
|
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("--dereference-command-line")
|
||||||
|
.arg("sym_file")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_is("sym_file\n");
|
||||||
|
|
||||||
let result = scene
|
let result = scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg("-l")
|
.arg("-l")
|
||||||
|
@ -1400,11 +1421,24 @@ fn test_ls_deref_command_line_dir() {
|
||||||
|
|
||||||
at.touch("some_dir/nested_file");
|
at.touch("some_dir/nested_file");
|
||||||
|
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("sym_dir")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_contains("nested_file");
|
||||||
|
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg("-l")
|
.arg("-l")
|
||||||
.arg("sym_dir")
|
.arg("sym_dir")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
|
.stdout_contains("sym_dir ->");
|
||||||
|
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("--dereference-command-line-symlink-to-dir")
|
||||||
|
.arg("sym_dir")
|
||||||
|
.succeeds()
|
||||||
.stdout_contains("nested_file");
|
.stdout_contains("nested_file");
|
||||||
|
|
||||||
scene
|
scene
|
||||||
|
@ -1415,6 +1449,13 @@ fn test_ls_deref_command_line_dir() {
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_contains("nested_file");
|
.stdout_contains("nested_file");
|
||||||
|
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("--dereference-command-line")
|
||||||
|
.arg("sym_dir")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_contains("nested_file");
|
||||||
|
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg("-l")
|
.arg("-l")
|
||||||
|
@ -1469,4 +1510,23 @@ fn test_ls_deref_command_line_dir() {
|
||||||
.succeeds();
|
.succeeds();
|
||||||
|
|
||||||
assert!(!result.stdout_str().ends_with("sym_dir"));
|
assert!(!result.stdout_str().ends_with("sym_dir"));
|
||||||
|
|
||||||
|
// --classify does not dereference anything by default
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("-l")
|
||||||
|
.arg("--directory")
|
||||||
|
.arg("sym_dir")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_contains("sym_dir ->");
|
||||||
|
|
||||||
|
let result = scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("-l")
|
||||||
|
.arg("--directory")
|
||||||
|
.arg("--dereference-command-line-symlink-to-dir")
|
||||||
|
.arg("sym_dir")
|
||||||
|
.succeeds();
|
||||||
|
|
||||||
|
assert!(!result.stdout_str().ends_with("sym_dir"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue