mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
ls: If we have --dired --hyperlink, we don't show dired but we still want to see the
long format Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
This commit is contained in:
parent
4d705621e6
commit
ececddd672
3 changed files with 14 additions and 2 deletions
|
@ -179,6 +179,14 @@ pub fn update_positions(dired: &mut DiredOutput, start: usize, end: usize) {
|
||||||
dired.padding = 0;
|
dired.padding = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checks if the "--dired" or "-D" argument is present in the command line arguments.
|
||||||
|
/// we don't use clap here because we need to know if the argument is present
|
||||||
|
/// as it can be overridden by --hyperlink
|
||||||
|
pub fn is_dired_arg_present() -> bool {
|
||||||
|
let args: Vec<String> = std::env::args().collect();
|
||||||
|
args.iter().any(|x| x == "--dired" || x == "-D")
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -67,7 +67,7 @@ use uucore::{
|
||||||
};
|
};
|
||||||
use uucore::{help_about, help_section, help_usage, parse_glob, show, show_error, show_warning};
|
use uucore::{help_about, help_section, help_usage, parse_glob, show, show_error, show_warning};
|
||||||
mod dired;
|
mod dired;
|
||||||
use dired::DiredOutput;
|
use dired::{is_dired_arg_present, DiredOutput};
|
||||||
#[cfg(not(feature = "selinux"))]
|
#[cfg(not(feature = "selinux"))]
|
||||||
static CONTEXT_HELP_TEXT: &str = "print any security context of each file (not enabled)";
|
static CONTEXT_HELP_TEXT: &str = "print any security context of each file (not enabled)";
|
||||||
#[cfg(feature = "selinux")]
|
#[cfg(feature = "selinux")]
|
||||||
|
@ -1079,8 +1079,10 @@ impl Config {
|
||||||
};
|
};
|
||||||
|
|
||||||
let dired = options.get_flag(options::DIRED);
|
let dired = options.get_flag(options::DIRED);
|
||||||
if dired {
|
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
|
||||||
|
// long format
|
||||||
format = Format::Long;
|
format = Format::Long;
|
||||||
}
|
}
|
||||||
if dired && options.get_flag(options::ZERO) {
|
if dired && options.get_flag(options::ZERO) {
|
||||||
|
|
|
@ -3956,6 +3956,8 @@ fn test_ls_dired_hyperlink() {
|
||||||
.arg("-R")
|
.arg("-R")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_contains("file://")
|
.stdout_contains("file://")
|
||||||
|
.stdout_contains("-rw") // we should have the long output
|
||||||
|
// even if dired isn't actually run
|
||||||
.stdout_does_not_contain("//DIRED//");
|
.stdout_does_not_contain("//DIRED//");
|
||||||
// dired is passed after hyperlink
|
// dired is passed after hyperlink
|
||||||
// so we will have DIRED output
|
// so we will have DIRED output
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue