1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

Fix to build on Rust 1.32.0 and formatting

This commit is contained in:
Alex Lyon 2020-06-16 04:08:17 -05:00
parent 5cea5faee0
commit 8377abadb6
No known key found for this signature in database
GPG key ID: 15B1C566BEF7A2D8
3 changed files with 31 additions and 17 deletions

View file

@ -36,7 +36,7 @@ fn usage<T>(utils: &UtilityMap<T>, name: &str) {
fn binary_path(args: &mut impl Iterator<Item = OsString>) -> PathBuf { fn binary_path(args: &mut impl Iterator<Item = OsString>) -> PathBuf {
match args.next() { match args.next() {
Some(s) if !s.is_empty() => PathBuf::from(s), Some(ref s) if !s.is_empty() => PathBuf::from(s),
_ => std::env::current_exe().unwrap(), _ => std::env::current_exe().unwrap(),
} }
} }
@ -61,8 +61,7 @@ fn main() {
// binary name equals prefixed util name? // binary name equals prefixed util name?
// * prefix/stem may be any string ending in a non-alphanumeric character // * prefix/stem may be any string ending in a non-alphanumeric character
let utilname = let utilname = if let Some(util) = utils.keys().find(|util| {
if let Some(util) = utils.keys().find(|util| {
binary_as_util.ends_with(*util) binary_as_util.ends_with(*util)
&& !(&binary_as_util[..binary_as_util.len() - (*util).len()]) && !(&binary_as_util[..binary_as_util.len() - (*util).len()])
.ends_with(char::is_alphanumeric) .ends_with(char::is_alphanumeric)
@ -90,7 +89,10 @@ fn main() {
match utils.get(&util[..]) { match utils.get(&util[..]) {
Some(&uumain) => { Some(&uumain) => {
let code = uumain((vec![util_os, OsString::from("--help")].into_iter()).chain(args)); let code = uumain(
(vec![util_os, OsString::from("--help")].into_iter())
.chain(args),
);
io::stdout().flush().expect("could not flush stdout"); io::stdout().flush().expect("could not flush stdout");
process::exit(code); process::exit(code);
} }

View file

@ -24,5 +24,11 @@ static LONG_HELP: &str = "
"; ";
pub fn uumain(args: impl uucore::Args) -> i32 { pub fn uumain(args: impl uucore::Args) -> i32 {
base_common::execute(args.collect_str(), SYNTAX, SUMMARY, LONG_HELP, Format::Base32) base_common::execute(
args.collect_str(),
SYNTAX,
SUMMARY,
LONG_HELP,
Format::Base32,
)
} }

View file

@ -25,5 +25,11 @@ static LONG_HELP: &str = "
"; ";
pub fn uumain(args: impl uucore::Args) -> i32 { pub fn uumain(args: impl uucore::Args) -> i32 {
base_common::execute(args.collect_str(), SYNTAX, SUMMARY, LONG_HELP, Format::Base64) base_common::execute(
args.collect_str(),
SYNTAX,
SUMMARY,
LONG_HELP,
Format::Base64,
)
} }