diff --git a/Cargo.lock b/Cargo.lock index a96b1c0c6..e176d0ddd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -58,6 +58,7 @@ dependencies = [ "rm 0.0.1", "rmdir 0.0.1", "seq 0.0.1", + "shred 0.0.1", "shuf 0.0.1", "sleep 0.0.1", "sort 0.0.1", @@ -720,6 +721,18 @@ dependencies = [ "uucore 0.0.1", ] +[[package]] +name = "shred" +version = "0.0.1" +dependencies = [ + "filetime 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", + "uucore 0.0.1", +] + [[package]] name = "shuf" version = "0.0.1" diff --git a/src/chmod/chmod.rs b/src/chmod/chmod.rs index 5b869f129..4e932b70f 100644 --- a/src/chmod/chmod.rs +++ b/src/chmod/chmod.rs @@ -211,7 +211,7 @@ fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool } None => { // TODO: make the regex processing occur earlier (i.e. once in the main function) - let re: regex::Regex = Regex::new(r"^(([ugoa]*)((?:[-+=](?:[rwxXst]*|[ugo]))+))|([-+=]?[0-7]+)$").unwrap(); + let re: regex::Regex = Regex::new(r"^(([ugoa]*)((?:[-+=](?:[ugo]|[rwxXst]*))+))|([-+=]?[0-7]+)$").unwrap(); let mut stat: libc::stat = unsafe { mem::uninitialized() }; let statres = unsafe { libc::stat(path.as_ptr(), &mut stat as *mut libc::stat) }; let mut fperm = @@ -233,11 +233,12 @@ fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool levels = "a"; } let change = cap.at(3).unwrap().to_string() + "+"; - let mut action = change.chars().next().unwrap(); + let mut change = change.chars(); + let mut action = change.next().unwrap(); let mut rwx = 0; let mut special = 0; let mut special_changed = false; - for ch in change[1..].chars() { + for ch in change { match ch { '+' | '-' | '=' => { for level in levels.chars() {