uucore: Move strip_minus_from_mode to mkdir

It's only used there anyway.
This commit is contained in:
Nicolas Boichat
2025-07-22 17:25:59 +08:00
parent 4bbbb972ad
commit f6f9ca7449
2 changed files with 17 additions and 21 deletions
+17 -1
View File
@@ -85,9 +85,25 @@ fn strip_minus_from_mode(_args: &mut [String]) -> bool {
false
}
// Iterate 'args' and delete the first occurrence
// of a prefix '-' if it's associated with MODE
// e.g. "chmod -v -xw -R FILE" -> "chmod -v xw -R FILE"
#[cfg(not(windows))]
fn strip_minus_from_mode(args: &mut Vec<String>) -> bool {
mode::strip_minus_from_mode(args)
for arg in args {
if arg == "--" {
break;
}
if let Some(arg_stripped) = arg.strip_prefix('-') {
if let Some('r' | 'w' | 'x' | 'X' | 's' | 't' | 'u' | 'g' | 'o' | '0'..='7') =
arg.chars().nth(1)
{
*arg = arg_stripped.to_string();
return true;
}
}
}
false
}
#[uucore::main]
-20
View File
@@ -182,26 +182,6 @@ pub fn get_umask() -> u32 {
return mask as u32;
}
// Iterate 'args' and delete the first occurrence
// of a prefix '-' if it's associated with MODE
// e.g. "chmod -v -xw -R FILE" -> "chmod -v xw -R FILE"
pub fn strip_minus_from_mode(args: &mut Vec<String>) -> bool {
for arg in args {
if arg == "--" {
break;
}
if let Some(arg_stripped) = arg.strip_prefix('-') {
if let Some('r' | 'w' | 'x' | 'X' | 's' | 't' | 'u' | 'g' | 'o' | '0'..='7') =
arg.chars().nth(1)
{
*arg = arg_stripped.to_string();
return true;
}
}
}
false
}
#[cfg(test)]
mod test {