Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/uu/ls/src/dired.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub fn print_dired_output(
out: &mut BufWriter<Stdout>,
) -> UResult<()> {
out.flush()?;
if dired.padding == 0 && !dired.dired_positions.is_empty() {
if !dired.dired_positions.is_empty() {
print_positions("//DIRED//", &dired.dired_positions);
}
if config.recursive {
Expand Down
4 changes: 2 additions & 2 deletions src/uu/ls/src/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,8 @@ impl Config {
let mut quoting_style = extract_quoting_style(options, show_control);
let indicator_style = extract_indicator_style(options);
// Only parse the value to "--time-style" if it will become relevant.
let time_style = if format == Format::Long {
let dired = options.get_flag(options::DIRED);
let time_style = if format == Format::Long || dired {
parse_time_style(options)?
} else {
TimeStyle::Iso
Expand Down Expand Up @@ -1092,7 +1093,6 @@ impl Config {
None
};

let dired = options.get_flag(options::DIRED);
if dired || is_dired_arg_present() {
// --dired implies --format=long
// if we have --dired --hyperlink, we don't show dired but we still want to see the
Expand Down
36 changes: 36 additions & 0 deletions tests/by-util/test_ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4058,6 +4058,42 @@ fn test_ls_dired_recursive() {
.stdout_contains("//DIRED-OPTIONS// --quoting-style");
}

#[test]
fn test_ls_dired_outputs_parent_offset() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.mkdir("dir");
at.mkdir("dir/a");
scene
.ucmd()
.arg("--dired")
.arg("dir")
.arg("-R")
.succeeds()
.stdout_contains("//DIRED//");
}

#[test]
fn test_ls_dired_outputs_same_date_time_format() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.mkdir("dir");
at.mkdir("dir/a");
let binding = scene.ucmd().arg("-l").arg("dir").run();
let long_output_str = binding.stdout_str();
let split_lines: Vec<&str> = long_output_str.split('\n').collect();
// the second line should contain the long output which includes date
let list_line = split_lines.get(1).unwrap();
// should be same as the dired output
scene
.ucmd()
.arg("--dired")
.arg("dir")
.arg("-R")
.succeeds()
.stdout_contains(list_line);
}

#[test]
fn test_ls_dired_recursive_multiple() {
let scene = TestScenario::new(util_name!());
Expand Down