1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

Merge pull request #7423 from sylvestre/rust-2024

bump to Rust edition 2024 & min = 1.85
This commit is contained in:
Daniel Hofstetter 2025-03-25 09:30:03 +01:00 committed by GitHub
commit f038d3e716
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
310 changed files with 1106 additions and 993 deletions

View file

@ -11,7 +11,7 @@ env:
PROJECT_NAME: coreutils
PROJECT_DESC: "Core universal (cross-platform) utilities"
PROJECT_AUTH: "uutils"
RUST_MIN_SRV: "1.82.0"
RUST_MIN_SRV: "1.85.0"
# * style job configuration
STYLE_FAIL_ON_FAULT: true ## (bool) fail the build if a style job contains a fault (error or warning); may be overridden on a per-job basis

View file

@ -16,8 +16,8 @@ repository = "https://github.com/uutils/coreutils"
readme = "README.md"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
rust-version = "1.82.0"
edition = "2021"
rust-version = "1.85.0"
edition = "2024"
build = "build.rs"

View file

@ -14,7 +14,7 @@
[![dependency status](https://deps.rs/repo/github/uutils/coreutils/status.svg)](https://deps.rs/repo/github/uutils/coreutils)
[![CodeCov](https://codecov.io/gh/uutils/coreutils/branch/master/graph/badge.svg)](https://codecov.io/gh/uutils/coreutils)
![MSRV](https://img.shields.io/badge/MSRV-1.82.0-brightgreen)
![MSRV](https://img.shields.io/badge/MSRV-1.85.0-brightgreen)
</div>
@ -70,7 +70,7 @@ the [coreutils docs](https://github.com/uutils/uutils.github.io) repository.
### Rust Version
uutils follows Rust's release channels and is tested against stable, beta and
nightly. The current Minimum Supported Rust Version (MSRV) is `1.82.0`.
nightly. The current Minimum Supported Rust Version (MSRV) is `1.85.0`.
## Building

View file

@ -34,7 +34,7 @@ pub fn main() {
match krate.as_ref() {
"default" | "macos" | "unix" | "windows" | "selinux" | "zip" => continue, // common/standard feature names
"nightly" | "test_unimplemented" | "expensive_tests" | "test_risky_names" => {
continue
continue;
} // crate-local custom features
"uudoc" => continue, // is not a utility
"test" => continue, // over-ridden with 'uu_test' to avoid collision with rust core crate 'test'

View file

@ -2,7 +2,7 @@
name = "uucore-fuzz"
version = "0.0.0"
publish = false
edition = "2021"
edition = "2024"
[package.metadata]
cargo-fuzz = true

View file

@ -69,7 +69,9 @@ fuzz_target!(|_data: &[u8]| {
// Use C locale to avoid false positives, like in https://github.com/uutils/coreutils/issues/5378,
// because uutils expr doesn't support localization yet
// TODO remove once uutils expr supports localization
unsafe {
env::set_var("LC_COLLATE", "C");
}
let rust_result = generate_and_run_uumain(&args, uumain, None);
let gnu_result = match run_gnu_cmd(CMD_PATH, &args[1..], false, None) {

View file

@ -84,7 +84,9 @@ fuzz_target!(|_data: &[u8]| {
let rust_result = generate_and_run_uumain(&args, uumain, None);
// TODO remove once uutils printf supports localization
unsafe {
env::set_var("LC_ALL", "C");
}
let gnu_result = match run_gnu_cmd(CMD_PATH, &args[1..], false, None) {
Ok(result) => result,
Err(error_result) => {

View file

@ -60,7 +60,9 @@ fuzz_target!(|_data: &[u8]| {
let rust_result = generate_and_run_uumain(&args, uumain, Some(&input_lines));
// TODO remove once uutils sort supports localization
unsafe {
env::set_var("LC_ALL", "C");
}
let gnu_result = match run_gnu_cmd(CMD_PATH, &args[1..], false, Some(&input_lines)) {
Ok(result) => result,
Err(error_result) => {

View file

@ -23,7 +23,9 @@ fn main() -> io::Result<()> {
if tldr_zip.is_none() {
println!("Warning: No tldr archive found, so the documentation will not include examples.");
println!("To include examples in the documentation, download the tldr archive and put it in the docs/ folder.");
println!(
"To include examples in the documentation, download the tldr archive and put it in the docs/ folder."
);
println!();
println!(" curl https://tldr.sh/assets/tldr.zip -o docs/tldr.zip");
println!();

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/arch"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/base32"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -11,8 +11,8 @@ use std::io::{self, ErrorKind, Read, Seek, SeekFrom};
use std::path::{Path, PathBuf};
use uucore::display::Quotable;
use uucore::encoding::{
for_base_common::{BASE32, BASE32HEX, BASE64, BASE64URL, BASE64_NOPAD, HEXUPPER_PERMISSIVE},
Format, Z85Wrapper, BASE2LSBF, BASE2MSBF,
BASE2LSBF, BASE2MSBF, Format, Z85Wrapper,
for_base_common::{BASE32, BASE32HEX, BASE64, BASE64_NOPAD, BASE64URL, HEXUPPER_PERMISSIVE},
};
use uucore::encoding::{EncodingWrapper, SupportsFastDecodeAndEncode};
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
@ -291,7 +291,7 @@ pub fn get_supports_fast_decode_and_encode(
}
pub mod fast_encode {
use crate::base_common::{format_read_error, WRAP_DEFAULT};
use crate::base_common::{WRAP_DEFAULT, format_read_error};
use std::{
collections::VecDeque,
io::{self, ErrorKind, Read, Write},

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/base64"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/basename"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -6,7 +6,7 @@
// spell-checker:ignore (ToDO) fullname
use clap::{Arg, ArgAction, Command};
use std::path::{is_separator, PathBuf};
use std::path::{PathBuf, is_separator};
use uucore::display::Quotable;
use uucore::error::{UResult, UUsageError};
use uucore::line_ending::LineEnding;

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/basenc"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -6,7 +6,7 @@
// spell-checker:ignore lsbf msbf
use clap::{Arg, ArgAction, Command};
use uu_base32::base_common::{self, Config, BASE_CMD_PARSE_ERROR};
use uu_base32::base_common::{self, BASE_CMD_PARSE_ERROR, Config};
use uucore::error::UClapError;
use uucore::{
encoding::Format,

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/cat"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -4,7 +4,7 @@
// file that was distributed with this source code.
// spell-checker:ignore (ToDO) nonprint nonblank nonprinting ELOOP
use std::fs::{metadata, File};
use std::fs::{File, metadata};
use std::io::{self, BufWriter, IsTerminal, Read, Write};
/// Unix domain socket support
#[cfg(unix)]
@ -18,7 +18,7 @@ use std::os::unix::net::UnixStream;
use clap::{Arg, ArgAction, Command};
#[cfg(unix)]
use nix::fcntl::{fcntl, FcntlArg};
use nix::fcntl::{FcntlArg, fcntl};
use thiserror::Error;
use uucore::display::Quotable;
use uucore::error::UResult;
@ -83,19 +83,11 @@ struct OutputOptions {
impl OutputOptions {
fn tab(&self) -> &'static str {
if self.show_tabs {
"^I"
} else {
"\t"
}
if self.show_tabs { "^I" } else { "\t" }
}
fn end_of_line(&self) -> &'static str {
if self.show_ends {
"$\n"
} else {
"\n"
}
if self.show_ends { "$\n" } else { "\n" }
}
/// We can write fast if we can simply copy the contents of the file to
@ -694,7 +686,7 @@ fn write_end_of_line<W: Write>(
#[cfg(test)]
mod tests {
use std::io::{stdout, BufWriter};
use std::io::{BufWriter, stdout};
#[test]
fn test_write_nonprint_to_end_new_line() {

View file

@ -8,7 +8,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/chcon"
keywords = ["coreutils", "uutils", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/chgrp"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -8,7 +8,7 @@
use uucore::display::Quotable;
pub use uucore::entries;
use uucore::error::{FromIo, UResult, USimpleError};
use uucore::perms::{chown_base, options, GidUidOwnerFilter, IfFrom};
use uucore::perms::{GidUidOwnerFilter, IfFrom, chown_base, options};
use uucore::{format_usage, help_about, help_usage};
use clap::{Arg, ArgAction, ArgMatches, Command};
@ -76,7 +76,7 @@ fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<GidUidOwnerFilter> {
return Err(USimpleError::new(
1,
format!("invalid user: '{}'", from_group),
))
));
}
}
} else {

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/chmod"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -11,12 +11,12 @@ use std::fs;
use std::os::unix::fs::{MetadataExt, PermissionsExt};
use std::path::Path;
use uucore::display::Quotable;
use uucore::error::{set_exit_code, ExitCode, UResult, USimpleError, UUsageError};
use uucore::error::{ExitCode, UResult, USimpleError, UUsageError, set_exit_code};
use uucore::fs::display_permissions_unix;
use uucore::libc::mode_t;
#[cfg(not(windows))]
use uucore::mode;
use uucore::perms::{configure_symlink_and_recursion, TraverseSymlinks};
use uucore::perms::{TraverseSymlinks, configure_symlink_and_recursion};
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error};
const ABOUT: &str = help_about!("chmod.md");
@ -107,7 +107,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
return Err(USimpleError::new(
1,
format!("cannot stat attributes of {}: {}", fref.quote(), err),
))
));
}
},
None => None,
@ -298,7 +298,7 @@ impl Chmoder {
format!(
"it is dangerous to operate recursively on {}\nchmod: use --no-preserve-root to override this failsafe",
filename.quote()
)
),
));
}
if self.recursive {

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/chown"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -7,7 +7,7 @@
use uucore::display::Quotable;
pub use uucore::entries::{self, Group, Locate, Passwd};
use uucore::perms::{chown_base, options, GidUidOwnerFilter, IfFrom};
use uucore::perms::{GidUidOwnerFilter, IfFrom, chown_base, options};
use uucore::{format_usage, help_about, help_usage};
use uucore::error::{FromIo, UResult, USimpleError};

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/chroot"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -13,9 +13,9 @@ use std::io::Error;
use std::os::unix::prelude::OsStrExt;
use std::path::{Path, PathBuf};
use std::process;
use uucore::entries::{grp2gid, usr2uid, Locate, Passwd};
use uucore::error::{set_exit_code, UClapError, UResult, UUsageError};
use uucore::fs::{canonicalize, MissingHandling, ResolveMode};
use uucore::entries::{Locate, Passwd, grp2gid, usr2uid};
use uucore::error::{UClapError, UResult, UUsageError, set_exit_code};
use uucore::fs::{MissingHandling, ResolveMode, canonicalize};
use uucore::libc::{self, chroot, setgid, setgroups, setuid};
use uucore::{format_usage, help_about, help_usage, show};
@ -224,7 +224,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} else {
ChrootError::CommandFailed(command[0].to_string(), e)
}
.into())
.into());
}
};

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/cksum"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -5,17 +5,17 @@
// spell-checker:ignore (ToDO) fname, algo
use clap::builder::ValueParser;
use clap::{value_parser, Arg, ArgAction, Command};
use clap::{Arg, ArgAction, Command, value_parser};
use std::ffi::{OsStr, OsString};
use std::fs::File;
use std::io::{self, stdin, stdout, BufReader, Read, Write};
use std::io::{self, BufReader, Read, Write, stdin, stdout};
use std::iter;
use std::path::Path;
use uucore::checksum::{
calculate_blake2b_length, detect_algo, digest_reader, perform_checksum_validation,
ChecksumError, ChecksumOptions, ChecksumVerbose, ALGORITHM_OPTIONS_BLAKE2B,
ALGORITHM_OPTIONS_BSD, ALGORITHM_OPTIONS_CRC, ALGORITHM_OPTIONS_CRC32B, ALGORITHM_OPTIONS_SYSV,
SUPPORTED_ALGORITHMS,
ALGORITHM_OPTIONS_BLAKE2B, ALGORITHM_OPTIONS_BSD, ALGORITHM_OPTIONS_CRC,
ALGORITHM_OPTIONS_CRC32B, ALGORITHM_OPTIONS_SYSV, ChecksumError, ChecksumOptions,
ChecksumVerbose, SUPPORTED_ALGORITHMS, calculate_blake2b_length, detect_algo, digest_reader,
perform_checksum_validation,
};
use uucore::{
encoding,

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/comm"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -6,8 +6,8 @@
// spell-checker:ignore (ToDO) delim mkdelim pairable
use std::cmp::Ordering;
use std::fs::{metadata, File};
use std::io::{self, stdin, BufRead, BufReader, Read, Stdin};
use std::fs::{File, metadata};
use std::io::{self, BufRead, BufReader, Read, Stdin, stdin};
use uucore::error::{FromIo, UResult, USimpleError};
use uucore::fs::paths_refer_to_same_file;
use uucore::line_ending::LineEnding;

View file

@ -13,7 +13,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/cp"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -18,7 +18,7 @@ use indicatif::ProgressBar;
use uucore::display::Quotable;
use uucore::error::UIoError;
use uucore::fs::{
canonicalize, path_ends_with_terminator, FileInformation, MissingHandling, ResolveMode,
FileInformation, MissingHandling, ResolveMode, canonicalize, path_ends_with_terminator,
};
use uucore::show;
use uucore::show_error;
@ -26,8 +26,8 @@ use uucore::uio_error;
use walkdir::{DirEntry, WalkDir};
use crate::{
aligned_ancestors, context_for, copy_attributes, copy_file, copy_link, CopyResult, Error,
Options,
CopyResult, Error, Options, aligned_ancestors, context_for, copy_attributes, copy_file,
copy_link,
};
/// Ensure a Windows path starts with a `\\?`.

View file

@ -20,7 +20,7 @@ use std::path::{Path, PathBuf, StripPrefixError};
#[cfg(all(unix, not(target_os = "android")))]
use uucore::fsxattr::copy_xattrs;
use clap::{builder::ValueParser, Arg, ArgAction, ArgMatches, Command};
use clap::{Arg, ArgAction, ArgMatches, Command, builder::ValueParser};
use filetime::FileTime;
use indicatif::{ProgressBar, ProgressStyle};
#[cfg(unix)]
@ -29,11 +29,11 @@ use quick_error::ResultExt;
use platform::copy_on_write;
use uucore::display::Quotable;
use uucore::error::{set_exit_code, UClapError, UError, UResult, UUsageError};
use uucore::error::{UClapError, UError, UResult, UUsageError, set_exit_code};
use uucore::fs::{
are_hardlinks_to_same_file, canonicalize, get_filename, is_symlink_loop, normalize_path,
path_ends_with_terminator, paths_refer_to_same_file, FileInformation, MissingHandling,
ResolveMode,
FileInformation, MissingHandling, ResolveMode, are_hardlinks_to_same_file, canonicalize,
get_filename, is_symlink_loop, normalize_path, path_ends_with_terminator,
paths_refer_to_same_file,
};
use uucore::{backup_control, update_control};
// These are exposed for projects (e.g. nushell) that want to create an `Options` value, which
@ -1498,7 +1498,7 @@ fn file_mode_for_interactive_overwrite(
{
#[cfg(unix)]
{
use libc::{mode_t, S_IWUSR};
use libc::{S_IWUSR, mode_t};
use std::os::unix::prelude::MetadataExt;
match path.metadata() {
@ -1631,9 +1631,9 @@ pub(crate) fn copy_attributes(
#[cfg(unix)]
handle_preserve(&attributes.ownership, || -> CopyResult<()> {
use std::os::unix::prelude::MetadataExt;
use uucore::perms::wrap_chown;
use uucore::perms::Verbosity;
use uucore::perms::VerbosityLevel;
use uucore::perms::wrap_chown;
let dest_uid = source_metadata.uid();
let dest_gid = source_metadata.gid();
@ -2627,7 +2627,7 @@ fn disk_usage_directory(p: &Path) -> io::Result<u64> {
#[cfg(test)]
mod tests {
use crate::{aligned_ancestors, localize_to_target, Attributes, Preserve};
use crate::{Attributes, Preserve, aligned_ancestors, localize_to_target};
use std::path::Path;
#[test]

View file

@ -401,7 +401,7 @@ pub(crate) fn copy_on_write(
clone(source, dest, CloneFallback::Error)
}
(ReflinkMode::Always, _) => {
return Err("`--reflink=always` can be used only with --sparse=auto".into())
return Err("`--reflink=always` can be used only with --sparse=auto".into());
}
};
result.context(context)?;

View file

@ -84,7 +84,7 @@ pub(crate) fn copy_on_write(
// support COW).
match reflink_mode {
ReflinkMode::Always => {
return Err(format!("failed to clone {source:?} from {dest:?}: {error}").into())
return Err(format!("failed to clone {source:?} from {dest:?}: {error}").into());
}
_ => {
copy_debug.reflink = OffloadReflinkDebug::Yes;

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/ls"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -8,7 +8,7 @@
use std::cmp::Ordering;
use std::io::{self, BufReader};
use std::{
fs::{remove_file, File},
fs::{File, remove_file},
io::{BufRead, BufWriter, Write},
};

View file

@ -4,7 +4,7 @@
// file that was distributed with this source code.
// spell-checker:ignore (regex) diuox
use uucore::format::{num_format::UnsignedInt, Format, FormatError};
use uucore::format::{Format, FormatError, num_format::UnsignedInt};
use crate::csplit_error::CsplitError;

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/cut"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -6,13 +6,13 @@
// spell-checker:ignore (ToDO) delim sourcefiles
use bstr::io::BufReadExt;
use clap::{builder::ValueParser, Arg, ArgAction, ArgMatches, Command};
use clap::{Arg, ArgAction, ArgMatches, Command, builder::ValueParser};
use std::ffi::OsString;
use std::fs::File;
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, IsTerminal, Read, Write};
use std::io::{BufRead, BufReader, BufWriter, IsTerminal, Read, Write, stdin, stdout};
use std::path::Path;
use uucore::display::Quotable;
use uucore::error::{set_exit_code, FromIo, UResult, USimpleError};
use uucore::error::{FromIo, UResult, USimpleError, set_exit_code};
use uucore::line_ending::LineEnding;
use uucore::os_str_as_bytes;
@ -355,9 +355,9 @@ fn cut_files(mut filenames: Vec<String>, mode: &Mode) {
}
show_if_err!(match mode {
Mode::Bytes(ref ranges, ref opts) => cut_bytes(stdin(), ranges, opts),
Mode::Characters(ref ranges, ref opts) => cut_bytes(stdin(), ranges, opts),
Mode::Fields(ref ranges, ref opts) => cut_fields(stdin(), ranges, opts),
Mode::Bytes(ranges, opts) => cut_bytes(stdin(), ranges, opts),
Mode::Characters(ranges, opts) => cut_bytes(stdin(), ranges, opts),
Mode::Fields(ranges, opts) => cut_fields(stdin(), ranges, opts),
});
stdin_read = true;
@ -370,7 +370,8 @@ fn cut_files(mut filenames: Vec<String>, mode: &Mode) {
continue;
}
show_if_err!(File::open(path)
show_if_err!(
File::open(path)
.map_err_context(|| filename.maybe_quote().to_string())
.and_then(|file| {
match &mode {
@ -379,7 +380,8 @@ fn cut_files(mut filenames: Vec<String>, mode: &Mode) {
}
Mode::Fields(ranges, opts) => cut_fields(file, ranges, opts),
}
}));
})
);
}
}
}

View file

@ -10,7 +10,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/date"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -11,7 +11,7 @@ use chrono::{DateTime, FixedOffset, Local, Offset, TimeDelta, Utc};
use chrono::{Datelike, Timelike};
use clap::{Arg, ArgAction, Command};
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
use libc::{clock_settime, timespec, CLOCK_REALTIME};
use libc::{CLOCK_REALTIME, clock_settime, timespec};
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::PathBuf;

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/dd"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -22,7 +22,7 @@ use nix::fcntl::FcntlArg::F_SETFL;
use nix::fcntl::OFlag;
use parseargs::Parser;
use progress::ProgUpdateType;
use progress::{gen_prog_updater, ProgUpdate, ReadStat, StatusLevel, WriteStat};
use progress::{ProgUpdate, ReadStat, StatusLevel, WriteStat, gen_prog_updater};
use uucore::io::OwnedFileDescriptorOrHandle;
use std::cmp;
@ -41,7 +41,7 @@ use std::os::unix::{
use std::os::windows::{fs::MetadataExt, io::AsHandle};
use std::path::Path;
use std::sync::atomic::AtomicU8;
use std::sync::{atomic::Ordering::Relaxed, mpsc, Arc};
use std::sync::{Arc, atomic::Ordering::Relaxed, mpsc};
use std::thread;
use std::time::{Duration, Instant};
@ -50,12 +50,12 @@ use gcd::Gcd;
#[cfg(target_os = "linux")]
use nix::{
errno::Errno,
fcntl::{posix_fadvise, PosixFadviseAdvice},
fcntl::{PosixFadviseAdvice, posix_fadvise},
};
use uucore::display::Quotable;
#[cfg(unix)]
use uucore::error::{set_exit_code, USimpleError};
use uucore::error::{FromIo, UResult};
#[cfg(unix)]
use uucore::error::{USimpleError, set_exit_code};
#[cfg(target_os = "linux")]
use uucore::show_if_err;
use uucore::{format_usage, help_about, help_section, help_usage, show_error};
@ -417,11 +417,7 @@ fn make_linux_iflags(iflags: &IFlags) -> Option<libc::c_int> {
flag |= libc::O_SYNC;
}
if flag == 0 {
None
} else {
Some(flag)
}
if flag == 0 { None } else { Some(flag) }
}
impl Read for Input<'_> {
@ -832,10 +828,9 @@ impl<'a> Output<'a> {
fn discard_cache(&self, offset: libc::off_t, len: libc::off_t) {
#[cfg(target_os = "linux")]
{
show_if_err!(self
.dst
.discard_cache(offset, len)
.map_err_context(|| "failed to discard cache for: 'standard output'".to_string()));
show_if_err!(self.dst.discard_cache(offset, len).map_err_context(|| {
"failed to discard cache for: 'standard output'".to_string()
}));
}
#[cfg(target_os = "linux")]
{
@ -1241,11 +1236,7 @@ fn make_linux_oflags(oflags: &OFlags) -> Option<libc::c_int> {
flag |= libc::O_SYNC;
}
if flag == 0 {
None
} else {
Some(flag)
}
if flag == 0 { None } else { Some(flag) }
}
/// Read from an input (that is, a source of bytes) into the given buffer.
@ -1441,7 +1432,7 @@ pub fn uu_app() -> Command {
#[cfg(test)]
mod tests {
use crate::{calc_bsize, Output, Parser};
use crate::{Output, Parser, calc_bsize};
use std::path::Path;

View file

@ -90,7 +90,7 @@ pub(crate) fn to_magnitude_and_suffix(n: u128, suffix_type: SuffixType) -> Strin
#[cfg(test)]
mod tests {
use crate::numbers::{to_magnitude_and_suffix, SuffixType};
use crate::numbers::{SuffixType, to_magnitude_and_suffix};
#[test]
fn test_to_magnitude_and_suffix_powers_of_1024() {

View file

@ -630,8 +630,8 @@ fn conversion_mode(
#[cfg(test)]
mod tests {
use crate::parseargs::{parse_bytes_with_opt_multiplier, Parser};
use crate::Num;
use crate::parseargs::{Parser, parse_bytes_with_opt_multiplier};
use std::matches;
const BIG: &str = "9999999999999999999999999999999999999999999999999999999999999";

View file

@ -6,11 +6,11 @@
use super::*;
use crate::StatusLevel;
use crate::conversion_tables::{
ASCII_TO_EBCDIC_UCASE_TO_LCASE, ASCII_TO_IBM, EBCDIC_TO_ASCII_LCASE_TO_UCASE,
};
use crate::parseargs::Parser;
use crate::StatusLevel;
#[cfg(not(any(target_os = "linux", target_os = "android")))]
#[allow(clippy::useless_vec)]
@ -341,7 +341,9 @@ fn parse_icf_tokens_elu() {
#[test]
fn parse_icf_tokens_remaining() {
let args = &["conv=ascii,ucase,block,sparse,swab,sync,noerror,excl,nocreat,notrunc,noerror,fdatasync,fsync"];
let args = &[
"conv=ascii,ucase,block,sparse,swab,sync,noerror,excl,nocreat,notrunc,noerror,fdatasync,fsync",
];
assert_eq!(
Parser::new().read(args),
Ok(Parser {

View file

@ -22,7 +22,7 @@ use uucore::{
format::num_format::{FloatVariant, Formatter},
};
use crate::numbers::{to_magnitude_and_suffix, SuffixType};
use crate::numbers::{SuffixType, to_magnitude_and_suffix};
#[derive(PartialEq, Eq)]
pub(crate) enum ProgUpdateType {

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/df"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -9,7 +9,7 @@ use std::{env, fmt};
use uucore::{
display::Quotable,
parse_size::{parse_size_u64, ParseSizeError},
parse_size::{ParseSizeError, parse_size_u64},
};
/// The first ten powers of 1024.
@ -216,7 +216,7 @@ mod tests {
use std::env;
use crate::blocks::{to_magnitude_and_suffix, BlockSize, SuffixType};
use crate::blocks::{BlockSize, SuffixType, to_magnitude_and_suffix};
#[test]
fn test_to_magnitude_and_suffix_powers_of_1024() {
@ -294,8 +294,8 @@ mod tests {
#[test]
fn test_default_block_size() {
assert_eq!(BlockSize::Bytes(1024), BlockSize::default());
env::set_var("POSIXLY_CORRECT", "1");
unsafe { env::set_var("POSIXLY_CORRECT", "1") };
assert_eq!(BlockSize::Bytes(512), BlockSize::default());
env::remove_var("POSIXLY_CORRECT");
unsafe { env::remove_var("POSIXLY_CORRECT") };
}
}

View file

@ -4,7 +4,7 @@
// file that was distributed with this source code.
// spell-checker:ignore itotal iused iavail ipcent pcent squashfs
use crate::{OPT_INODES, OPT_OUTPUT, OPT_PRINT_TYPE};
use clap::{parser::ValueSource, ArgMatches};
use clap::{ArgMatches, parser::ValueSource};
/// The columns in the output table produced by `df`.
///

View file

@ -13,18 +13,18 @@ use clap::builder::ValueParser;
use table::HeaderMode;
use uucore::display::Quotable;
use uucore::error::{UError, UResult, USimpleError};
use uucore::fsext::{read_fs_list, MountInfo};
use uucore::fsext::{MountInfo, read_fs_list};
use uucore::parse_size::ParseSizeError;
use uucore::{format_usage, help_about, help_section, help_usage, show};
use clap::{parser::ValueSource, Arg, ArgAction, ArgMatches, Command};
use clap::{Arg, ArgAction, ArgMatches, Command, parser::ValueSource};
use std::error::Error;
use std::ffi::OsString;
use std::fmt;
use std::path::Path;
use crate::blocks::{read_block_size, BlockSize};
use crate::blocks::{BlockSize, read_block_size};
use crate::columns::{Column, ColumnError};
use crate::filesystem::Filesystem;
use crate::filesystem::FsError;
@ -749,7 +749,7 @@ mod tests {
mod is_included {
use crate::{is_included, Options};
use crate::{Options, is_included};
use uucore::fsext::MountInfo;
/// Instantiate a [`MountInfo`] with the given fields.
@ -886,7 +886,7 @@ mod tests {
mod filter_mount_list {
use crate::{filter_mount_list, Options};
use crate::{Options, filter_mount_list};
#[test]
fn test_empty() {

View file

@ -207,7 +207,7 @@ mod tests {
use uucore::fsext::MountInfo;
use crate::filesystem::{mount_info_from_path, FsError};
use crate::filesystem::{FsError, mount_info_from_path};
// Create a fake `MountInfo` with the given directory name.
fn mount_info(mount_dir: &str) -> MountInfo {
@ -312,7 +312,7 @@ mod tests {
#[cfg(not(windows))]
mod over_mount {
use crate::filesystem::{is_over_mounted, Filesystem, FsError};
use crate::filesystem::{Filesystem, FsError, is_over_mounted};
use uucore::fsext::MountInfo;
fn mount_info_with_dev_name(mount_dir: &str, dev_name: Option<&str>) -> MountInfo {

View file

@ -9,7 +9,7 @@
//! collection of data rows ([`Row`]), one per filesystem.
use unicode_width::UnicodeWidthStr;
use crate::blocks::{to_magnitude_and_suffix, SuffixType};
use crate::blocks::{SuffixType, to_magnitude_and_suffix};
use crate::columns::{Alignment, Column};
use crate::filesystem::Filesystem;
use crate::{BlockSize, Options};

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/ls"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -6,7 +6,7 @@
use clap::Command;
use std::ffi::OsString;
use std::path::Path;
use uu_ls::{options, Config, Format};
use uu_ls::{Config, Format, options};
use uucore::error::UResult;
use uucore::quoting_style::{Quotes, QuotingStyle};

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/dircolors"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/dirname"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/du"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -4,7 +4,7 @@
// file that was distributed with this source code.
use chrono::{DateTime, Local};
use clap::{builder::PossibleValue, Arg, ArgAction, ArgMatches, Command};
use clap::{Arg, ArgAction, ArgMatches, Command, builder::PossibleValue};
use glob::Pattern;
use std::collections::HashSet;
use std::env;
@ -24,19 +24,19 @@ use std::sync::mpsc;
use std::thread;
use std::time::{Duration, UNIX_EPOCH};
use thiserror::Error;
use uucore::display::{print_verbatim, Quotable};
use uucore::error::{set_exit_code, FromIo, UError, UResult, USimpleError};
use uucore::display::{Quotable, print_verbatim};
use uucore::error::{FromIo, UError, UResult, USimpleError, set_exit_code};
use uucore::line_ending::LineEnding;
use uucore::parse_glob;
use uucore::parse_size::{parse_size_u64, ParseSizeError};
use uucore::parse_size::{ParseSizeError, parse_size_u64};
use uucore::shortcut_value_parser::ShortcutValueParser;
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error, show_warning};
#[cfg(windows)]
use windows_sys::Win32::Foundation::HANDLE;
#[cfg(windows)]
use windows_sys::Win32::Storage::FileSystem::{
FileIdInfo, FileStandardInfo, GetFileInformationByHandleEx, FILE_ID_128, FILE_ID_INFO,
FILE_STANDARD_INFO,
FILE_ID_128, FILE_ID_INFO, FILE_STANDARD_INFO, FileIdInfo, FileStandardInfo,
GetFileInformationByHandleEx,
};
mod options {
@ -593,7 +593,7 @@ fn read_files_from(file_name: &str) -> Result<Vec<PathBuf>, std::io::Error> {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("cannot open '{file_name}' for reading: No such file or directory"),
))
));
}
Err(e) => return Err(e),
}

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/echo"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -9,7 +9,7 @@ use std::env;
use std::ffi::{OsStr, OsString};
use std::io::{self, StdoutLock, Write};
use uucore::error::{UResult, USimpleError};
use uucore::format::{parse_escape_only, EscapedChar, FormatChar, OctalParsing};
use uucore::format::{EscapedChar, FormatChar, OctalParsing, parse_escape_only};
use uucore::{format_usage, help_about, help_section, help_usage};
const ABOUT: &str = help_about!("echo.md");

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/env"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

17
src/uu/env/src/env.rs vendored
View file

@ -13,14 +13,14 @@ pub mod string_parser;
pub mod variable_parser;
use clap::builder::ValueParser;
use clap::{crate_name, Arg, ArgAction, Command};
use clap::{Arg, ArgAction, Command, crate_name};
use ini::Ini;
use native_int_str::{
from_native_int_representation_owned, Convert, NCvt, NativeIntStr, NativeIntString, NativeStr,
Convert, NCvt, NativeIntStr, NativeIntString, NativeStr, from_native_int_representation_owned,
};
#[cfg(unix)]
use nix::sys::signal::{
raise, sigaction, signal, SaFlags, SigAction, SigHandler, SigHandler::SigIgn, SigSet, Signal,
SaFlags, SigAction, SigHandler, SigHandler::SigIgn, SigSet, Signal, raise, sigaction, signal,
};
use std::borrow::Cow;
use std::env;
@ -163,10 +163,12 @@ fn load_config_file(opts: &mut Options) -> UResult<()> {
for (_, prop) in &conf {
// ignore all INI section lines (treat them as comments)
for (key, value) in prop {
unsafe {
env::set_var(key, value);
}
}
}
}
Ok(())
}
@ -559,10 +561,12 @@ fn apply_removal_of_all_env_vars(opts: &Options<'_>) {
// remove all env vars if told to ignore presets
if opts.ignore_env {
for (ref name, _) in env::vars_os() {
unsafe {
env::remove_var(name);
}
}
}
}
fn make_options(matches: &clap::ArgMatches) -> UResult<Options<'_>> {
let ignore_env = matches.get_flag("ignore-environment");
@ -634,9 +638,10 @@ fn apply_unset_env_vars(opts: &Options<'_>) -> Result<(), Box<dyn UError>> {
format!("cannot unset {}: Invalid argument", name.quote()),
));
}
unsafe {
env::remove_var(name);
}
}
Ok(())
}
@ -692,9 +697,11 @@ fn apply_specified_env_vars(opts: &Options<'_>) {
show_warning!("no name specified for value {}", val.quote());
continue;
}
unsafe {
env::set_var(name, val);
}
}
}
#[cfg(unix)]
fn apply_ignore_signal(opts: &Options<'_>) -> UResult<()> {
@ -736,7 +743,7 @@ mod tests {
#[test]
fn test_split_string_environment_vars_test() {
std::env::set_var("FOO", "BAR");
unsafe { std::env::set_var("FOO", "BAR") };
assert_eq!(
NCvt::convert(vec!["FOO=bar", "sh", "-c", "echo xBARx =$FOO="]),
parse_args_from_str(&NCvt::convert(r#"FOO=bar sh -c "echo x${FOO}x =\$FOO=""#))

View file

@ -19,10 +19,10 @@ use std::os::unix::ffi::{OsStrExt, OsStringExt};
use std::os::windows::prelude::*;
use std::{borrow::Cow, ffi::OsStr};
#[cfg(target_os = "windows")]
use u16 as NativeIntCharU;
#[cfg(not(target_os = "windows"))]
use u8 as NativeIntCharU;
#[cfg(target_os = "windows")]
use u16 as NativeIntCharU;
pub type NativeCharInt = NativeIntCharU;
pub type NativeIntStr = [NativeCharInt];
@ -178,22 +178,14 @@ pub fn get_single_native_int_value(c: &char) -> Option<NativeCharInt> {
{
let mut buf = [0u16, 0];
let s = c.encode_utf16(&mut buf);
if s.len() == 1 {
Some(buf[0])
} else {
None
}
if s.len() == 1 { Some(buf[0]) } else { None }
}
#[cfg(not(target_os = "windows"))]
{
let mut buf = [0u8, 0, 0, 0];
let s = c.encode_utf8(&mut buf);
if s.len() == 1 {
Some(buf[0])
} else {
None
}
if s.len() == 1 { Some(buf[0]) } else { None }
}
}

View file

@ -20,10 +20,10 @@
use std::borrow::Cow;
use crate::native_int_str::from_native_int_representation;
use crate::native_int_str::NativeCharInt;
use crate::native_int_str::NativeIntStr;
use crate::native_int_str::NativeIntString;
use crate::native_int_str::from_native_int_representation;
use crate::parse_error::ParseError;
use crate::string_expander::StringExpander;
use crate::string_parser::StringParser;
@ -256,7 +256,7 @@ impl<'a> SplitIterator<'a> {
return Err(ParseError::MissingClosingQuote {
pos: self.get_parser().get_peek_position(),
c: '\'',
})
});
}
Some(SINGLE_QUOTES) => {
self.skip_one()?;
@ -306,7 +306,7 @@ impl<'a> SplitIterator<'a> {
return Err(ParseError::MissingClosingQuote {
pos: self.get_parser().get_peek_position(),
c: '"',
})
});
}
Some(DOLLAR) => {
self.substitute_variable()?;

View file

@ -10,7 +10,7 @@ use std::{
};
use crate::{
native_int_str::{to_native_int_representation, NativeCharInt, NativeIntStr},
native_int_str::{NativeCharInt, NativeIntStr, to_native_int_representation},
string_parser::{Chunk, Error, StringParser},
};

View file

@ -9,8 +9,8 @@
use std::{borrow::Cow, ffi::OsStr};
use crate::native_int_str::{
from_native_int_representation, get_char_from_native_int, get_single_native_int_value,
NativeCharInt, NativeIntStr,
NativeCharInt, NativeIntStr, from_native_int_representation, get_char_from_native_int,
get_single_native_int_value,
};
#[derive(Clone, Debug, Eq, PartialEq)]

View file

@ -21,7 +21,10 @@ impl<'a> VariableParser<'a, '_> {
if c.is_ascii_digit() {
return Err(ParseError::ParsingOfVariableNameFailed {
pos: self.parser.get_peek_position(),
msg: format!("Unexpected character: '{c}', expected variable name must not start with 0..9") });
msg: format!(
"Unexpected character: '{c}', expected variable name must not start with 0..9"
),
});
}
}
Ok(())
@ -44,8 +47,10 @@ impl<'a> VariableParser<'a, '_> {
match self.get_current_char() {
None => {
return Err(ParseError::ParsingOfVariableNameFailed {
pos: self.parser.get_peek_position(), msg: "Missing closing brace".into() })
},
pos: self.parser.get_peek_position(),
msg: "Missing closing brace".into(),
});
}
Some(c) if !c.is_ascii() || c.is_ascii_alphanumeric() || c == '_' => {
self.skip_one()?;
}
@ -56,32 +61,35 @@ impl<'a> VariableParser<'a, '_> {
None => {
return Err(ParseError::ParsingOfVariableNameFailed {
pos: self.parser.get_peek_position(),
msg: "Missing closing brace after default value".into() })
},
msg: "Missing closing brace after default value".into(),
});
}
Some('}') => {
default_end = Some(self.parser.get_peek_position());
self.skip_one()?;
break
},
break;
}
Some(_) => {
self.skip_one()?;
},
}
}
}
break;
},
}
Some('}') => {
varname_end = self.parser.get_peek_position();
default_end = None;
self.skip_one()?;
break;
},
}
Some(c) => {
return Err(ParseError::ParsingOfVariableNameFailed {
pos: self.parser.get_peek_position(),
msg: format!("Unexpected character: '{c}', expected a closing brace ('}}') or colon (':')")
})
},
msg: format!(
"Unexpected character: '{c}', expected a closing brace ('}}') or colon (':')"
),
});
}
};
}
@ -144,7 +152,7 @@ impl<'a> VariableParser<'a, '_> {
return Err(ParseError::ParsingOfVariableNameFailed {
pos: self.parser.get_peek_position(),
msg: "missing variable name".into(),
})
});
}
Some('{') => {
self.skip_one()?;

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/expand"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -10,13 +10,13 @@ use std::error::Error;
use std::ffi::OsString;
use std::fmt;
use std::fs::File;
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write};
use std::io::{BufRead, BufReader, BufWriter, Read, Write, stdin, stdout};
use std::num::IntErrorKind;
use std::path::Path;
use std::str::from_utf8;
use unicode_width::UnicodeWidthChar;
use uucore::display::Quotable;
use uucore::error::{set_exit_code, FromIo, UError, UResult};
use uucore::error::{FromIo, UError, UResult, set_exit_code};
use uucore::{format_usage, help_about, help_usage, show_error};
const ABOUT: &str = help_about!("expand.md");
@ -496,8 +496,8 @@ fn expand(options: &Options) -> UResult<()> {
mod tests {
use crate::is_digit_or_comma;
use super::next_tabstop;
use super::RemainingMode;
use super::next_tabstop;
#[test]
fn test_next_tabstop_remaining_mode_none() {

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/expr"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -4,7 +4,7 @@
// file that was distributed with this source code.
use clap::{Arg, ArgAction, Command};
use syntax_tree::{is_truthy, AstNode};
use syntax_tree::{AstNode, is_truthy};
use thiserror::Error;
use uucore::{
display::Quotable,

View file

@ -87,11 +87,7 @@ impl RelationOp {
Self::Geq => a >= b,
}
};
if b {
Ok(1.into())
} else {
Ok(0.into())
}
if b { Ok(1.into()) } else { Ok(0.into()) }
}
}
@ -697,8 +693,8 @@ mod test {
use crate::ExprError::InvalidBracketContent;
use super::{
check_posix_regex_errors, get_next_id, AstNode, AstNodeInner, BinOp, NumericOp, RelationOp,
StringOp,
AstNode, AstNodeInner, BinOp, NumericOp, RelationOp, StringOp, check_posix_regex_errors,
get_next_id,
};
impl PartialEq for AstNode {

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -7,13 +7,13 @@
use std::collections::BTreeMap;
use std::io::BufRead;
use std::io::{self, stdin, stdout, Write};
use std::io::{self, Write, stdin, stdout};
use clap::{Arg, ArgAction, Command};
use num_bigint::BigUint;
use num_traits::FromPrimitive;
use uucore::display::Quotable;
use uucore::error::{set_exit_code, FromIo, UResult, USimpleError};
use uucore::error::{FromIo, UResult, USimpleError, set_exit_code};
use uucore::{format_usage, help_about, help_usage, show_error, show_warning};
const ABOUT: &str = help_about!("factor.md");

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/false"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -4,7 +4,7 @@
// file that was distributed with this source code.
use clap::{Arg, ArgAction, Command};
use std::{ffi::OsString, io::Write};
use uucore::error::{set_exit_code, UResult};
use uucore::error::{UResult, set_exit_code};
use uucore::help_about;
const ABOUT: &str = help_about!("false.md");

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/fmt"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -7,7 +7,7 @@
use clap::{Arg, ArgAction, ArgMatches, Command};
use std::fs::File;
use std::io::{stdin, stdout, BufReader, BufWriter, Read, Stdout, Write};
use std::io::{BufReader, BufWriter, Read, Stdout, Write, stdin, stdout};
use uucore::display::Quotable;
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
use uucore::{format_usage, help_about, help_usage};
@ -124,7 +124,10 @@ impl FmtOptions {
}
(None, None) => (DEFAULT_WIDTH, DEFAULT_GOAL),
};
debug_assert!(width >= goal, "GOAL {goal} should not be greater than WIDTH {width} when given {width_opt:?} and {goal_opt:?}.");
debug_assert!(
width >= goal,
"GOAL {goal} should not be greater than WIDTH {width} when given {width_opt:?} and {goal_opt:?}."
);
if width > MAX_WIDTH {
return Err(USimpleError::new(

View file

@ -8,8 +8,8 @@
use std::io::{BufWriter, Stdout, Write};
use std::{cmp, mem};
use crate::parasplit::{ParaWords, Paragraph, WordInfo};
use crate::FmtOptions;
use crate::parasplit::{ParaWords, Paragraph, WordInfo};
struct BreakArgs<'a> {
opts: &'a FmtOptions,
@ -465,11 +465,7 @@ fn restart_active_breaks<'a>(
// Number of spaces to add before a word, based on mode, newline, sentence start.
fn compute_slen(uniform: bool, newline: bool, start: bool, punct: bool) -> usize {
if uniform || newline {
if start || (newline && punct) {
2
} else {
1
}
if start || (newline && punct) { 2 } else { 1 }
} else {
0
}

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/fold"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -7,7 +7,7 @@
use clap::{Arg, ArgAction, Command};
use std::fs::File;
use std::io::{stdin, BufRead, BufReader, Read};
use std::io::{BufRead, BufReader, Read, stdin};
use std::path::Path;
use uucore::display::Quotable;
use uucore::error::{FromIo, UResult, USimpleError};

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/groups"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -8,7 +8,7 @@
use thiserror::Error;
use uucore::{
display::Quotable,
entries::{get_groups_gnu, gid2grp, Locate, Passwd},
entries::{Locate, Passwd, get_groups_gnu, gid2grp},
error::{UError, UResult},
format_usage, help_about, help_usage, show,
};

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/hashsum"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -5,26 +5,26 @@
// spell-checker:ignore (ToDO) algo, algoname, regexes, nread, nonames
use clap::ArgAction;
use clap::builder::ValueParser;
use clap::value_parser;
use clap::ArgAction;
use clap::{Arg, ArgMatches, Command};
use std::ffi::{OsStr, OsString};
use std::fs::File;
use std::io::{stdin, BufReader, Read};
use std::io::{BufReader, Read, stdin};
use std::iter;
use std::num::ParseIntError;
use std::path::Path;
use uucore::checksum::ChecksumError;
use uucore::checksum::ChecksumOptions;
use uucore::checksum::ChecksumVerbose;
use uucore::checksum::HashAlgorithm;
use uucore::checksum::calculate_blake2b_length;
use uucore::checksum::create_sha3;
use uucore::checksum::detect_algo;
use uucore::checksum::digest_reader;
use uucore::checksum::escape_filename;
use uucore::checksum::perform_checksum_validation;
use uucore::checksum::ChecksumError;
use uucore::checksum::ChecksumOptions;
use uucore::checksum::ChecksumVerbose;
use uucore::checksum::HashAlgorithm;
use uucore::error::{FromIo, UResult};
use uucore::sum::{Digest, Sha3_224, Sha3_256, Sha3_384, Sha3_512, Shake128, Shake256};
use uucore::{format_usage, help_about, help_usage};

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/head"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -4,7 +4,7 @@
// file that was distributed with this source code.
use std::ffi::OsString;
use uucore::parse_size::{parse_size_u64, ParseSizeError};
use uucore::parse_size::{ParseSizeError, parse_size_u64};
#[derive(PartialEq, Eq, Debug)]
pub enum ParseError {
@ -14,7 +14,7 @@ pub enum ParseError {
/// Parses obsolete syntax
/// head -NUM\[kmzv\] // spell-checker:disable-line
pub fn parse_obsolete(src: &str) -> Option<Result<impl Iterator<Item = OsString>, ParseError>> {
pub fn parse_obsolete(src: &str) -> Option<Result<Vec<OsString>, ParseError>> {
let mut chars = src.char_indices();
if let Some((_, '-')) = chars.next() {
let mut num_end = 0usize;
@ -44,7 +44,7 @@ fn process_num_block(
src: &str,
last_char: char,
chars: &mut std::str::CharIndices,
) -> Option<Result<impl Iterator<Item = OsString>, ParseError>> {
) -> Option<Result<Vec<OsString>, ParseError>> {
match src.parse::<usize>() {
Ok(num) => {
let mut quiet = false;
@ -99,7 +99,7 @@ fn process_num_block(
options.push(OsString::from("-n"));
options.push(OsString::from(format!("{num}")));
}
Some(Ok(options.into_iter()))
Some(Ok(options))
}
Err(_) => Some(Err(ParseError::Overflow)),
}
@ -140,7 +140,10 @@ mod tests {
let r = parse_obsolete(src);
match r {
Some(s) => match s {
Ok(v) => Some(Ok(v.map(|s| s.to_str().unwrap().to_owned()).collect())),
Ok(v) => Some(Ok(v
.into_iter()
.map(|s| s.to_str().unwrap().to_owned())
.collect())),
Err(e) => Some(Err(e)),
},
None => None,

View file

@ -362,7 +362,7 @@ mod tests {
use std::io::{BufRead, BufReader};
use crate::take::{
copy_all_but_n_bytes, copy_all_but_n_lines, take_lines, TakeAllBuffer, TakeAllLinesBuffer,
TakeAllBuffer, TakeAllLinesBuffer, copy_all_but_n_bytes, copy_all_but_n_lines, take_lines,
};
#[test]

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/hostid"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -13,7 +13,7 @@ const USAGE: &str = help_usage!("hostid.md");
const ABOUT: &str = help_about!("hostid.md");
// currently rust libc interface doesn't include gethostid
extern "C" {
unsafe extern "C" {
pub fn gethostid() -> c_long;
}

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/hostname"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -34,7 +34,7 @@ static OPT_HOST: &str = "host";
mod wsa {
use std::io;
use windows_sys::Win32::Networking::WinSock::{WSACleanup, WSAStartup, WSADATA};
use windows_sys::Win32::Networking::WinSock::{WSACleanup, WSADATA, WSAStartup};
pub(super) struct WsaHandle(());

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/id"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -38,7 +38,7 @@ use std::ffi::CStr;
use uucore::display::Quotable;
use uucore::entries::{self, Group, Locate, Passwd};
use uucore::error::UResult;
use uucore::error::{set_exit_code, USimpleError};
use uucore::error::{USimpleError, set_exit_code};
pub use uucore::libc;
use uucore::libc::{getlogin, uid_t};
use uucore::line_ending::LineEnding;
@ -660,7 +660,7 @@ mod audit {
}
pub type c_auditinfo_addr_t = c_auditinfo_addr;
extern "C" {
unsafe extern "C" {
pub fn getaudit(auditinfo_addr: *mut c_auditinfo_addr_t) -> c_int;
}
}

View file

@ -9,7 +9,7 @@ homepage = "https://github.com/uutils/coreutils"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/install"
keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"]
categories = ["command-line-utilities"]
edition = "2021"
edition = "2024"
readme.workspace = true

View file

@ -9,11 +9,11 @@ mod mode;
use clap::{Arg, ArgAction, ArgMatches, Command};
use file_diff::diff;
use filetime::{set_file_times, FileTime};
use filetime::{FileTime, set_file_times};
use std::fmt::Debug;
use std::fs::File;
use std::fs::{self, metadata};
use std::path::{Path, PathBuf, MAIN_SEPARATOR};
use std::path::{MAIN_SEPARATOR, Path, PathBuf};
use std::process;
use thiserror::Error;
use uucore::backup_control::{self, BackupMode};
@ -23,7 +23,7 @@ use uucore::entries::{grp2gid, usr2uid};
use uucore::error::{FromIo, UError, UResult, UUsageError};
use uucore::fs::dir_strip_dot_for_creation;
use uucore::mode::get_umask;
use uucore::perms::{wrap_chown, Verbosity, VerbosityLevel};
use uucore::perms::{Verbosity, VerbosityLevel, wrap_chown};
use uucore::process::{getegid, geteuid};
use uucore::{format_usage, help_about, help_usage, show, show_error, show_if_err};

Some files were not shown because too many files have changed in this diff Show more