@@ -101,6 +101,12 @@ fn maybe_sanitize_length(
101101#[ uucore:: main]
102102pub fn uumain ( args : impl uucore:: Args ) -> UResult < ( ) > {
103103 let binary_name = uucore:: util_name ( ) ;
104+ // Put --\nuntagged to make logic simpler
105+ let mut args: Vec < OsString > = args. collect ( ) ;
106+ if !binary_name. ends_with ( "cksum" ) && !args. is_empty ( ) {
107+ args. insert ( 1 , OsString :: from ( "--\n untagged" ) ) ;
108+ }
109+
104110 let matches = uucore:: clap_localization:: handle_clap_result ( uu_app ( ) , args) ?;
105111
106112 let check = matches. get_flag ( options:: CHECK ) ;
@@ -180,7 +186,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
180186 // --untagged is cksum specific. So we use this form...
181187 let is_cksum = binary_name. ends_with ( "cksum" ) ;
182188 // clap cannot overrides_with --binary by --tag unilaterally...
183- let tag = ( !is_cksum && std:: env:: args ( ) . any ( |a| a == "--tag" || a == "-t" ) )
189+ let tag = ( !is_cksum && std:: env:: args ( ) . any ( |a| a == "--tag" ) )
184190 || ( is_cksum && !matches. get_flag ( options:: UNTAGGED ) ) ;
185191 let binary = matches. get_flag ( options:: BINARY ) ;
186192
@@ -225,8 +231,9 @@ pub fn uu_app() -> Command {
225231 . long ( options:: TAG )
226232 . help ( translate ! ( "cksum-help-tag" ) )
227233 . action ( ArgAction :: SetTrue )
228- . overrides_with ( options:: BINARY )
229- . overrides_with ( options:: TEXT ) ,
234+ . overrides_with ( options:: TEXT )
235+ . overrides_with ( options:: UNTAGGED )
236+ . overrides_with ( options:: BINARY ) ,
230237 )
231238 . arg (
232239 Arg :: new ( options:: RAW )
@@ -262,13 +269,15 @@ pub fn uu_app() -> Command {
262269 . long ( options:: TEXT )
263270 . short ( 't' )
264271 . hide ( true )
272+ . requires ( options:: UNTAGGED )
265273 . action ( ArgAction :: SetTrue ) ,
266274 )
267275 . arg (
268276 Arg :: new ( options:: BINARY )
269277 . long ( options:: BINARY )
270278 . short ( 'b' )
271279 . hide ( true )
280+ . overrides_with ( options:: TEXT )
272281 . action ( ArgAction :: SetTrue ) ,
273282 )
274283 . arg (
@@ -327,7 +336,6 @@ pub fn uu_app() -> Command {
327336 }
328337 if binary_name. ends_with ( "cksum" ) {
329338 app = app
330- . mut_arg ( options:: TEXT , |a : Arg | a. requires ( options:: UNTAGGED ) )
331339 . arg (
332340 Arg :: new ( options:: ALGORITHM )
333341 . long ( options:: ALGORITHM )
@@ -340,9 +348,15 @@ pub fn uu_app() -> Command {
340348 Arg :: new ( options:: UNTAGGED )
341349 . long ( options:: UNTAGGED )
342350 . help ( translate ! ( "cksum-help-untagged" ) )
343- . action ( ArgAction :: SetTrue )
344- . overrides_with ( options:: TAG ) ,
351+ . action ( ArgAction :: SetTrue ) ,
345352 ) ;
353+ } else {
354+ app = app. arg (
355+ Arg :: new ( options:: UNTAGGED )
356+ . long ( "\n untagged" )
357+ . hide ( true )
358+ . action ( ArgAction :: SetTrue ) ,
359+ ) ;
346360 }
347361 app. after_help ( translate ! ( "cksum-after-help" ) )
348362}
0 commit comments