File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1639,6 +1639,7 @@ pub fn uu_app() -> Command {
16391639 Arg :: new ( options:: EXCLUDE )
16401640 . long ( options:: EXCLUDE )
16411641 . value_name ( "PATTERN" )
1642+ . allow_hyphen_values ( true )
16421643 . help ( translate ! ( "du-help-exclude" ) )
16431644 . action ( ArgAction :: Append ) ,
16441645 )
@@ -1648,6 +1649,7 @@ pub fn uu_app() -> Command {
16481649 . long ( "exclude-from" )
16491650 . value_name ( "FILE" )
16501651 . value_hint ( clap:: ValueHint :: FilePath )
1652+ . allow_hyphen_values ( true )
16511653 . help ( translate ! ( "du-help-exclude-from" ) )
16521654 . action ( ArgAction :: Append ) ,
16531655 )
@@ -1657,6 +1659,7 @@ pub fn uu_app() -> Command {
16571659 . value_name ( "FILE" )
16581660 . value_hint ( clap:: ValueHint :: FilePath )
16591661 . value_parser ( clap:: value_parser!( OsString ) )
1662+ . allow_hyphen_values ( true )
16601663 . help ( translate ! ( "du-help-files0-from" ) )
16611664 . action ( ArgAction :: Append ) ,
16621665 )
Original file line number Diff line number Diff line change @@ -2104,6 +2104,40 @@ fn test_du_exclude_invalid_syntax() {
21042104 . stderr_contains ( "du: Invalid exclude syntax" ) ;
21052105}
21062106
2107+ #[ test]
2108+ fn test_du_option_values_starting_with_hyphen ( ) {
2109+ let ts = TestScenario :: new ( util_name ! ( ) ) ;
2110+ let at = & ts. fixtures ;
2111+
2112+ at. mkdir ( "dir" ) ;
2113+ at. write ( "dir/-skip" , "content" ) ;
2114+ at. write ( "dir/keep" , "content" ) ;
2115+ at. write ( "-patterns" , "-skip\n " ) ;
2116+ at. write ( "-list" , "dir/keep\0 " ) ;
2117+
2118+ ts. ucmd ( )
2119+ . args ( & [ "-a" , "--exclude" , "-skip" , "dir" ] )
2120+ . succeeds ( )
2121+ . stdout_contains ( "dir/keep" )
2122+ . stdout_does_not_contain ( "-skip" ) ;
2123+
2124+ ts. ucmd ( )
2125+ . args ( & [ "-a" , "-X" , "-patterns" , "dir" ] )
2126+ . succeeds ( )
2127+ . stdout_contains ( "dir/keep" )
2128+ . stdout_does_not_contain ( "-skip" ) ;
2129+
2130+ ts. ucmd ( )
2131+ . args ( & [ "-a" , "--exclude-from" , "-patterns" , "dir" ] )
2132+ . succeeds ( )
2133+ . stdout_does_not_contain ( "-skip" ) ;
2134+
2135+ ts. ucmd ( )
2136+ . args ( & [ "--files0-from" , "-list" ] )
2137+ . succeeds ( )
2138+ . stdout_contains ( "dir/keep" ) ;
2139+ }
2140+
21072141#[ test]
21082142fn test_du_exclude_from_nonexistent_file ( ) {
21092143 new_ucmd ! ( )
You can’t perform that action at this time.
0 commit comments