mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
use semicolons if nothing returned
This commit is contained in:
parent
a2d5f06be4
commit
784f2e2ea1
56 changed files with 125 additions and 127 deletions
10
build.rs
10
build.rs
|
@ -77,7 +77,7 @@ pub fn main() {
|
||||||
)
|
)
|
||||||
.as_bytes(),
|
.as_bytes(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap();
|
||||||
}
|
}
|
||||||
k if k.starts_with(override_prefix) => {
|
k if k.starts_with(override_prefix) => {
|
||||||
mf.write_all(
|
mf.write_all(
|
||||||
|
@ -97,7 +97,7 @@ pub fn main() {
|
||||||
)
|
)
|
||||||
.as_bytes(),
|
.as_bytes(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap();
|
||||||
}
|
}
|
||||||
"false" | "true" => {
|
"false" | "true" => {
|
||||||
mf.write_all(
|
mf.write_all(
|
||||||
|
@ -116,7 +116,7 @@ pub fn main() {
|
||||||
)
|
)
|
||||||
.as_bytes(),
|
.as_bytes(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap();
|
||||||
}
|
}
|
||||||
"hashsum" => {
|
"hashsum" => {
|
||||||
mf.write_all(
|
mf.write_all(
|
||||||
|
@ -150,7 +150,7 @@ pub fn main() {
|
||||||
)
|
)
|
||||||
.as_bytes(),
|
.as_bytes(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap();
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
mf.write_all(
|
mf.write_all(
|
||||||
|
@ -169,7 +169,7 @@ pub fn main() {
|
||||||
)
|
)
|
||||||
.as_bytes(),
|
.as_bytes(),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ fn main() -> io::Result<()> {
|
||||||
} else {
|
} else {
|
||||||
println!("Error writing to {}", p);
|
println!("Error writing to {}", p);
|
||||||
}
|
}
|
||||||
writeln!(summary, "* [{0}](utils/{0}.md)", name)?
|
writeln!(summary, "* [{0}](utils/{0}.md)", name)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -743,7 +743,7 @@ This almost certainly means that you have a corrupted file system.\n\
|
||||||
NOTIFY YOUR SYSTEM MANAGER.\n\
|
NOTIFY YOUR SYSTEM MANAGER.\n\
|
||||||
The following directory is part of the cycle {}.",
|
The following directory is part of the cycle {}.",
|
||||||
file_name.quote()
|
file_name.quote()
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -742,7 +742,7 @@ fn parse_path_args(path_args: &[String], options: &Options) -> CopyResult<(Vec<S
|
||||||
|
|
||||||
if options.strip_trailing_slashes {
|
if options.strip_trailing_slashes {
|
||||||
for source in paths.iter_mut() {
|
for source in paths.iter_mut() {
|
||||||
*source = source.components().as_path().to_owned()
|
*source = source.components().as_path().to_owned();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -864,7 +864,7 @@ fn copy(sources: &[Source], target: &TargetSlice, options: &Options) -> CopyResu
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
show_error!("{}", error);
|
show_error!("{}", error);
|
||||||
non_fatal_errors = true
|
non_fatal_errors = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1580,5 +1580,5 @@ fn test_cp_localize_to_target() {
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
== Path::new("target/c.txt")
|
== Path::new("target/c.txt")
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -491,14 +491,14 @@ pub fn parse_conv_flag_input(matches: &Matches) -> Result<IConvFlags, ParseError
|
||||||
if case.is_some() {
|
if case.is_some() {
|
||||||
return Err(ParseError::MultipleUCaseLCase);
|
return Err(ParseError::MultipleUCaseLCase);
|
||||||
} else {
|
} else {
|
||||||
case = Some(flag)
|
case = Some(flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ConvFlag::LCase => {
|
ConvFlag::LCase => {
|
||||||
if case.is_some() {
|
if case.is_some() {
|
||||||
return Err(ParseError::MultipleUCaseLCase);
|
return Err(ParseError::MultipleUCaseLCase);
|
||||||
} else {
|
} else {
|
||||||
case = Some(flag)
|
case = Some(flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ConvFlag::Block => match (cbs, iconvflags.unblock) {
|
ConvFlag::Block => match (cbs, iconvflags.unblock) {
|
||||||
|
|
|
@ -56,10 +56,10 @@ fn unimplemented_flags_should_error() {
|
||||||
let matches = uu_app().try_get_matches_from(args).unwrap();
|
let matches = uu_app().try_get_matches_from(args).unwrap();
|
||||||
|
|
||||||
if parse_iflags(&matches).is_ok() {
|
if parse_iflags(&matches).is_ok() {
|
||||||
succeeded.push(format!("iflag={}", flag))
|
succeeded.push(format!("iflag={}", flag));
|
||||||
}
|
}
|
||||||
if parse_oflags(&matches).is_ok() {
|
if parse_oflags(&matches).is_ok() {
|
||||||
succeeded.push(format!("oflag={}", flag))
|
succeeded.push(format!("oflag={}", flag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
|
||||||
let result;
|
let result;
|
||||||
if files.is_empty() {
|
if files.is_empty() {
|
||||||
result = parse(INTERNAL_DB.lines(), &out_format, "")
|
result = parse(INTERNAL_DB.lines(), &out_format, "");
|
||||||
} else {
|
} else {
|
||||||
if files.len() > 1 {
|
if files.len() > 1 {
|
||||||
return Err(UUsageError::new(
|
return Err(UUsageError::new(
|
||||||
|
@ -138,7 +138,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
match File::open(files[0]) {
|
match File::open(files[0]) {
|
||||||
Ok(f) => {
|
Ok(f) => {
|
||||||
let fin = BufReader::new(f);
|
let fin = BufReader::new(f);
|
||||||
result = parse(fin.lines().filter_map(Result::ok), &out_format, files[0])
|
result = parse(fin.lines().filter_map(Result::ok), &out_format, files[0]);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
return Err(USimpleError::new(
|
return Err(USimpleError::new(
|
||||||
|
|
|
@ -61,7 +61,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
match p.parent() {
|
match p.parent() {
|
||||||
Some(d) => {
|
Some(d) => {
|
||||||
if d.components().next() == None {
|
if d.components().next() == None {
|
||||||
print!(".")
|
print!(".");
|
||||||
} else {
|
} else {
|
||||||
print_verbatim(d).unwrap();
|
print_verbatim(d).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,7 @@ fn du(
|
||||||
ErrorKind::PermissionDenied => {
|
ErrorKind::PermissionDenied => {
|
||||||
let description = format!("cannot access {}", entry.path().quote());
|
let description = format!("cannot access {}", entry.path().quote());
|
||||||
let error_message = "Permission denied";
|
let error_message = "Permission denied";
|
||||||
show_error_custom_description!(description, "{}", error_message)
|
show_error_custom_description!(description, "{}", error_message);
|
||||||
}
|
}
|
||||||
_ => show_error!("cannot access {}: {}", entry.path().quote(), error),
|
_ => show_error!("cannot access {}: {}", entry.path().quote(), error),
|
||||||
},
|
},
|
||||||
|
@ -486,7 +486,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
if options.inodes
|
if options.inodes
|
||||||
&& (matches.is_present(options::APPARENT_SIZE) || matches.is_present(options::BYTES))
|
&& (matches.is_present(options::APPARENT_SIZE) || matches.is_present(options::BYTES))
|
||||||
{
|
{
|
||||||
show_warning!("options --apparent-size and -b are ineffective with --inodes")
|
show_warning!("options --apparent-size and -b are ineffective with --inodes");
|
||||||
}
|
}
|
||||||
|
|
||||||
let block_size = u64::try_from(read_block_size(matches.value_of(options::BLOCK_SIZE))).unwrap();
|
let block_size = u64::try_from(read_block_size(matches.value_of(options::BLOCK_SIZE))).unwrap();
|
||||||
|
|
|
@ -332,7 +332,7 @@ fn expand(options: &Options) -> std::io::Result<()> {
|
||||||
// now dump out either spaces if we're expanding, or a literal tab if we're not
|
// now dump out either spaces if we're expanding, or a literal tab if we're not
|
||||||
if init || !options.iflag {
|
if init || !options.iflag {
|
||||||
if nts <= options.tspaces.len() {
|
if nts <= options.tspaces.len() {
|
||||||
output.write_all(options.tspaces[..nts].as_bytes())?
|
output.write_all(options.tspaces[..nts].as_bytes())?;
|
||||||
} else {
|
} else {
|
||||||
output.write_all(" ".repeat(nts).as_bytes())?;
|
output.write_all(" ".repeat(nts).as_bytes())?;
|
||||||
};
|
};
|
||||||
|
|
|
@ -370,7 +370,7 @@ fn push_op_to_stack(
|
||||||
},
|
},
|
||||||
)) => {
|
)) => {
|
||||||
if la && prev_prec >= prec || !la && prev_prec > prec {
|
if la && prev_prec >= prec || !la && prev_prec > prec {
|
||||||
out_stack.push(op_stack.pop().unwrap())
|
out_stack.push(op_stack.pop().unwrap());
|
||||||
} else {
|
} else {
|
||||||
op_stack.push((token_idx, token.clone()));
|
op_stack.push((token_idx, token.clone()));
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
|
@ -155,8 +155,8 @@ fn push_token_if_not_escaped(acc: &mut Vec<(usize, Token)>, tok_idx: usize, toke
|
||||||
|
|
||||||
if should_use_as_escaped {
|
if should_use_as_escaped {
|
||||||
acc.pop();
|
acc.pop();
|
||||||
acc.push((tok_idx, Token::new_value(s)))
|
acc.push((tok_idx, Token::new_value(s)));
|
||||||
} else {
|
} else {
|
||||||
acc.push((tok_idx, token))
|
acc.push((tok_idx, token));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ impl Decomposition {
|
||||||
if let Some((_, e)) = self.0.iter_mut().find(|(f, _)| *f == factor) {
|
if let Some((_, e)) = self.0.iter_mut().find(|(f, _)| *f == factor) {
|
||||||
*e += exp;
|
*e += exp;
|
||||||
} else {
|
} else {
|
||||||
self.0.push((factor, exp))
|
self.0.push((factor, exp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,11 +79,11 @@ impl Factors {
|
||||||
|
|
||||||
pub fn add(&mut self, prime: u64, exp: Exponent) {
|
pub fn add(&mut self, prime: u64, exp: Exponent) {
|
||||||
debug_assert!(miller_rabin::is_prime(prime));
|
debug_assert!(miller_rabin::is_prime(prime));
|
||||||
self.0.borrow_mut().add(prime, exp)
|
self.0.borrow_mut().add(prime, exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push(&mut self, prime: u64) {
|
pub fn push(&mut self, prime: u64) {
|
||||||
self.add(prime, 1)
|
self.add(prime, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -99,7 +99,7 @@ impl fmt::Display for Factors {
|
||||||
|
|
||||||
for (p, exp) in v.iter() {
|
for (p, exp) in v.iter() {
|
||||||
for _ in 0..*exp {
|
for _ in 0..*exp {
|
||||||
write!(f, " {}", p)?
|
write!(f, " {}", p)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -384,7 +384,7 @@ fn build_best_path<'a>(paths: &[LineBreak<'a>], active: &[usize]) -> Vec<(&'a Wo
|
||||||
None => return breakwords,
|
None => return breakwords,
|
||||||
Some(prev) => {
|
Some(prev) => {
|
||||||
breakwords.push((prev, next_best.break_before));
|
breakwords.push((prev, next_best.break_before));
|
||||||
best_idx = next_best.prev
|
best_idx = next_best.prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ impl Digest for md5::Context {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn input(&mut self, input: &[u8]) {
|
fn input(&mut self, input: &[u8]) {
|
||||||
self.consume(input)
|
self.consume(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn result(&mut self, out: &mut [u8]) {
|
fn result(&mut self, out: &mut [u8]) {
|
||||||
|
|
|
@ -173,28 +173,28 @@ fn detect_algo(
|
||||||
};
|
};
|
||||||
name = n;
|
name = n;
|
||||||
alg = Some(val);
|
alg = Some(val);
|
||||||
output_bits = bits
|
output_bits = bits;
|
||||||
};
|
};
|
||||||
if matches.is_present("md5") {
|
if matches.is_present("md5") {
|
||||||
set_or_crash("MD5", Box::new(Md5::new()), 128)
|
set_or_crash("MD5", Box::new(Md5::new()), 128);
|
||||||
}
|
}
|
||||||
if matches.is_present("sha1") {
|
if matches.is_present("sha1") {
|
||||||
set_or_crash("SHA1", Box::new(Sha1::new()), 160)
|
set_or_crash("SHA1", Box::new(Sha1::new()), 160);
|
||||||
}
|
}
|
||||||
if matches.is_present("sha224") {
|
if matches.is_present("sha224") {
|
||||||
set_or_crash("SHA224", Box::new(Sha224::new()), 224)
|
set_or_crash("SHA224", Box::new(Sha224::new()), 224);
|
||||||
}
|
}
|
||||||
if matches.is_present("sha256") {
|
if matches.is_present("sha256") {
|
||||||
set_or_crash("SHA256", Box::new(Sha256::new()), 256)
|
set_or_crash("SHA256", Box::new(Sha256::new()), 256);
|
||||||
}
|
}
|
||||||
if matches.is_present("sha384") {
|
if matches.is_present("sha384") {
|
||||||
set_or_crash("SHA384", Box::new(Sha384::new()), 384)
|
set_or_crash("SHA384", Box::new(Sha384::new()), 384);
|
||||||
}
|
}
|
||||||
if matches.is_present("sha512") {
|
if matches.is_present("sha512") {
|
||||||
set_or_crash("SHA512", Box::new(Sha512::new()), 512)
|
set_or_crash("SHA512", Box::new(Sha512::new()), 512);
|
||||||
}
|
}
|
||||||
if matches.is_present("b2sum") {
|
if matches.is_present("b2sum") {
|
||||||
set_or_crash("BLAKE2", Box::new(blake2b_simd::State::new()), 512)
|
set_or_crash("BLAKE2", Box::new(blake2b_simd::State::new()), 512);
|
||||||
}
|
}
|
||||||
if matches.is_present("sha3") {
|
if matches.is_present("sha3") {
|
||||||
match matches.value_of("bits") {
|
match matches.value_of("bits") {
|
||||||
|
@ -229,16 +229,16 @@ fn detect_algo(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if matches.is_present("sha3-224") {
|
if matches.is_present("sha3-224") {
|
||||||
set_or_crash("SHA3-224", Box::new(Sha3_224::new()), 224)
|
set_or_crash("SHA3-224", Box::new(Sha3_224::new()), 224);
|
||||||
}
|
}
|
||||||
if matches.is_present("sha3-256") {
|
if matches.is_present("sha3-256") {
|
||||||
set_or_crash("SHA3-256", Box::new(Sha3_256::new()), 256)
|
set_or_crash("SHA3-256", Box::new(Sha3_256::new()), 256);
|
||||||
}
|
}
|
||||||
if matches.is_present("sha3-384") {
|
if matches.is_present("sha3-384") {
|
||||||
set_or_crash("SHA3-384", Box::new(Sha3_384::new()), 384)
|
set_or_crash("SHA3-384", Box::new(Sha3_384::new()), 384);
|
||||||
}
|
}
|
||||||
if matches.is_present("sha3-512") {
|
if matches.is_present("sha3-512") {
|
||||||
set_or_crash("SHA3-512", Box::new(Sha3_512::new()), 512)
|
set_or_crash("SHA3-512", Box::new(Sha3_512::new()), 512);
|
||||||
}
|
}
|
||||||
if matches.is_present("shake128") {
|
if matches.is_present("shake128") {
|
||||||
match matches.value_of("bits") {
|
match matches.value_of("bits") {
|
||||||
|
|
|
@ -424,7 +424,7 @@ fn uu_head(options: &HeadOptions) -> UResult<()> {
|
||||||
if !first {
|
if !first {
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
println!("==> standard input <==")
|
println!("==> standard input <==");
|
||||||
}
|
}
|
||||||
let stdin = std::io::stdin();
|
let stdin = std::io::stdin();
|
||||||
let mut stdin = stdin.lock();
|
let mut stdin = stdin.lock();
|
||||||
|
@ -460,7 +460,7 @@ fn uu_head(options: &HeadOptions) -> UResult<()> {
|
||||||
if !first {
|
if !first {
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
println!("==> {} <==", name)
|
println!("==> {} <==", name);
|
||||||
}
|
}
|
||||||
head_file(&mut file, options)
|
head_file(&mut file, options)
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,11 +43,11 @@ pub fn parse_obsolete(src: &str) -> Option<Result<impl Iterator<Item = OsString>
|
||||||
// this also saves us 1 heap allocation
|
// this also saves us 1 heap allocation
|
||||||
'q' => {
|
'q' => {
|
||||||
quiet = true;
|
quiet = true;
|
||||||
verbose = false
|
verbose = false;
|
||||||
}
|
}
|
||||||
'v' => {
|
'v' => {
|
||||||
verbose = true;
|
verbose = true;
|
||||||
quiet = false
|
quiet = false;
|
||||||
}
|
}
|
||||||
'z' => zero_terminated = true,
|
'z' => zero_terminated = true,
|
||||||
'c' => multiplier = Some(1),
|
'c' => multiplier = Some(1),
|
||||||
|
@ -58,20 +58,20 @@ pub fn parse_obsolete(src: &str) -> Option<Result<impl Iterator<Item = OsString>
|
||||||
_ => return Some(Err(ParseError::Syntax)),
|
_ => return Some(Err(ParseError::Syntax)),
|
||||||
}
|
}
|
||||||
if let Some((_, next)) = chars.next() {
|
if let Some((_, next)) = chars.next() {
|
||||||
c = next
|
c = next;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut options = Vec::new();
|
let mut options = Vec::new();
|
||||||
if quiet {
|
if quiet {
|
||||||
options.push(OsString::from("-q"))
|
options.push(OsString::from("-q"));
|
||||||
}
|
}
|
||||||
if verbose {
|
if verbose {
|
||||||
options.push(OsString::from("-v"))
|
options.push(OsString::from("-v"));
|
||||||
}
|
}
|
||||||
if zero_terminated {
|
if zero_terminated {
|
||||||
options.push(OsString::from("-z"))
|
options.push(OsString::from("-z"));
|
||||||
}
|
}
|
||||||
if let Some(n) = multiplier {
|
if let Some(n) = multiplier {
|
||||||
options.push(OsString::from("-c"));
|
options.push(OsString::from("-c"));
|
||||||
|
|
|
@ -308,7 +308,7 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &Path, settings: &Settings)
|
||||||
if is_symlink(target_dir) {
|
if is_symlink(target_dir) {
|
||||||
if target_dir.is_file() {
|
if target_dir.is_file() {
|
||||||
if let Err(e) = fs::remove_file(target_dir) {
|
if let Err(e) = fs::remove_file(target_dir) {
|
||||||
show_error!("Could not update {}: {}", target_dir.quote(), e)
|
show_error!("Could not update {}: {}", target_dir.quote(), e);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if target_dir.is_dir() {
|
if target_dir.is_dir() {
|
||||||
|
@ -316,7 +316,7 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &Path, settings: &Settings)
|
||||||
// considered as a dir
|
// considered as a dir
|
||||||
// See test_ln::test_symlink_no_deref_dir
|
// See test_ln::test_symlink_no_deref_dir
|
||||||
if let Err(e) = fs::remove_dir(target_dir) {
|
if let Err(e) = fs::remove_dir(target_dir) {
|
||||||
show_error!("Could not update {}: {}", target_dir.quote(), e)
|
show_error!("Could not update {}: {}", target_dir.quote(), e);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,7 +402,7 @@ fn link(src: &Path, dst: &Path, settings: &Settings) -> Result<()> {
|
||||||
if !read_yes() {
|
if !read_yes() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
fs::remove_file(dst)?
|
fs::remove_file(dst)?;
|
||||||
}
|
}
|
||||||
OverwriteMode::Force => fs::remove_file(dst)?,
|
OverwriteMode::Force => fs::remove_file(dst)?,
|
||||||
};
|
};
|
||||||
|
|
|
@ -118,7 +118,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches.is_present(OPT_T) {
|
if matches.is_present(OPT_T) {
|
||||||
tmpdir = env::temp_dir()
|
tmpdir = env::temp_dir();
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = if dry_run {
|
let res = if dry_run {
|
||||||
|
|
|
@ -305,7 +305,7 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> UR
|
||||||
sourcepath.quote(),
|
sourcepath.quote(),
|
||||||
targetpath.quote()
|
targetpath.quote()
|
||||||
))
|
))
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ fn rename(from: &Path, to: &Path, b: &Behavior) -> io::Result<()> {
|
||||||
// normalize behavior between *nix and windows
|
// normalize behavior between *nix and windows
|
||||||
if from.is_dir() {
|
if from.is_dir() {
|
||||||
if is_empty_dir(to) {
|
if is_empty_dir(to) {
|
||||||
fs::remove_dir(to)?
|
fs::remove_dir(to)?;
|
||||||
} else {
|
} else {
|
||||||
return Err(io::Error::new(io::ErrorKind::Other, "Directory not empty"));
|
return Err(io::Error::new(io::ErrorKind::Other, "Directory not empty"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ impl<'b> MultifileReader<'b> {
|
||||||
// then move on the the next file.
|
// then move on the the next file.
|
||||||
// This matches the behavior of the original `od`
|
// This matches the behavior of the original `od`
|
||||||
show_error!("{}: {}", fname.maybe_quote(), e);
|
show_error!("{}: {}", fname.maybe_quote(), e);
|
||||||
self.any_err = true
|
self.any_err = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ pub fn parse_format_flags(args: &[String]) -> Result<Vec<ParsedFormatterItemInfo
|
||||||
} else {
|
} else {
|
||||||
// not every option is a format
|
// not every option is a format
|
||||||
if let Some(r) = od_argument_traditional_format(c) {
|
if let Some(r) = od_argument_traditional_format(c) {
|
||||||
formats.push(ParsedFormatterItemInfo::new(r, false))
|
formats.push(ParsedFormatterItemInfo::new(r, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,9 +210,9 @@ impl Capitalize for str {
|
||||||
self.char_indices()
|
self.char_indices()
|
||||||
.fold(String::with_capacity(self.len()), |mut acc, x| {
|
.fold(String::with_capacity(self.len()), |mut acc, x| {
|
||||||
if x.0 != 0 {
|
if x.0 != 0 {
|
||||||
acc.push(x.1)
|
acc.push(x.1);
|
||||||
} else {
|
} else {
|
||||||
acc.push(x.1.to_ascii_uppercase())
|
acc.push(x.1.to_ascii_uppercase());
|
||||||
}
|
}
|
||||||
acc
|
acc
|
||||||
})
|
})
|
||||||
|
@ -324,12 +324,10 @@ impl Pinky {
|
||||||
self.print_heading();
|
self.print_heading();
|
||||||
}
|
}
|
||||||
for ut in Utmpx::iter_all_records() {
|
for ut in Utmpx::iter_all_records() {
|
||||||
if ut.is_user_process() {
|
if ut.is_user_process()
|
||||||
if self.names.is_empty() {
|
&& (self.names.is_empty() || self.names.iter().any(|n| n.as_str() == ut.user()))
|
||||||
self.print_entry(&ut)?
|
{
|
||||||
} else if self.names.iter().any(|n| n.as_str() == ut.user()) {
|
self.print_entry(&ut)?;
|
||||||
self.print_entry(&ut)?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -275,7 +275,7 @@ fn read_input(input_files: &[String], config: &Config) -> std::io::Result<FileMa
|
||||||
offset,
|
offset,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
offset += size
|
offset += size;
|
||||||
}
|
}
|
||||||
Ok(file_map)
|
Ok(file_map)
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ impl Iterator for FilenameGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
if name_charset_indices[0] == NAME_CHARSET.len() - 1 {
|
if name_charset_indices[0] == NAME_CHARSET.len() - 1 {
|
||||||
self.exhausted.set(true)
|
self.exhausted.set(true);
|
||||||
}
|
}
|
||||||
// Now increment the least significant index
|
// Now increment the least significant index
|
||||||
for i in (0..self.name_len).rev() {
|
for i in (0..self.name_len).rev() {
|
||||||
|
@ -478,7 +478,7 @@ fn wipe_file(
|
||||||
if n_passes <= 3 {
|
if n_passes <= 3 {
|
||||||
// Only random passes if n_passes <= 3
|
// Only random passes if n_passes <= 3
|
||||||
for _ in 0..n_passes {
|
for _ in 0..n_passes {
|
||||||
pass_sequence.push(PassType::Random)
|
pass_sequence.push(PassType::Random);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// First fill it with Patterns, shuffle it, then evenly distribute Random
|
// First fill it with Patterns, shuffle it, then evenly distribute Random
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl<R: Read> RngCore for ReadRng<R> {
|
||||||
panic!(
|
panic!(
|
||||||
"reading random bytes from Read implementation failed; error: {}",
|
"reading random bytes from Read implementation failed; error: {}",
|
||||||
err
|
err
|
||||||
)
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ fn reader_writer<
|
||||||
fn sorter(receiver: &Receiver<Chunk>, sender: &SyncSender<Chunk>, settings: &GlobalSettings) {
|
fn sorter(receiver: &Receiver<Chunk>, sender: &SyncSender<Chunk>, settings: &GlobalSettings) {
|
||||||
while let Ok(mut payload) = receiver.recv() {
|
while let Ok(mut payload) = receiver.recv() {
|
||||||
payload.with_contents_mut(|contents| {
|
payload.with_contents_mut(|contents| {
|
||||||
sort_by(&mut contents.lines, settings, &contents.line_data)
|
sort_by(&mut contents.lines, settings, &contents.line_data);
|
||||||
});
|
});
|
||||||
if sender.send(payload).is_err() {
|
if sender.send(payload).is_err() {
|
||||||
// The receiver has gone away, likely because the other thread hit an error.
|
// The receiver has gone away, likely because the other thread hit an error.
|
||||||
|
|
|
@ -50,7 +50,7 @@ fn replace_output_file_in_input_files(
|
||||||
std::fs::copy(file_path, ©_path)
|
std::fs::copy(file_path, ©_path)
|
||||||
.map_err(|error| SortError::OpenTmpFileFailed { error })?;
|
.map_err(|error| SortError::OpenTmpFileFailed { error })?;
|
||||||
*file = copy_path.clone().into_os_string();
|
*file = copy_path.clone().into_os_string();
|
||||||
copy = Some(copy_path)
|
copy = Some(copy_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ fn merge_without_limit<M: MergeInput + 'static, F: Iterator<Item = UResult<M>>>(
|
||||||
file_number,
|
file_number,
|
||||||
line_idx: 0,
|
line_idx: 0,
|
||||||
receiver,
|
receiver,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -535,7 +535,7 @@ impl<'a> Line<'a> {
|
||||||
}
|
}
|
||||||
Selection::Str(str) => {
|
Selection::Str(str) => {
|
||||||
if selector.needs_selection {
|
if selector.needs_selection {
|
||||||
line_data.selections.push(str)
|
line_data.selections.push(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -701,9 +701,9 @@ impl<'a> Line<'a> {
|
||||||
fn tokenize(line: &str, separator: Option<char>, token_buffer: &mut Vec<Field>) {
|
fn tokenize(line: &str, separator: Option<char>, token_buffer: &mut Vec<Field>) {
|
||||||
assert!(token_buffer.is_empty());
|
assert!(token_buffer.is_empty());
|
||||||
if let Some(separator) = separator {
|
if let Some(separator) = separator {
|
||||||
tokenize_with_separator(line, separator, token_buffer)
|
tokenize_with_separator(line, separator, token_buffer);
|
||||||
} else {
|
} else {
|
||||||
tokenize_default(line, token_buffer)
|
tokenize_default(line, token_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1232,7 +1232,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
settings.separator = Some(separator.chars().next().unwrap())
|
settings.separator = Some(separator.chars().next().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(values) = matches.values_of(options::KEY) {
|
if let Some(values) = matches.values_of(options::KEY) {
|
||||||
|
@ -1524,9 +1524,9 @@ fn exec(
|
||||||
|
|
||||||
fn sort_by<'a>(unsorted: &mut Vec<Line<'a>>, settings: &GlobalSettings, line_data: &LineData<'a>) {
|
fn sort_by<'a>(unsorted: &mut Vec<Line<'a>>, settings: &GlobalSettings, line_data: &LineData<'a>) {
|
||||||
if settings.stable || settings.unique {
|
if settings.stable || settings.unique {
|
||||||
unsorted.par_sort_by(|a, b| compare_by(a, b, settings, line_data, line_data))
|
unsorted.par_sort_by(|a, b| compare_by(a, b, settings, line_data, line_data));
|
||||||
} else {
|
} else {
|
||||||
unsorted.par_sort_unstable_by(|a, b| compare_by(a, b, settings, line_data, line_data))
|
unsorted.par_sort_unstable_by(|a, b| compare_by(a, b, settings, line_data, line_data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ impl Drop for WithEnvVarSet {
|
||||||
if let Ok(ref prev_value) = self._previous_var_value {
|
if let Ok(ref prev_value) = self._previous_var_value {
|
||||||
env::set_var(&self._previous_var_key, &prev_value);
|
env::set_var(&self._previous_var_key, &prev_value);
|
||||||
} else {
|
} else {
|
||||||
env::remove_var(&self._previous_var_key)
|
env::remove_var(&self._previous_var_key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,7 +406,7 @@ impl Stater {
|
||||||
flag,
|
flag,
|
||||||
precision,
|
precision,
|
||||||
format: chars[i],
|
format: chars[i],
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
'\\' => {
|
'\\' => {
|
||||||
if !use_printf {
|
if !use_printf {
|
||||||
|
|
|
@ -42,11 +42,11 @@ pub fn parse_obsolete(src: &str) -> Option<Result<impl Iterator<Item = OsString>
|
||||||
// this also saves us 1 heap allocation
|
// this also saves us 1 heap allocation
|
||||||
'q' => {
|
'q' => {
|
||||||
quiet = true;
|
quiet = true;
|
||||||
verbose = false
|
verbose = false;
|
||||||
}
|
}
|
||||||
'v' => {
|
'v' => {
|
||||||
verbose = true;
|
verbose = true;
|
||||||
quiet = false
|
quiet = false;
|
||||||
}
|
}
|
||||||
'z' => zero_terminated = true,
|
'z' => zero_terminated = true,
|
||||||
'c' => multiplier = Some(1),
|
'c' => multiplier = Some(1),
|
||||||
|
@ -57,20 +57,20 @@ pub fn parse_obsolete(src: &str) -> Option<Result<impl Iterator<Item = OsString>
|
||||||
_ => return Some(Err(ParseError::Syntax)),
|
_ => return Some(Err(ParseError::Syntax)),
|
||||||
}
|
}
|
||||||
if let Some((_, next)) = chars.next() {
|
if let Some((_, next)) = chars.next() {
|
||||||
c = next
|
c = next;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut options = Vec::new();
|
let mut options = Vec::new();
|
||||||
if quiet {
|
if quiet {
|
||||||
options.push(OsString::from("-q"))
|
options.push(OsString::from("-q"));
|
||||||
}
|
}
|
||||||
if verbose {
|
if verbose {
|
||||||
options.push(OsString::from("-v"))
|
options.push(OsString::from("-v"));
|
||||||
}
|
}
|
||||||
if zero_terminated {
|
if zero_terminated {
|
||||||
options.push(OsString::from("-z"))
|
options.push(OsString::from("-z"));
|
||||||
}
|
}
|
||||||
if let Some(n) = multiplier {
|
if let Some(n) = multiplier {
|
||||||
options.push(OsString::from("-c"));
|
options.push(OsString::from("-c"));
|
||||||
|
|
|
@ -102,7 +102,7 @@ impl Settings {
|
||||||
if let Some(n) = matches.value_of(options::SLEEP_INT) {
|
if let Some(n) = matches.value_of(options::SLEEP_INT) {
|
||||||
let parsed: Option<u32> = n.parse().ok();
|
let parsed: Option<u32> = n.parse().ok();
|
||||||
if let Some(m) = parsed {
|
if let Some(m) = parsed {
|
||||||
settings.sleep_msec = m * 1000
|
settings.sleep_msec = m * 1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ fn ignore_interrupts() -> Result<()> {
|
||||||
|
|
||||||
fn tee(options: &Options) -> Result<()> {
|
fn tee(options: &Options) -> Result<()> {
|
||||||
if options.ignore_interrupts {
|
if options.ignore_interrupts {
|
||||||
ignore_interrupts()?
|
ignore_interrupts()?;
|
||||||
}
|
}
|
||||||
let mut writers: Vec<NamedWriter> = options
|
let mut writers: Vec<NamedWriter> = options
|
||||||
.files
|
.files
|
||||||
|
|
|
@ -178,7 +178,7 @@ fn print_uptime(upsecs: i64) {
|
||||||
match updays.cmp(&1) {
|
match updays.cmp(&1) {
|
||||||
std::cmp::Ordering::Equal => print!("up {:1} day, {:2}:{:02}, ", updays, uphours, upmins),
|
std::cmp::Ordering::Equal => print!("up {:1} day, {:2}:{:02}, ", updays, uphours, upmins),
|
||||||
std::cmp::Ordering::Greater => {
|
std::cmp::Ordering::Greater => {
|
||||||
print!("up {:1} days, {:2}:{:02}, ", updays, uphours, upmins)
|
print!("up {:1} days, {:2}:{:02}, ", updays, uphours, upmins);
|
||||||
}
|
}
|
||||||
_ => print!("up {:2}:{:02}, ", uphours, upmins),
|
_ => print!("up {:2}:{:02}, ", uphours, upmins),
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,7 +27,7 @@ impl Add for WordCount {
|
||||||
|
|
||||||
impl AddAssign for WordCount {
|
impl AddAssign for WordCount {
|
||||||
fn add_assign(&mut self, other: Self) {
|
fn add_assign(&mut self, other: Self) {
|
||||||
*self = *self + other
|
*self = *self + other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,7 @@ impl Who {
|
||||||
let records = Utmpx::iter_all_records_from(f).peekable();
|
let records = Utmpx::iter_all_records_from(f).peekable();
|
||||||
|
|
||||||
if self.include_heading {
|
if self.include_heading {
|
||||||
self.print_heading()
|
self.print_heading();
|
||||||
}
|
}
|
||||||
let cur_tty = if self.my_line_only {
|
let cur_tty = if self.my_line_only {
|
||||||
current_tty()
|
current_tty()
|
||||||
|
|
|
@ -159,7 +159,7 @@ pub fn resolve_relative_path(path: &Path) -> Cow<Path> {
|
||||||
}
|
}
|
||||||
Component::CurDir => (),
|
Component::CurDir => (),
|
||||||
Component::RootDir | Component::Normal(_) | Component::Prefix(_) => {
|
Component::RootDir | Component::Normal(_) | Component::Prefix(_) => {
|
||||||
result.push(comp.as_os_str())
|
result.push(comp.as_os_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ impl MountInfo {
|
||||||
// but set dev_id
|
// but set dev_id
|
||||||
if let Ok(stat) = std::fs::metadata(&self.mount_dir) {
|
if let Ok(stat) = std::fs::metadata(&self.mount_dir) {
|
||||||
// Why do we cast this to i32?
|
// Why do we cast this to i32?
|
||||||
self.dev_id = (stat.dev() as i32).to_string()
|
self.dev_id = (stat.dev() as i32).to_string();
|
||||||
} else {
|
} else {
|
||||||
self.dev_id = "".to_string();
|
self.dev_id = "".to_string();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ pub fn parse_symbolic(
|
||||||
// keep the setgid and setuid bits for directories
|
// keep the setgid and setuid bits for directories
|
||||||
srwx |= fperm & (0o4000 | 0o2000);
|
srwx |= fperm & (0o4000 | 0o2000);
|
||||||
}
|
}
|
||||||
fperm = (fperm & !mask) | (srwx & mask)
|
fperm = (fperm & !mask) | (srwx & mask);
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ fn parse_change(mode: &str, fperm: u32, considering_dir: bool) -> (u32, usize) {
|
||||||
'x' => srwx |= 0o111,
|
'x' => srwx |= 0o111,
|
||||||
'X' => {
|
'X' => {
|
||||||
if considering_dir || (fperm & 0o0111) != 0 {
|
if considering_dir || (fperm & 0o0111) != 0 {
|
||||||
srwx |= 0o111
|
srwx |= 0o111;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
's' => srwx |= 0o4000 | 0o2000,
|
's' => srwx |= 0o4000 | 0o2000,
|
||||||
|
|
|
@ -296,9 +296,9 @@ impl ChownExecutor {
|
||||||
} else {
|
} else {
|
||||||
"Too many levels of symbolic links".into()
|
"Too many levels of symbolic links".into()
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
} else {
|
} else {
|
||||||
show_error!("{}", e)
|
show_error!("{}", e);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -450,7 +450,7 @@ pub fn chown_base<'a>(
|
||||||
.required(true)
|
.required(true)
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.multiple_occurrences(false),
|
.multiple_occurrences(false),
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
app = app.arg(
|
app = app.arg(
|
||||||
Arg::new(options::ARG_FILES)
|
Arg::new(options::ARG_FILES)
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub fn arrnum_int_mult(arr_num: &[u8], basenum: u8, base_ten_int_fact: u8) -> Ve
|
||||||
new_amount = (u16::from(*u) * fact) + carry;
|
new_amount = (u16::from(*u) * fact) + carry;
|
||||||
rem = new_amount % base;
|
rem = new_amount % base;
|
||||||
carry = (new_amount - rem) / base;
|
carry = (new_amount - rem) / base;
|
||||||
ret_rev.push(rem as u8)
|
ret_rev.push(rem as u8);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
while carry != 0 {
|
while carry != 0 {
|
||||||
|
@ -119,7 +119,7 @@ pub fn arrnum_int_add(arrnum: &[u8], basenum: u8, base_ten_int_term: u8) -> Vec<
|
||||||
new_amount = u16::from(*u) + carry;
|
new_amount = u16::from(*u) + carry;
|
||||||
rem = new_amount % base;
|
rem = new_amount % base;
|
||||||
carry = (new_amount - rem) / base;
|
carry = (new_amount - rem) / base;
|
||||||
ret_rev.push(rem as u8)
|
ret_rev.push(rem as u8);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
while carry != 0 {
|
while carry != 0 {
|
||||||
|
@ -170,7 +170,7 @@ pub fn base_conv_float(src: &[u8], radix_src: u8, _radix_dest: u8) -> f64 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
factor /= radix_src_float;
|
factor /= radix_src_float;
|
||||||
r += factor * f64::from(*u)
|
r += factor * f64::from(*u);
|
||||||
}
|
}
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,10 +283,10 @@ impl SubParser {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Some(x) = n_ch {
|
if let Some(x) = n_ch {
|
||||||
it.put_back(x)
|
it.put_back(x);
|
||||||
};
|
};
|
||||||
if let Some(x) = preface {
|
if let Some(x) = preface {
|
||||||
it.put_back(x)
|
it.put_back(x);
|
||||||
};
|
};
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,7 +227,7 @@ impl UnescapedText {
|
||||||
new_vec.extend(tmp_str.bytes());
|
new_vec.extend(tmp_str.bytes());
|
||||||
tmp_str = String::new();
|
tmp_str = String::new();
|
||||||
}
|
}
|
||||||
UnescapedText::handle_escaped(new_vec, it, subs_mode)
|
UnescapedText::handle_escaped(new_vec, it, subs_mode);
|
||||||
}
|
}
|
||||||
x if x == '%' && !subs_mode => {
|
x if x == '%' && !subs_mode => {
|
||||||
if let Some(follow) = it.next() {
|
if let Some(follow) = it.next() {
|
||||||
|
|
|
@ -97,7 +97,7 @@ pub fn get_utility_is_second_arg() -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_utility_is_second_arg() {
|
pub fn set_utility_is_second_arg() {
|
||||||
crate::macros::UTILITY_IS_SECOND_ARG.store(true, Ordering::SeqCst)
|
crate::macros::UTILITY_IS_SECOND_ARG.store(true, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
|
|
||||||
// args_os() can be expensive to call, it copies all of argv before iterating.
|
// args_os() can be expensive to call, it copies all of argv before iterating.
|
||||||
|
|
|
@ -36,7 +36,7 @@ pub fn mute_sigpipe_panic() {
|
||||||
let hook = panic::take_hook();
|
let hook = panic::take_hook();
|
||||||
panic::set_hook(Box::new(move |info| {
|
panic::set_hook(Box::new(move |info| {
|
||||||
if !is_broken_pipe(info) {
|
if !is_broken_pipe(info) {
|
||||||
hook(info)
|
hook(info);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -461,9 +461,9 @@ fn set_file_context(path: impl AsRef<Path>, context: &str) -> Result<(), selinux
|
||||||
context,
|
context,
|
||||||
path.display(),
|
path.display(),
|
||||||
r
|
r
|
||||||
)
|
);
|
||||||
} else {
|
} else {
|
||||||
println!("set_file_context: '{}' => '{}'.", context, path.display())
|
println!("set_file_context: '{}' => '{}'.", context, path.display());
|
||||||
}
|
}
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ mod test_passgrp {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_grp2gid() {
|
fn test_grp2gid() {
|
||||||
if cfg!(target_os = "linux") || cfg!(target_os = "android") || cfg!(target_os = "windows") {
|
if cfg!(target_os = "linux") || cfg!(target_os = "android") || cfg!(target_os = "windows") {
|
||||||
assert_eq!(0, grp2gid("root").unwrap())
|
assert_eq!(0, grp2gid("root").unwrap());
|
||||||
} else {
|
} else {
|
||||||
assert_eq!(0, grp2gid("wheel").unwrap());
|
assert_eq!(0, grp2gid("wheel").unwrap());
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,7 @@ fn test_change_directory() {
|
||||||
.arg(pwd)
|
.arg(pwd)
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_move_str();
|
.stdout_move_str();
|
||||||
assert_eq!(out.trim(), temporary_path.as_os_str())
|
assert_eq!(out.trim(), temporary_path.as_os_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
|
|
@ -1551,7 +1551,7 @@ fn test_ls_inode() {
|
||||||
assert!(!re_long.is_match(result.stdout_str()));
|
assert!(!re_long.is_match(result.stdout_str()));
|
||||||
assert!(!result.stdout_str().contains(inode_long));
|
assert!(!result.stdout_str().contains(inode_long));
|
||||||
|
|
||||||
assert_eq!(inode_short, inode_long)
|
assert_eq!(inode_short, inode_long);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1901,7 +1901,7 @@ fn test_ls_version_sort() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.stdout_str().split('\n').collect::<Vec<_>>(),
|
result.stdout_str().split('\n').collect::<Vec<_>>(),
|
||||||
expected,
|
expected,
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -75,7 +75,7 @@ fn test_symbolic_mode() {
|
||||||
|
|
||||||
ucmd.arg("-m").arg("a=rwx").arg(TEST_DIR1).succeeds();
|
ucmd.arg("-m").arg("a=rwx").arg(TEST_DIR1).succeeds();
|
||||||
let perms = at.metadata(TEST_DIR1).permissions().mode();
|
let perms = at.metadata(TEST_DIR1).permissions().mode();
|
||||||
assert_eq!(perms, 0o40777)
|
assert_eq!(perms, 0o40777);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -85,7 +85,7 @@ fn test_symbolic_alteration() {
|
||||||
|
|
||||||
ucmd.arg("-m").arg("-w").arg(TEST_DIR1).succeeds();
|
ucmd.arg("-m").arg("-w").arg(TEST_DIR1).succeeds();
|
||||||
let perms = at.metadata(TEST_DIR1).permissions().mode();
|
let perms = at.metadata(TEST_DIR1).permissions().mode();
|
||||||
assert_eq!(perms, 0o40555)
|
assert_eq!(perms, 0o40555);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -98,5 +98,5 @@ fn test_multi_symbolic() {
|
||||||
.arg(TEST_DIR1)
|
.arg(TEST_DIR1)
|
||||||
.succeeds();
|
.succeeds();
|
||||||
let perms = at.metadata(TEST_DIR1).permissions().mode();
|
let perms = at.metadata(TEST_DIR1).permissions().mode();
|
||||||
assert_eq!(perms, 0o40750)
|
assert_eq!(perms, 0o40750);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ fn test_head_count() {
|
||||||
result_seq.iter().all(|x| input_seq.contains(x)),
|
result_seq.iter().all(|x| input_seq.contains(x)),
|
||||||
"Output includes element not from input: {}",
|
"Output includes element not from input: {}",
|
||||||
result.stdout_str()
|
result.stdout_str()
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -129,7 +129,7 @@ fn test_repeat() {
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|x| !input_seq.contains(x))
|
.filter(|x| !input_seq.contains(x))
|
||||||
.collect::<Vec<&i32>>()
|
.collect::<Vec<&i32>>()
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -155,7 +155,7 @@ fn test_multiple_decimals_general() {
|
||||||
test_helper(
|
test_helper(
|
||||||
"multiple_decimals_general",
|
"multiple_decimals_general",
|
||||||
&["-g", "--general-numeric-sort", "--sort=general-numeric"],
|
&["-g", "--general-numeric-sort", "--sort=general-numeric"],
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -163,7 +163,7 @@ fn test_multiple_decimals_numeric() {
|
||||||
test_helper(
|
test_helper(
|
||||||
"multiple_decimals_numeric",
|
"multiple_decimals_numeric",
|
||||||
&["-n", "--numeric-sort", "--sort=numeric"],
|
&["-n", "--numeric-sort", "--sort=numeric"],
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -171,7 +171,7 @@ fn test_numeric_with_trailing_invalid_chars() {
|
||||||
test_helper(
|
test_helper(
|
||||||
"numeric_trailing_chars",
|
"numeric_trailing_chars",
|
||||||
&["-n", "--numeric-sort", "--sort=numeric"],
|
&["-n", "--numeric-sort", "--sort=numeric"],
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -588,7 +588,7 @@ fn test_keys_with_options_blanks_start() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_keys_blanks_with_char_idx() {
|
fn test_keys_blanks_with_char_idx() {
|
||||||
test_helper("keys_blanks", &["-k 1.2b"])
|
test_helper("keys_blanks", &["-k 1.2b"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -648,7 +648,7 @@ fn test_keys_negative_size_match() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_keys_ignore_flag() {
|
fn test_keys_ignore_flag() {
|
||||||
test_helper("keys_ignore_flag", &["-k 1n -b"])
|
test_helper("keys_ignore_flag", &["-k 1n -b"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -27,7 +27,7 @@ fn get_symlink_times(at: &AtPath, path: &str) -> (FileTime, FileTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_file_times(at: &AtPath, path: &str, atime: FileTime, mtime: FileTime) {
|
fn set_file_times(at: &AtPath, path: &str, atime: FileTime, mtime: FileTime) {
|
||||||
filetime::set_file_times(&at.plus_as_string(path), atime, mtime).unwrap()
|
filetime::set_file_times(&at.plus_as_string(path), atime, mtime).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjusts for local timezone
|
// Adjusts for local timezone
|
||||||
|
|
|
@ -241,7 +241,7 @@ impl CmdResult {
|
||||||
"stdout was {}\nExpected any of {:#?}",
|
"stdout was {}\nExpected any of {:#?}",
|
||||||
self.stdout_str(),
|
self.stdout_str(),
|
||||||
expected
|
expected
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -419,14 +419,14 @@ impl CmdResult {
|
||||||
|
|
||||||
pub fn stdout_matches(&self, regex: ®ex::Regex) -> &CmdResult {
|
pub fn stdout_matches(&self, regex: ®ex::Regex) -> &CmdResult {
|
||||||
if !regex.is_match(self.stdout_str().trim()) {
|
if !regex.is_match(self.stdout_str().trim()) {
|
||||||
panic!("Stdout does not match regex:\n{}", self.stdout_str())
|
panic!("Stdout does not match regex:\n{}", self.stdout_str());
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stdout_does_not_match(&self, regex: ®ex::Regex) -> &CmdResult {
|
pub fn stdout_does_not_match(&self, regex: ®ex::Regex) -> &CmdResult {
|
||||||
if regex.is_match(self.stdout_str().trim()) {
|
if regex.is_match(self.stdout_str().trim()) {
|
||||||
panic!("Stdout matches regex:\n{}", self.stdout_str())
|
panic!("Stdout matches regex:\n{}", self.stdout_str());
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -1059,7 +1059,7 @@ impl UCommand {
|
||||||
.write_all(input);
|
.write_all(input);
|
||||||
if !self.ignore_stdin_write_error {
|
if !self.ignore_stdin_write_error {
|
||||||
if let Err(e) = write_result {
|
if let Err(e) = write_result {
|
||||||
panic!("failed to write to stdin of child: {}", e)
|
panic!("failed to write to stdin of child: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue