mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
uucore: Move strip_minus_from_mode to mkdir
It's only used there anyway.
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user