File tree Expand file tree Collapse file tree 2 files changed +17
-21
lines changed
Expand file tree Collapse file tree 2 files changed +17
-21
lines changed Original file line number Diff line number Diff line change @@ -85,9 +85,25 @@ fn strip_minus_from_mode(_args: &mut [String]) -> bool {
8585 false
8686}
8787
88+ // Iterate 'args' and delete the first occurrence
89+ // of a prefix '-' if it's associated with MODE
90+ // e.g. "chmod -v -xw -R FILE" -> "chmod -v xw -R FILE"
8891#[ cfg( not( windows) ) ]
8992fn strip_minus_from_mode ( args : & mut Vec < String > ) -> bool {
90- mode:: strip_minus_from_mode ( args)
93+ for arg in args {
94+ if arg == "--" {
95+ break ;
96+ }
97+ if let Some ( arg_stripped) = arg. strip_prefix ( '-' ) {
98+ if let Some ( 'r' | 'w' | 'x' | 'X' | 's' | 't' | 'u' | 'g' | 'o' | '0' ..='7' ) =
99+ arg. chars ( ) . nth ( 1 )
100+ {
101+ * arg = arg_stripped. to_string ( ) ;
102+ return true ;
103+ }
104+ }
105+ }
106+ false
91107}
92108
93109#[ uucore:: main]
Original file line number Diff line number Diff line change @@ -182,26 +182,6 @@ pub fn get_umask() -> u32 {
182182 return mask as u32 ;
183183}
184184
185- // Iterate 'args' and delete the first occurrence
186- // of a prefix '-' if it's associated with MODE
187- // e.g. "chmod -v -xw -R FILE" -> "chmod -v xw -R FILE"
188- pub fn strip_minus_from_mode ( args : & mut Vec < String > ) -> bool {
189- for arg in args {
190- if arg == "--" {
191- break ;
192- }
193- if let Some ( arg_stripped) = arg. strip_prefix ( '-' ) {
194- if let Some ( 'r' | 'w' | 'x' | 'X' | 's' | 't' | 'u' | 'g' | 'o' | '0' ..='7' ) =
195- arg. chars ( ) . nth ( 1 )
196- {
197- * arg = arg_stripped. to_string ( ) ;
198- return true ;
199- }
200- }
201- }
202- false
203- }
204-
205185#[ cfg( test) ]
206186mod test {
207187
You can’t perform that action at this time.
0 commit comments