mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
ls: fixed dired option (-D) not outputting datetime and parent dir byte offsets (#6538)
Closes #6522
This commit is contained in:
parent
b774000351
commit
ea478c2bb6
3 changed files with 39 additions and 3 deletions
|
@ -110,7 +110,7 @@ pub fn print_dired_output(
|
||||||
out: &mut BufWriter<Stdout>,
|
out: &mut BufWriter<Stdout>,
|
||||||
) -> UResult<()> {
|
) -> UResult<()> {
|
||||||
out.flush()?;
|
out.flush()?;
|
||||||
if dired.padding == 0 && !dired.dired_positions.is_empty() {
|
if !dired.dired_positions.is_empty() {
|
||||||
print_positions("//DIRED//", &dired.dired_positions);
|
print_positions("//DIRED//", &dired.dired_positions);
|
||||||
}
|
}
|
||||||
if config.recursive {
|
if config.recursive {
|
||||||
|
|
|
@ -971,7 +971,8 @@ impl Config {
|
||||||
let mut quoting_style = extract_quoting_style(options, show_control);
|
let mut quoting_style = extract_quoting_style(options, show_control);
|
||||||
let indicator_style = extract_indicator_style(options);
|
let indicator_style = extract_indicator_style(options);
|
||||||
// Only parse the value to "--time-style" if it will become relevant.
|
// 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)?
|
parse_time_style(options)?
|
||||||
} else {
|
} else {
|
||||||
TimeStyle::Iso
|
TimeStyle::Iso
|
||||||
|
@ -1092,7 +1093,6 @@ impl Config {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let dired = options.get_flag(options::DIRED);
|
|
||||||
if dired || is_dired_arg_present() {
|
if dired || is_dired_arg_present() {
|
||||||
// --dired implies --format=long
|
// --dired implies --format=long
|
||||||
// if we have --dired --hyperlink, we don't show dired but we still want to see the
|
// if we have --dired --hyperlink, we don't show dired but we still want to see the
|
||||||
|
|
|
@ -4058,6 +4058,42 @@ fn test_ls_dired_recursive() {
|
||||||
.stdout_contains("//DIRED-OPTIONS// --quoting-style");
|
.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]
|
#[test]
|
||||||
fn test_ls_dired_recursive_multiple() {
|
fn test_ls_dired_recursive_multiple() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue