mirror of
https://github.com/uutils/coreutils
synced 2024-07-23 10:54:14 +00:00
ls --dired: v9.5 --hyperlink is ignored if passed first
Manages cases like: $ ls -R --dired --hyperlink a2 will show hyperlink $ ls -R --hyperlink --dired a2 won't
This commit is contained in:
parent
da11981026
commit
cd44a3d1fd
|
@ -1287,7 +1287,8 @@ pub fn uu_app() -> Command {
|
|||
.long(options::DIRED)
|
||||
.short('D')
|
||||
.help("generate output designed for Emacs' dired (Directory Editor) mode")
|
||||
.action(ArgAction::SetTrue),
|
||||
.action(ArgAction::SetTrue)
|
||||
.overrides_with(options::HYPERLINK),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::HYPERLINK)
|
||||
|
@ -1302,7 +1303,7 @@ pub fn uu_app() -> Command {
|
|||
.num_args(0..=1)
|
||||
.default_missing_value("always")
|
||||
.default_value("never")
|
||||
.value_name("WHEN"),
|
||||
.value_name("WHEN").overrides_with(options::DIRED),
|
||||
)
|
||||
// The next four arguments do not override with the other format
|
||||
// options, see the comment in Config::from for the reason.
|
||||
|
@ -2018,7 +2019,7 @@ impl PathData {
|
|||
}
|
||||
|
||||
fn show_dir_name(path_data: &PathData, out: &mut BufWriter<Stdout>, config: &Config) {
|
||||
if config.hyperlink {
|
||||
if config.hyperlink && !config.dired {
|
||||
let name = escape_name(&path_data.display_name, &config.quoting_style);
|
||||
let hyperlink = create_hyperlink(&name, path_data);
|
||||
write!(out, "{}:", hyperlink).unwrap();
|
||||
|
@ -2123,7 +2124,7 @@ pub fn list(locs: Vec<&Path>, config: &Config) -> UResult<()> {
|
|||
&mut style_manager,
|
||||
)?;
|
||||
}
|
||||
if config.dired {
|
||||
if config.dired && !config.hyperlink {
|
||||
dired::print_dired_output(config, &dired, &mut out)?;
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -3941,6 +3941,34 @@ fn test_ls_dired_implies_long() {
|
|||
.stdout_contains("//DIRED-OPTIONS// --quoting-style");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ls_dired_hyperlink() {
|
||||
// we will have link but not the DIRED output
|
||||
// note that the order matters
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
at.mkdir("dir");
|
||||
at.touch("dir/a");
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("--dired")
|
||||
.arg("--hyperlink")
|
||||
.arg("-R")
|
||||
.succeeds()
|
||||
.stdout_contains("file://")
|
||||
.stdout_does_not_contain("//DIRED//");
|
||||
// dired is passed after hyperlink
|
||||
// so we will have DIRED output
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("--hyperlink")
|
||||
.arg("--dired")
|
||||
.arg("-R")
|
||||
.succeeds()
|
||||
.stdout_does_not_contain("file://")
|
||||
.stdout_contains("//DIRED//");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ls_dired_and_zero_are_incompatible() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
|
|
Loading…
Reference in a new issue