mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge pull request #7689 from nyurik/inline2
chore: manual inline formatting
This commit is contained in:
+13
-13
@@ -64,7 +64,7 @@ fn main() -> io::Result<()> {
|
||||
for platform in ["unix", "macos", "windows", "unix_android"] {
|
||||
let platform_utils: Vec<String> = String::from_utf8(
|
||||
std::process::Command::new("./util/show-utils.sh")
|
||||
.arg(format!("--features=feat_os_{}", platform))
|
||||
.arg(format!("--features=feat_os_{platform}"))
|
||||
.output()?
|
||||
.stdout,
|
||||
)
|
||||
@@ -138,7 +138,7 @@ fn main() -> io::Result<()> {
|
||||
if name == "[" {
|
||||
continue;
|
||||
}
|
||||
let p = format!("docs/src/utils/{}.md", name);
|
||||
let p = format!("docs/src/utils/{name}.md");
|
||||
|
||||
let markdown = File::open(format!("src/uu/{name}/{name}.md"))
|
||||
.and_then(|mut f: File| {
|
||||
@@ -158,11 +158,11 @@ fn main() -> io::Result<()> {
|
||||
markdown,
|
||||
}
|
||||
.markdown()?;
|
||||
println!("Wrote to '{}'", p);
|
||||
println!("Wrote to '{p}'");
|
||||
} else {
|
||||
println!("Error writing to {}", p);
|
||||
println!("Error writing to {p}");
|
||||
}
|
||||
writeln!(summary, "* [{0}](utils/{0}.md)", name)?;
|
||||
writeln!(summary, "* [{name}](utils/{name}.md)")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -214,7 +214,7 @@ impl MDWriter<'_, '_> {
|
||||
.iter()
|
||||
.any(|u| u == self.name)
|
||||
{
|
||||
writeln!(self.w, "<i class=\"fa fa-brands fa-{}\"></i>", icon)?;
|
||||
writeln!(self.w, "<i class=\"fa fa-brands fa-{icon}\"></i>")?;
|
||||
}
|
||||
}
|
||||
writeln!(self.w, "</div>")?;
|
||||
@@ -242,7 +242,7 @@ impl MDWriter<'_, '_> {
|
||||
let usage = usage.replace("{}", self.name);
|
||||
|
||||
writeln!(self.w, "\n```")?;
|
||||
writeln!(self.w, "{}", usage)?;
|
||||
writeln!(self.w, "{usage}")?;
|
||||
writeln!(self.w, "```")
|
||||
} else {
|
||||
Ok(())
|
||||
@@ -293,14 +293,14 @@ impl MDWriter<'_, '_> {
|
||||
writeln!(self.w)?;
|
||||
for line in content.lines().skip_while(|l| !l.starts_with('-')) {
|
||||
if let Some(l) = line.strip_prefix("- ") {
|
||||
writeln!(self.w, "{}", l)?;
|
||||
writeln!(self.w, "{l}")?;
|
||||
} else if line.starts_with('`') {
|
||||
writeln!(self.w, "```shell\n{}\n```", line.trim_matches('`'))?;
|
||||
} else if line.is_empty() {
|
||||
writeln!(self.w)?;
|
||||
} else {
|
||||
println!("Not sure what to do with this line:");
|
||||
println!("{}", line);
|
||||
println!("{line}");
|
||||
}
|
||||
}
|
||||
writeln!(self.w)?;
|
||||
@@ -332,14 +332,14 @@ impl MDWriter<'_, '_> {
|
||||
write!(self.w, ", ")?;
|
||||
}
|
||||
write!(self.w, "<code>")?;
|
||||
write!(self.w, "--{}", l)?;
|
||||
write!(self.w, "--{l}")?;
|
||||
if let Some(names) = arg.get_value_names() {
|
||||
write!(
|
||||
self.w,
|
||||
"={}",
|
||||
names
|
||||
.iter()
|
||||
.map(|x| format!("<{}>", x))
|
||||
.map(|x| format!("<{x}>"))
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ")
|
||||
)?;
|
||||
@@ -353,14 +353,14 @@ impl MDWriter<'_, '_> {
|
||||
write!(self.w, ", ")?;
|
||||
}
|
||||
write!(self.w, "<code>")?;
|
||||
write!(self.w, "-{}", s)?;
|
||||
write!(self.w, "-{s}")?;
|
||||
if let Some(names) = arg.get_value_names() {
|
||||
write!(
|
||||
self.w,
|
||||
" {}",
|
||||
names
|
||||
.iter()
|
||||
.map(|x| format!("<{}>", x))
|
||||
.map(|x| format!("<{x}>"))
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ")
|
||||
)?;
|
||||
|
||||
@@ -68,7 +68,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
//
|
||||
|
||||
for path in name_args {
|
||||
print!("{}{}", basename(path, &suffix), line_ending);
|
||||
print!("{}{line_ending}", basename(path, &suffix));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -101,7 +101,7 @@ enum CatError {
|
||||
#[error("{0}")]
|
||||
Nix(#[from] nix::Error),
|
||||
/// Unknown file type; it's not a regular file, socket, etc.
|
||||
#[error("unknown filetype: {}", ft_debug)]
|
||||
#[error("unknown filetype: {ft_debug}")]
|
||||
UnknownFiletype {
|
||||
/// A debug print of the file type
|
||||
ft_debug: String,
|
||||
@@ -457,7 +457,7 @@ fn cat_files(files: &[String], options: &OutputOptions) -> UResult<()> {
|
||||
|
||||
for path in files {
|
||||
if let Err(err) = cat_path(path, options, &mut state, out_info.as_ref()) {
|
||||
error_messages.push(format!("{}: {}", path.maybe_quote(), err));
|
||||
error_messages.push(format!("{}: {err}", path.maybe_quote()));
|
||||
}
|
||||
}
|
||||
if state.skipped_carriage_return {
|
||||
|
||||
@@ -106,7 +106,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
Err(err) => {
|
||||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!("cannot stat attributes of {}: {}", fref.quote(), err),
|
||||
format!("cannot stat attributes of {}: {err}", fref.quote()),
|
||||
));
|
||||
}
|
||||
},
|
||||
@@ -373,7 +373,7 @@ impl Chmoder {
|
||||
format!("{}: Permission denied", file.quote()),
|
||||
));
|
||||
} else {
|
||||
return Err(USimpleError::new(1, format!("{}: {}", file.quote(), err)));
|
||||
return Err(USimpleError::new(1, format!("{}: {err}", file.quote())));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -441,24 +441,21 @@ impl Chmoder {
|
||||
if fperm == mode {
|
||||
if self.verbose && !self.changes {
|
||||
println!(
|
||||
"mode of {} retained as {:04o} ({})",
|
||||
"mode of {} retained as {fperm:04o} ({})",
|
||||
file.quote(),
|
||||
fperm,
|
||||
display_permissions_unix(fperm as mode_t, false),
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
} else if let Err(err) = fs::set_permissions(file, fs::Permissions::from_mode(mode)) {
|
||||
if !self.quiet {
|
||||
show_error!("{}", err);
|
||||
show_error!("{err}");
|
||||
}
|
||||
if self.verbose {
|
||||
println!(
|
||||
"failed to change mode of file {} from {:04o} ({}) to {:04o} ({})",
|
||||
"failed to change mode of file {} from {fperm:04o} ({}) to {mode:04o} ({})",
|
||||
file.quote(),
|
||||
fperm,
|
||||
display_permissions_unix(fperm as mode_t, false),
|
||||
mode,
|
||||
display_permissions_unix(mode as mode_t, false)
|
||||
);
|
||||
}
|
||||
@@ -466,11 +463,9 @@ impl Chmoder {
|
||||
} else {
|
||||
if self.verbose || self.changes {
|
||||
println!(
|
||||
"mode of {} changed from {:04o} ({}) to {:04o} ({})",
|
||||
"mode of {} changed from {fperm:04o} ({}) to {mode:04o} ({})",
|
||||
file.quote(),
|
||||
fperm,
|
||||
display_permissions_unix(fperm as mode_t, false),
|
||||
mode,
|
||||
display_permissions_unix(mode as mode_t, false)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -485,7 +485,7 @@ pub(crate) fn copy_directory(
|
||||
}
|
||||
|
||||
// Print an error message, but continue traversing the directory.
|
||||
Err(e) => show_error!("{}", e),
|
||||
Err(e) => show_error!("{e}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-16
@@ -53,11 +53,11 @@ quick_error! {
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
/// Simple io::Error wrapper
|
||||
IoErr(err: io::Error) { from() source(err) display("{}", err)}
|
||||
IoErr(err: io::Error) { from() source(err) display("{err}")}
|
||||
|
||||
/// Wrapper for io::Error with path context
|
||||
IoErrContext(err: io::Error, path: String) {
|
||||
display("{}: {}", path, err)
|
||||
display("{path}: {err}")
|
||||
context(path: &'a str, err: io::Error) -> (err, path.to_owned())
|
||||
context(context: String, err: io::Error) -> (err, context)
|
||||
source(err)
|
||||
@@ -65,7 +65,7 @@ quick_error! {
|
||||
|
||||
/// General copy error
|
||||
Error(err: String) {
|
||||
display("{}", err)
|
||||
display("{err}")
|
||||
from(err: String) -> (err)
|
||||
from(err: &'static str) -> (err.to_string())
|
||||
}
|
||||
@@ -75,7 +75,7 @@ quick_error! {
|
||||
NotAllFilesCopied {}
|
||||
|
||||
/// Simple walkdir::Error wrapper
|
||||
WalkDirErr(err: walkdir::Error) { from() display("{}", err) source(err) }
|
||||
WalkDirErr(err: walkdir::Error) { from() display("{err}") source(err) }
|
||||
|
||||
/// Simple std::path::StripPrefixError wrapper
|
||||
StripPrefixError(err: StripPrefixError) { from() }
|
||||
@@ -87,15 +87,15 @@ quick_error! {
|
||||
Skipped(exit_with_error:bool) { }
|
||||
|
||||
/// Result of a skipped file
|
||||
InvalidArgument(description: String) { display("{}", description) }
|
||||
InvalidArgument(description: String) { display("{description}") }
|
||||
|
||||
/// All standard options are included as an an implementation
|
||||
/// path, but those that are not implemented yet should return
|
||||
/// a NotImplemented error.
|
||||
NotImplemented(opt: String) { display("Option '{}' not yet implemented.", opt) }
|
||||
NotImplemented(opt: String) { display("Option '{opt}' not yet implemented.") }
|
||||
|
||||
/// Invalid arguments to backup
|
||||
Backup(description: String) { display("{}\nTry '{} --help' for more information.", description, uucore::execution_phrase()) }
|
||||
Backup(description: String) { display("{description}\nTry '{} --help' for more information.", uucore::execution_phrase()) }
|
||||
|
||||
NotADirectory(path: PathBuf) { display("'{}' is not a directory", path.display()) }
|
||||
}
|
||||
@@ -791,7 +791,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
// code should still be EXIT_ERR as does GNU cp
|
||||
Error::NotAllFilesCopied => {}
|
||||
// Else we caught a fatal bubbled-up error, log it to stderr
|
||||
_ => show_error!("{}", error),
|
||||
_ => show_error!("{error}"),
|
||||
};
|
||||
set_exit_code(EXIT_ERR);
|
||||
}
|
||||
@@ -1283,7 +1283,7 @@ fn show_error_if_needed(error: &Error) {
|
||||
// should return an error from GNU 9.2
|
||||
}
|
||||
_ => {
|
||||
show_error!("{}", error);
|
||||
show_error!("{error}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1686,18 +1686,13 @@ pub(crate) fn copy_attributes(
|
||||
handle_preserve(&attributes.context, || -> CopyResult<()> {
|
||||
let context = selinux::SecurityContext::of_path(source, false, false).map_err(|e| {
|
||||
format!(
|
||||
"failed to get security context of {}: {}",
|
||||
"failed to get security context of {}: {e}",
|
||||
source.display(),
|
||||
e
|
||||
)
|
||||
})?;
|
||||
if let Some(context) = context {
|
||||
context.set_for_path(dest, false, false).map_err(|e| {
|
||||
format!(
|
||||
"failed to set security context for {}: {}",
|
||||
dest.display(),
|
||||
e
|
||||
)
|
||||
format!("failed to set security context for {}: {e}", dest.display(),)
|
||||
})?;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@ impl std::fmt::Display for Pattern {
|
||||
match self {
|
||||
Self::UpToLine(n, _) => write!(f, "{n}"),
|
||||
Self::UpToMatch(regex, 0, _) => write!(f, "/{}/", regex.as_str()),
|
||||
Self::UpToMatch(regex, offset, _) => write!(f, "/{}/{:+}", regex.as_str(), offset),
|
||||
Self::UpToMatch(regex, offset, _) => write!(f, "/{}/{offset:+}", regex.as_str()),
|
||||
Self::SkipToMatch(regex, 0, _) => write!(f, "%{}%", regex.as_str()),
|
||||
Self::SkipToMatch(regex, offset, _) => write!(f, "%{}%{:+}", regex.as_str(), offset),
|
||||
Self::SkipToMatch(regex, offset, _) => write!(f, "%{}%{offset:+}", regex.as_str()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,7 @@ fn validate_line_numbers(patterns: &[Pattern]) -> Result<(), CsplitError> {
|
||||
(_, 0) => Err(CsplitError::LineNumberIsZero),
|
||||
// two consecutive numbers should not be equal
|
||||
(n, m) if n == m => {
|
||||
show_warning!("line number '{}' is the same as preceding line number", n);
|
||||
show_warning!("line number '{n}' is the same as preceding line number");
|
||||
Ok(n)
|
||||
}
|
||||
// a number cannot be greater than the one that follows
|
||||
|
||||
@@ -83,7 +83,7 @@ pub(crate) fn to_magnitude_and_suffix(n: u128, suffix_type: SuffixType) -> Strin
|
||||
if quotient < 10.0 {
|
||||
format!("{quotient:.1} {suffix}")
|
||||
} else {
|
||||
format!("{} {}", quotient.round(), suffix)
|
||||
format!("{} {suffix}", quotient.round())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,29 +29,28 @@ fn unimplemented_flags_should_error_non_linux() {
|
||||
"noctty",
|
||||
"nofollow",
|
||||
] {
|
||||
let args = vec![format!("iflag={}", flag)];
|
||||
let args = vec![format!("iflag={flag}")];
|
||||
|
||||
if Parser::new()
|
||||
.parse(&args.iter().map(AsRef::as_ref).collect::<Vec<_>>()[..])
|
||||
.is_ok()
|
||||
{
|
||||
succeeded.push(format!("iflag={}", flag));
|
||||
succeeded.push(format!("iflag={flag}"));
|
||||
}
|
||||
|
||||
let args = vec![format!("oflag={}", flag)];
|
||||
let args = vec![format!("oflag={flag}")];
|
||||
|
||||
if Parser::new()
|
||||
.parse(&args.iter().map(AsRef::as_ref).collect::<Vec<_>>()[..])
|
||||
.is_ok()
|
||||
{
|
||||
succeeded.push(format!("iflag={}", flag));
|
||||
succeeded.push(format!("iflag={flag}"));
|
||||
}
|
||||
}
|
||||
|
||||
assert!(
|
||||
succeeded.is_empty(),
|
||||
"The following flags did not panic as expected: {:?}",
|
||||
succeeded
|
||||
"The following flags did not panic as expected: {succeeded:?}",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,9 +98,9 @@ pub(crate) fn to_magnitude_and_suffix(n: u128, suffix_type: SuffixType) -> Strin
|
||||
if rem % (bases[i] / 10) == 0 {
|
||||
format!("{quot}.{tenths_place}{suffix}")
|
||||
} else if tenths_place + 1 == 10 || quot >= 10 {
|
||||
format!("{}{}", quot + 1, suffix)
|
||||
format!("{}{suffix}", quot + 1)
|
||||
} else {
|
||||
format!("{}.{}{}", quot, tenths_place + 1, suffix)
|
||||
format!("{quot}.{}{suffix}", tenths_place + 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,13 +114,7 @@ fn generate_ls_colors(fmt: &OutputFmt, sep: &str) -> String {
|
||||
}
|
||||
let (prefix, suffix) = get_colors_format_strings(fmt);
|
||||
let ls_colors = parts.join(sep);
|
||||
format!(
|
||||
"{}{}:{}:{}",
|
||||
prefix,
|
||||
generate_type_output(fmt),
|
||||
ls_colors,
|
||||
suffix
|
||||
)
|
||||
format!("{prefix}{}:{ls_colors}:{suffix}", generate_type_output(fmt),)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -233,10 +227,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!("{}: {}", path.maybe_quote(), e),
|
||||
));
|
||||
return Err(USimpleError::new(1, format!("{}: {e}", path.maybe_quote())));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -388,9 +379,8 @@ where
|
||||
if val.is_empty() {
|
||||
return Err(format!(
|
||||
// The double space is what GNU is doing
|
||||
"{}:{}: invalid line; missing second token",
|
||||
"{}:{num}: invalid line; missing second token",
|
||||
fp.maybe_quote(),
|
||||
num
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -466,7 +466,7 @@ fn build_exclude_patterns(matches: &ArgMatches) -> UResult<Vec<Pattern>> {
|
||||
let mut exclude_patterns = Vec::new();
|
||||
for f in excludes_iterator.chain(exclude_from_iterator) {
|
||||
if matches.get_flag(options::VERBOSE) {
|
||||
println!("adding {:?} to the exclude list ", &f);
|
||||
println!("adding {f:?} to the exclude list ");
|
||||
}
|
||||
match parse_glob::from_str(&f) {
|
||||
Ok(glob) => exclude_patterns.push(glob),
|
||||
@@ -559,7 +559,7 @@ impl StatPrinter {
|
||||
let secs = get_time_secs(time, stat)?;
|
||||
let tm = DateTime::<Local>::from(UNIX_EPOCH + Duration::from_secs(secs));
|
||||
let time_str = tm.format(&self.time_format).to_string();
|
||||
print!("{}\t{}\t", self.convert_size(size), time_str);
|
||||
print!("{}\t{time_str}\t", self.convert_size(size));
|
||||
} else {
|
||||
print!("{}\t", self.convert_size(size));
|
||||
}
|
||||
@@ -1095,12 +1095,12 @@ fn format_error_message(error: &ParseSizeError, s: &str, option: &str) -> String
|
||||
// GNU's du echos affected flag, -B or --block-size (-t or --threshold), depending user's selection
|
||||
match error {
|
||||
ParseSizeError::InvalidSuffix(_) => {
|
||||
format!("invalid suffix in --{} argument {}", option, s.quote())
|
||||
format!("invalid suffix in --{option} argument {}", s.quote())
|
||||
}
|
||||
ParseSizeError::ParseFailure(_) | ParseSizeError::PhysicalMem(_) => {
|
||||
format!("invalid --{} argument {}", option, s.quote())
|
||||
format!("invalid --{option} argument {}", s.quote())
|
||||
}
|
||||
ParseSizeError::SizeTooBig(_) => format!("--{} argument {} too large", option, s.quote()),
|
||||
ParseSizeError::SizeTooBig(_) => format!("--{option} argument {} too large", s.quote()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+8
-8
@@ -193,7 +193,7 @@ fn load_config_file(opts: &mut Options) -> UResult<()> {
|
||||
};
|
||||
|
||||
let conf =
|
||||
conf.map_err(|e| USimpleError::new(1, format!("{}: {}", file.maybe_quote(), e)))?;
|
||||
conf.map_err(|e| USimpleError::new(1, format!("{}: {e}", file.maybe_quote())))?;
|
||||
|
||||
for (_, prop) in &conf {
|
||||
// ignore all INI section lines (treat them as comments)
|
||||
@@ -338,7 +338,7 @@ pub fn parse_args_from_str(text: &NativeIntStr) -> UResult<Vec<NativeIntString>>
|
||||
fn debug_print_args(args: &[OsString]) {
|
||||
eprintln!("input args:");
|
||||
for (i, arg) in args.iter().enumerate() {
|
||||
eprintln!("arg[{}]: {}", i, arg.quote());
|
||||
eprintln!("arg[{i}]: {}", arg.quote());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ impl EnvAppData {
|
||||
fn make_error_no_such_file_or_dir(&self, prog: &OsStr) -> Box<dyn UError> {
|
||||
uucore::show_error!("{}: No such file or directory", prog.quote());
|
||||
if !self.had_string_argument {
|
||||
uucore::show_error!("{}", ERROR_MSG_S_SHEBANG);
|
||||
uucore::show_error!("{ERROR_MSG_S_SHEBANG}");
|
||||
}
|
||||
ExitCode::new(127)
|
||||
}
|
||||
@@ -451,9 +451,9 @@ impl EnvAppData {
|
||||
let s = format!("{e}");
|
||||
if !s.is_empty() {
|
||||
let s = s.trim_end();
|
||||
uucore::show_error!("{}", s);
|
||||
uucore::show_error!("{s}");
|
||||
}
|
||||
uucore::show_error!("{}", ERROR_MSG_S_SHEBANG);
|
||||
uucore::show_error!("{ERROR_MSG_S_SHEBANG}");
|
||||
uucore::error::ExitCode::new(125)
|
||||
}
|
||||
}
|
||||
@@ -545,9 +545,9 @@ impl EnvAppData {
|
||||
if do_debug_printing {
|
||||
eprintln!("executing: {}", prog.maybe_quote());
|
||||
let arg_prefix = " arg";
|
||||
eprintln!("{}[{}]= {}", arg_prefix, 0, arg0.quote());
|
||||
eprintln!("{arg_prefix}[{}]= {}", 0, arg0.quote());
|
||||
for (i, arg) in args.iter().enumerate() {
|
||||
eprintln!("{}[{}]= {}", arg_prefix, i + 1, arg.quote());
|
||||
eprintln!("{arg_prefix}[{}]= {}", i + 1, arg.quote());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,7 +590,7 @@ impl EnvAppData {
|
||||
return Err(126.into());
|
||||
}
|
||||
_ => {
|
||||
uucore::show_error!("unknown error: {:?}", err);
|
||||
uucore::show_error!("unknown error: {err:?}");
|
||||
return Err(126.into());
|
||||
}
|
||||
},
|
||||
|
||||
@@ -448,7 +448,7 @@ fn expand(options: &Options) -> UResult<()> {
|
||||
|
||||
for file in &options.files {
|
||||
if Path::new(file).is_dir() {
|
||||
show_error!("{}: Is a directory", file);
|
||||
show_error!("{file}: Is a directory");
|
||||
set_exit_code(1);
|
||||
continue;
|
||||
}
|
||||
@@ -463,7 +463,7 @@ fn expand(options: &Options) -> UResult<()> {
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
show_error!("{}", e);
|
||||
show_error!("{e}");
|
||||
set_exit_code(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
}
|
||||
Err(e) => {
|
||||
set_exit_code(1);
|
||||
show_error!("error reading input: {}", e);
|
||||
show_error!("error reading input: {e}");
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
}
|
||||
|
||||
if let Err(e) = w.flush() {
|
||||
show_error!("{}", e);
|
||||
show_error!("{e}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
// Try to display this error.
|
||||
if let Err(print_fail) = error {
|
||||
// Completely ignore any error here, no more failover and we will fail in any case.
|
||||
let _ = writeln!(std::io::stderr(), "{}: {}", uucore::util_name(), print_fail);
|
||||
let _ = writeln!(std::io::stderr(), "{}: {print_fail}", uucore::util_name());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ impl FmtOptions {
|
||||
Err(e) => {
|
||||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!("Invalid TABWIDTH specification: {}: {}", s.quote(), e),
|
||||
format!("Invalid TABWIDTH specification: {}: {e}", s.quote()),
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
Some(inp_width) => inp_width.parse::<usize>().map_err(|e| {
|
||||
USimpleError::new(
|
||||
1,
|
||||
format!("illegal width value ({}): {}", inp_width.quote(), e),
|
||||
format!("illegal width value ({}): {e}", inp_width.quote()),
|
||||
)
|
||||
})?,
|
||||
None => 80,
|
||||
|
||||
@@ -69,7 +69,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
match Passwd::locate(user.as_str()) {
|
||||
Ok(p) => {
|
||||
let groups: Vec<String> = p.belongs_to().iter().map(infallible_gid2grp).collect();
|
||||
println!("{} : {}", user, groups.join(" "));
|
||||
println!("{user} : {}", groups.join(" "));
|
||||
}
|
||||
Err(_) => {
|
||||
// The `show!()` macro sets the global exit code for the program.
|
||||
|
||||
+14
-17
@@ -181,7 +181,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
#[cfg(all(any(target_os = "linux", target_os = "android"), feature = "selinux"))]
|
||||
if let Ok(context) = selinux::SecurityContext::current(false) {
|
||||
let bytes = context.as_bytes();
|
||||
print!("{}{}", String::from_utf8_lossy(bytes), line_ending);
|
||||
print!("{}{line_ending}", String::from_utf8_lossy(bytes));
|
||||
} else {
|
||||
// print error because `cflag` was explicitly requested
|
||||
return Err(USimpleError::new(1, "can't get process context"));
|
||||
@@ -246,7 +246,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
"{}",
|
||||
if state.nflag {
|
||||
entries::gid2grp(gid).unwrap_or_else(|_| {
|
||||
show_error!("cannot find name for group ID {}", gid);
|
||||
show_error!("cannot find name for group ID {gid}");
|
||||
set_exit_code(1);
|
||||
gid.to_string()
|
||||
})
|
||||
@@ -261,7 +261,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
"{}",
|
||||
if state.nflag {
|
||||
entries::uid2usr(uid).unwrap_or_else(|_| {
|
||||
show_error!("cannot find name for user ID {}", uid);
|
||||
show_error!("cannot find name for user ID {uid}");
|
||||
set_exit_code(1);
|
||||
uid.to_string()
|
||||
})
|
||||
@@ -286,7 +286,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
.map(|&id| {
|
||||
if state.nflag {
|
||||
entries::gid2grp(id).unwrap_or_else(|_| {
|
||||
show_error!("cannot find name for group ID {}", id);
|
||||
show_error!("cannot find name for group ID {id}");
|
||||
set_exit_code(1);
|
||||
id.to_string()
|
||||
})
|
||||
@@ -557,39 +557,37 @@ fn id_print(state: &State, groups: &[u32]) {
|
||||
let egid = state.ids.as_ref().unwrap().egid;
|
||||
|
||||
print!(
|
||||
"uid={}({})",
|
||||
uid,
|
||||
"uid={uid}({})",
|
||||
entries::uid2usr(uid).unwrap_or_else(|_| {
|
||||
show_error!("cannot find name for user ID {}", uid);
|
||||
show_error!("cannot find name for user ID {uid}");
|
||||
set_exit_code(1);
|
||||
uid.to_string()
|
||||
})
|
||||
);
|
||||
print!(
|
||||
" gid={}({})",
|
||||
gid,
|
||||
" gid={gid}({})",
|
||||
entries::gid2grp(gid).unwrap_or_else(|_| {
|
||||
show_error!("cannot find name for group ID {}", gid);
|
||||
show_error!("cannot find name for group ID {gid}");
|
||||
set_exit_code(1);
|
||||
gid.to_string()
|
||||
})
|
||||
);
|
||||
if !state.user_specified && (euid != uid) {
|
||||
print!(
|
||||
" euid={}({})",
|
||||
euid,
|
||||
" euid={euid}({})",
|
||||
entries::uid2usr(euid).unwrap_or_else(|_| {
|
||||
show_error!("cannot find name for user ID {}", euid);
|
||||
show_error!("cannot find name for user ID {euid}");
|
||||
set_exit_code(1);
|
||||
euid.to_string()
|
||||
})
|
||||
);
|
||||
}
|
||||
if !state.user_specified && (egid != gid) {
|
||||
// BUG? printing egid={euid} ?
|
||||
print!(
|
||||
" egid={egid}({})",
|
||||
entries::gid2grp(egid).unwrap_or_else(|_| {
|
||||
show_error!("cannot find name for group ID {}", egid);
|
||||
show_error!("cannot find name for group ID {egid}");
|
||||
set_exit_code(1);
|
||||
egid.to_string()
|
||||
})
|
||||
@@ -600,10 +598,9 @@ fn id_print(state: &State, groups: &[u32]) {
|
||||
groups
|
||||
.iter()
|
||||
.map(|&gr| format!(
|
||||
"{}({})",
|
||||
gr,
|
||||
"{gr}({})",
|
||||
entries::gid2grp(gr).unwrap_or_else(|_| {
|
||||
show_error!("cannot find name for group ID {}", gr);
|
||||
show_error!("cannot find name for group ID {gr}");
|
||||
set_exit_code(1);
|
||||
gr.to_string()
|
||||
})
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user