@@ -67,7 +67,7 @@ use uucore::{
6767} ;
6868use uucore:: { help_about, help_section, help_usage, parse_glob, show, show_error, show_warning} ;
6969mod dired;
70- use dired:: DiredOutput ;
70+ use dired:: { is_dired_arg_present , DiredOutput } ;
7171#[ cfg( not( feature = "selinux" ) ) ]
7272static CONTEXT_HELP_TEXT : & str = "print any security context of each file (not enabled)" ;
7373#[ cfg( feature = "selinux" ) ]
@@ -174,7 +174,6 @@ enum LsError {
174174 IOError ( std:: io:: Error ) ,
175175 IOErrorContext ( std:: io:: Error , PathBuf , bool ) ,
176176 BlockSizeParseError ( String ) ,
177- ConflictingArgumentDired ,
178177 DiredAndZeroAreIncompatible ,
179178 AlreadyListedError ( PathBuf ) ,
180179 TimeStyleParseError ( String , Vec < String > ) ,
@@ -188,7 +187,6 @@ impl UError for LsError {
188187 Self :: IOErrorContext ( _, _, false ) => 1 ,
189188 Self :: IOErrorContext ( _, _, true ) => 2 ,
190189 Self :: BlockSizeParseError ( _) => 2 ,
191- Self :: ConflictingArgumentDired => 1 ,
192190 Self :: DiredAndZeroAreIncompatible => 2 ,
193191 Self :: AlreadyListedError ( _) => 2 ,
194192 Self :: TimeStyleParseError ( _, _) => 2 ,
@@ -204,9 +202,6 @@ impl Display for LsError {
204202 Self :: BlockSizeParseError ( s) => {
205203 write ! ( f, "invalid --block-size argument {}" , s. quote( ) )
206204 }
207- Self :: ConflictingArgumentDired => {
208- write ! ( f, "--dired requires --format=long" )
209- }
210205 Self :: DiredAndZeroAreIncompatible => {
211206 write ! ( f, "--dired and --zero are incompatible" )
212207 }
@@ -1084,10 +1079,13 @@ impl Config {
10841079 } ;
10851080
10861081 let dired = options. get_flag ( options:: DIRED ) ;
1087- if dired && format != Format :: Long {
1088- return Err ( Box :: new ( LsError :: ConflictingArgumentDired ) ) ;
1082+ if dired || is_dired_arg_present ( ) {
1083+ // --dired implies --format=long
1084+ // if we have --dired --hyperlink, we don't show dired but we still want to see the
1085+ // long format
1086+ format = Format :: Long ;
10891087 }
1090- if dired && format == Format :: Long && options. get_flag ( options:: ZERO ) {
1088+ if dired && options. get_flag ( options:: ZERO ) {
10911089 return Err ( Box :: new ( LsError :: DiredAndZeroAreIncompatible ) ) ;
10921090 }
10931091
@@ -1215,6 +1213,7 @@ pub fn uu_app() -> Command {
12151213 options:: format:: LONG ,
12161214 options:: format:: ACROSS ,
12171215 options:: format:: COLUMNS ,
1216+ options:: DIRED ,
12181217 ] ) ,
12191218 )
12201219 . arg (
@@ -1291,7 +1290,8 @@ pub fn uu_app() -> Command {
12911290 . long ( options:: DIRED )
12921291 . short ( 'D' )
12931292 . help ( "generate output designed for Emacs' dired (Directory Editor) mode" )
1294- . action ( ArgAction :: SetTrue ) ,
1293+ . action ( ArgAction :: SetTrue )
1294+ . overrides_with ( options:: HYPERLINK ) ,
12951295 )
12961296 . arg (
12971297 Arg :: new ( options:: HYPERLINK )
@@ -1306,7 +1306,8 @@ pub fn uu_app() -> Command {
13061306 . num_args ( 0 ..=1 )
13071307 . default_missing_value ( "always" )
13081308 . default_value ( "never" )
1309- . value_name ( "WHEN" ) ,
1309+ . value_name ( "WHEN" )
1310+ . overrides_with ( options:: DIRED ) ,
13101311 )
13111312 // The next four arguments do not override with the other format
13121313 // options, see the comment in Config::from for the reason.
@@ -2022,7 +2023,7 @@ impl PathData {
20222023}
20232024
20242025fn show_dir_name ( path_data : & PathData , out : & mut BufWriter < Stdout > , config : & Config ) {
2025- if config. hyperlink {
2026+ if config. hyperlink && !config . dired {
20262027 let name = escape_name ( & path_data. display_name , & config. quoting_style ) ;
20272028 let hyperlink = create_hyperlink ( & name, path_data) ;
20282029 write ! ( out, "{}:" , hyperlink) . unwrap ( ) ;
@@ -2127,7 +2128,7 @@ pub fn list(locs: Vec<&Path>, config: &Config) -> UResult<()> {
21272128 & mut style_manager,
21282129 ) ?;
21292130 }
2130- if config. dired {
2131+ if config. dired && !config . hyperlink {
21312132 dired:: print_dired_output ( config, & dired, & mut out) ?;
21322133 }
21332134 Ok ( ( ) )
0 commit comments