mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge branch 'main' into cp-backup-force
This commit is contained in:
@@ -897,7 +897,7 @@ jobs:
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
- name: Prepare, build and test
|
||||
## spell-checker:ignore (ToDO) sshfs usesh vmactions
|
||||
uses: vmactions/freebsd-vm@v0.2.9
|
||||
uses: vmactions/freebsd-vm@v0.3.0
|
||||
with:
|
||||
usesh: true
|
||||
# sync: sshfs
|
||||
|
||||
@@ -6,8 +6,13 @@ on:
|
||||
types:
|
||||
- completed
|
||||
|
||||
permissions: {}
|
||||
jobs:
|
||||
post-comment:
|
||||
permissions:
|
||||
actions: read # to list workflow runs artifacts
|
||||
pull-requests: write # to comment on pr
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
if: >
|
||||
github.event.workflow_run.event == 'pull_request'
|
||||
|
||||
Generated
+28
-18
@@ -100,9 +100,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "binary-heap-plus"
|
||||
version = "0.4.1"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f068638f8ff9e118a9361e66a411eff410e7fb3ecaa23bf9272324f8fc606d7"
|
||||
checksum = "e4551d8382e911ecc0d0f0ffb602777988669be09447d536ff4388d1def11296"
|
||||
dependencies = [
|
||||
"compare",
|
||||
]
|
||||
@@ -190,10 +190,11 @@ checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d"
|
||||
|
||||
[[package]]
|
||||
name = "byte-unit"
|
||||
version = "4.0.14"
|
||||
version = "4.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95ebf10dda65f19ff0f42ea15572a359ed60d7fc74fdc984d90310937be0014b"
|
||||
checksum = "581ad4b3d627b0c09a0ccb2912148f839acaca0b93cf54cbe42b6c674e86079c"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"utf8-width",
|
||||
]
|
||||
|
||||
@@ -285,9 +286,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_complete"
|
||||
version = "4.0.2"
|
||||
version = "4.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11cba7abac9b56dfe2f035098cdb3a43946f276e6db83b72c4e692343f9aab9a"
|
||||
checksum = "dfe581a2035db4174cdbdc91265e1aba50f381577f0510d0ad36c7bc59cc84a3"
|
||||
dependencies = [
|
||||
"clap 4.0.18",
|
||||
]
|
||||
@@ -1145,9 +1146,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.135"
|
||||
version = "0.2.137"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c"
|
||||
checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
@@ -1342,9 +1343,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.13.1"
|
||||
version = "1.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
|
||||
checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
@@ -2076,21 +2077,32 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.15"
|
||||
version = "0.3.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d634a985c4d4238ec39cacaed2e7ae552fbd3c476b552c1deac3021b7d7eaf0c"
|
||||
checksum = "0fab5c8b9980850e06d92ddbe3ab839c062c801f3927c0fb8abd6fc8e918fbca"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"libc",
|
||||
"num_threads",
|
||||
"serde",
|
||||
"time-core",
|
||||
"time-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time-macros"
|
||||
version = "0.2.4"
|
||||
name = "time-core"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792"
|
||||
checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd"
|
||||
|
||||
[[package]]
|
||||
name = "time-macros"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65bb801831d812c562ae7d2bfb531f26e66e4e1f6b17307ba4149c5064710e5b"
|
||||
dependencies = [
|
||||
"time-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
@@ -2347,7 +2359,6 @@ name = "uu_dir"
|
||||
version = "0.0.16"
|
||||
dependencies = [
|
||||
"clap 4.0.18",
|
||||
"selinux",
|
||||
"uu_ls",
|
||||
"uucore",
|
||||
]
|
||||
@@ -2357,7 +2368,6 @@ name = "uu_dircolors"
|
||||
version = "0.0.16"
|
||||
dependencies = [
|
||||
"clap 4.0.18",
|
||||
"glob",
|
||||
"uucore",
|
||||
]
|
||||
|
||||
@@ -2807,6 +2817,7 @@ name = "uu_rm"
|
||||
version = "0.0.16"
|
||||
dependencies = [
|
||||
"clap 4.0.18",
|
||||
"libc",
|
||||
"remove_dir_all 0.7.0",
|
||||
"uucore",
|
||||
"walkdir",
|
||||
@@ -3124,7 +3135,6 @@ name = "uu_vdir"
|
||||
version = "0.0.16"
|
||||
dependencies = [
|
||||
"clap 4.0.18",
|
||||
"selinux",
|
||||
"uu_ls",
|
||||
"uucore",
|
||||
]
|
||||
|
||||
@@ -100,7 +100,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
}
|
||||
|
||||
CommandLineMode::ContextBased { context } => {
|
||||
let c_context = match os_str_to_c_string(&context) {
|
||||
let c_context = match os_str_to_c_string(context) {
|
||||
Ok(context) => context,
|
||||
|
||||
Err(_r) => {
|
||||
@@ -198,7 +198,7 @@ pub fn uu_app() -> Command {
|
||||
.long(options::REFERENCE)
|
||||
.value_name("RFILE")
|
||||
.value_hint(clap::ValueHint::FilePath)
|
||||
.conflicts_with_all(&[options::USER, options::ROLE, options::TYPE, options::RANGE])
|
||||
.conflicts_with_all([options::USER, options::ROLE, options::TYPE, options::RANGE])
|
||||
.help(
|
||||
"Use security context of RFILE, rather than specifying \
|
||||
a CONTEXT value.",
|
||||
@@ -249,7 +249,7 @@ pub fn uu_app() -> Command {
|
||||
Arg::new(options::sym_links::FOLLOW_ARG_DIR_SYM_LINK)
|
||||
.short('H')
|
||||
.requires(options::RECURSIVE)
|
||||
.overrides_with_all(&[
|
||||
.overrides_with_all([
|
||||
options::sym_links::FOLLOW_DIR_SYM_LINKS,
|
||||
options::sym_links::NO_FOLLOW_SYM_LINKS,
|
||||
])
|
||||
@@ -263,7 +263,7 @@ pub fn uu_app() -> Command {
|
||||
Arg::new(options::sym_links::FOLLOW_DIR_SYM_LINKS)
|
||||
.short('L')
|
||||
.requires(options::RECURSIVE)
|
||||
.overrides_with_all(&[
|
||||
.overrides_with_all([
|
||||
options::sym_links::FOLLOW_ARG_DIR_SYM_LINK,
|
||||
options::sym_links::NO_FOLLOW_SYM_LINKS,
|
||||
])
|
||||
@@ -277,7 +277,7 @@ pub fn uu_app() -> Command {
|
||||
Arg::new(options::sym_links::NO_FOLLOW_SYM_LINKS)
|
||||
.short('P')
|
||||
.requires(options::RECURSIVE)
|
||||
.overrides_with_all(&[
|
||||
.overrides_with_all([
|
||||
options::sym_links::FOLLOW_ARG_DIR_SYM_LINK,
|
||||
options::sym_links::FOLLOW_DIR_SYM_LINKS,
|
||||
])
|
||||
|
||||
@@ -146,7 +146,7 @@ pub fn uu_app() -> Command {
|
||||
Arg::new(options::traverse::NO_TRAVERSE)
|
||||
.short(options::traverse::NO_TRAVERSE.chars().next().unwrap())
|
||||
.help("do not traverse any symbolic links (default)")
|
||||
.overrides_with_all(&[options::traverse::TRAVERSE, options::traverse::EVERY])
|
||||
.overrides_with_all([options::traverse::TRAVERSE, options::traverse::EVERY])
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
|
||||
@@ -16,7 +16,7 @@ path = "src/chmod.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.0", features = ["wrap_help", "cargo"] }
|
||||
libc = "0.2.135"
|
||||
libc = "0.2.137"
|
||||
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["fs", "mode"] }
|
||||
|
||||
[[bin]]
|
||||
|
||||
@@ -156,21 +156,21 @@ pub fn uu_app() -> Command {
|
||||
Arg::new(options::traverse::TRAVERSE)
|
||||
.short(options::traverse::TRAVERSE.chars().next().unwrap())
|
||||
.help("if a command line argument is a symbolic link to a directory, traverse it")
|
||||
.overrides_with_all(&[options::traverse::EVERY, options::traverse::NO_TRAVERSE])
|
||||
.overrides_with_all([options::traverse::EVERY, options::traverse::NO_TRAVERSE])
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::traverse::EVERY)
|
||||
.short(options::traverse::EVERY.chars().next().unwrap())
|
||||
.help("traverse every symbolic link to a directory encountered")
|
||||
.overrides_with_all(&[options::traverse::TRAVERSE, options::traverse::NO_TRAVERSE])
|
||||
.overrides_with_all([options::traverse::TRAVERSE, options::traverse::NO_TRAVERSE])
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::traverse::NO_TRAVERSE)
|
||||
.short(options::traverse::NO_TRAVERSE.chars().next().unwrap())
|
||||
.help("do not traverse any symbolic links (default)")
|
||||
.overrides_with_all(&[options::traverse::TRAVERSE, options::traverse::EVERY])
|
||||
.overrides_with_all([options::traverse::TRAVERSE, options::traverse::EVERY])
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
@@ -246,6 +246,19 @@ fn parse_spec(spec: &str, sep: char) -> UResult<(Option<u32>, Option<u32>)> {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
if user.chars().next().map(char::is_numeric).unwrap_or(false)
|
||||
&& group.is_empty()
|
||||
&& spec != user
|
||||
{
|
||||
// if the arg starts with an id numeric value, the group isn't set but the separator is provided,
|
||||
// we should fail with an error
|
||||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!("invalid spec: {}", spec.quote()),
|
||||
));
|
||||
}
|
||||
|
||||
Ok((uid, gid))
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ path = "src/cp.rs"
|
||||
[dependencies]
|
||||
clap = { version = "4.0", features = ["wrap_help", "cargo"] }
|
||||
filetime = "0.2"
|
||||
libc = "0.2.135"
|
||||
libc = "0.2.137"
|
||||
quick-error = "2.0.1"
|
||||
selinux = { version="0.3", optional=true }
|
||||
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["entries", "fs", "perms", "mode"] }
|
||||
|
||||
@@ -66,7 +66,7 @@ fn get_local_to_root_parent(
|
||||
adjust_canonicalization(path),
|
||||
adjust_canonicalization(parent),
|
||||
);
|
||||
let path = path.strip_prefix(&parent)?;
|
||||
let path = path.strip_prefix(parent)?;
|
||||
Ok(path.to_path_buf())
|
||||
}
|
||||
None => Ok(path.to_path_buf()),
|
||||
|
||||
+22
-9
@@ -427,7 +427,7 @@ pub fn uu_app() -> Command {
|
||||
))
|
||||
.num_args(0..)
|
||||
.value_name("ATTR_LIST")
|
||||
.overrides_with_all(&[
|
||||
.overrides_with_all([
|
||||
options::ARCHIVE,
|
||||
options::PRESERVE_DEFAULT_ATTRIBUTES,
|
||||
options::NO_PRESERVE,
|
||||
@@ -443,7 +443,7 @@ pub fn uu_app() -> Command {
|
||||
Arg::new(options::PRESERVE_DEFAULT_ATTRIBUTES)
|
||||
.short('p')
|
||||
.long(options::PRESERVE_DEFAULT_ATTRIBUTES)
|
||||
.overrides_with_all(&[options::PRESERVE, options::NO_PRESERVE, options::ARCHIVE])
|
||||
.overrides_with_all([options::PRESERVE, options::NO_PRESERVE, options::ARCHIVE])
|
||||
.help("same as --preserve=mode,ownership(unix only),timestamps")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
@@ -451,7 +451,7 @@ pub fn uu_app() -> Command {
|
||||
Arg::new(options::NO_PRESERVE)
|
||||
.long(options::NO_PRESERVE)
|
||||
.value_name("ATTR_LIST")
|
||||
.overrides_with_all(&[
|
||||
.overrides_with_all([
|
||||
options::PRESERVE_DEFAULT_ATTRIBUTES,
|
||||
options::PRESERVE,
|
||||
options::ARCHIVE,
|
||||
@@ -492,7 +492,7 @@ pub fn uu_app() -> Command {
|
||||
Arg::new(options::ARCHIVE)
|
||||
.short('a')
|
||||
.long(options::ARCHIVE)
|
||||
.overrides_with_all(&[
|
||||
.overrides_with_all([
|
||||
options::PRESERVE_DEFAULT_ATTRIBUTES,
|
||||
options::PRESERVE,
|
||||
options::NO_PRESERVE,
|
||||
@@ -677,7 +677,6 @@ fn add_all_attributes() -> Vec<Attribute> {
|
||||
impl Options {
|
||||
fn from_matches(matches: &ArgMatches) -> CopyResult<Self> {
|
||||
let not_implemented_opts = vec![
|
||||
options::COPY_CONTENTS,
|
||||
#[cfg(not(any(windows, unix)))]
|
||||
options::ONE_FILE_SYSTEM,
|
||||
options::CONTEXT,
|
||||
@@ -1289,8 +1288,10 @@ fn copy_file(
|
||||
symlinked_files: &mut HashSet<FileInformation>,
|
||||
source_in_command_line: bool,
|
||||
) -> CopyResult<()> {
|
||||
if file_or_link_exists(dest) {
|
||||
handle_existing_dest(source, dest, options, source_in_command_line)?;
|
||||
if options.update && options.overwrite == OverwriteMode::Interactive(ClobberMode::Standard) {
|
||||
// `cp -i --update old new` when `new` exists doesn't copy anything
|
||||
// and exit with 0
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Fail if dest is a dangling symlink or a symlink this program created previously
|
||||
@@ -1306,7 +1307,13 @@ fn copy_file(
|
||||
)));
|
||||
}
|
||||
let copy_contents = options.dereference(source_in_command_line) || !source.is_symlink();
|
||||
if copy_contents && !dest.exists() {
|
||||
if copy_contents
|
||||
&& !dest.exists()
|
||||
&& !matches!(
|
||||
options.overwrite,
|
||||
OverwriteMode::Clobber(ClobberMode::RemoveDestination)
|
||||
)
|
||||
{
|
||||
return Err(Error::Error(format!(
|
||||
"not writing through dangling symlink '{}'",
|
||||
dest.display()
|
||||
@@ -1314,6 +1321,10 @@ fn copy_file(
|
||||
}
|
||||
}
|
||||
|
||||
if file_or_link_exists(dest) {
|
||||
handle_existing_dest(source, dest, options, source_in_command_line)?;
|
||||
}
|
||||
|
||||
if options.verbose {
|
||||
println!("{}", context_for(source, dest));
|
||||
}
|
||||
@@ -1470,7 +1481,7 @@ fn copy_helper(
|
||||
* https://github.com/rust-lang/rust/issues/79390
|
||||
*/
|
||||
File::create(dest).context(dest.display().to_string())?;
|
||||
} else if source_is_fifo && options.recursive {
|
||||
} else if source_is_fifo && options.recursive && !options.copy_contents {
|
||||
#[cfg(unix)]
|
||||
copy_fifo(dest, options.overwrite)?;
|
||||
} else if source_is_symlink {
|
||||
@@ -1482,6 +1493,8 @@ fn copy_helper(
|
||||
options.reflink_mode,
|
||||
options.sparse_mode,
|
||||
context,
|
||||
#[cfg(any(target_os = "linux", target_os = "android", target_os = "macos"))]
|
||||
source_is_fifo,
|
||||
)?;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,29 +21,39 @@ macro_rules! FICLONE {
|
||||
};
|
||||
}
|
||||
|
||||
/// The fallback behavior for [`clone`] on failed system call.
|
||||
#[derive(Clone, Copy)]
|
||||
enum CloneFallback {
|
||||
/// Raise an error.
|
||||
Error,
|
||||
|
||||
/// Use [`std::io::copy`].
|
||||
IOCopy,
|
||||
|
||||
/// Use [`std::fs::copy`].
|
||||
FSCopy,
|
||||
}
|
||||
|
||||
/// Use the Linux `ioctl_ficlone` API to do a copy-on-write clone.
|
||||
///
|
||||
/// If `fallback` is true and there is a failure performing the clone,
|
||||
/// then this function performs a standard [`std::fs::copy`]. Otherwise,
|
||||
/// this function returns an error.
|
||||
/// `fallback` controls what to do if the system call fails.
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn clone<P>(source: P, dest: P, fallback: bool) -> std::io::Result<()>
|
||||
fn clone<P>(source: P, dest: P, fallback: CloneFallback) -> std::io::Result<()>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
let src_file = File::open(&source)?;
|
||||
let dst_file = File::create(&dest)?;
|
||||
let mut src_file = File::open(&source)?;
|
||||
let mut dst_file = File::create(&dest)?;
|
||||
let src_fd = src_file.as_raw_fd();
|
||||
let dst_fd = dst_file.as_raw_fd();
|
||||
let result = unsafe { libc::ioctl(dst_fd, FICLONE!(), src_fd) };
|
||||
if result != 0 {
|
||||
if fallback {
|
||||
std::fs::copy(source, dest).map(|_| ())
|
||||
} else {
|
||||
Err(std::io::Error::last_os_error())
|
||||
}
|
||||
} else {
|
||||
Ok(())
|
||||
if result == 0 {
|
||||
return Ok(());
|
||||
}
|
||||
match fallback {
|
||||
CloneFallback::Error => Err(std::io::Error::last_os_error()),
|
||||
CloneFallback::IOCopy => std::io::copy(&mut src_file, &mut dst_file).map(|_| ()),
|
||||
CloneFallback::FSCopy => std::fs::copy(source, dest).map(|_| ()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,18 +99,31 @@ where
|
||||
}
|
||||
|
||||
/// Copies `source` to `dest` using copy-on-write if possible.
|
||||
///
|
||||
/// The `source_is_fifo` flag must be set to `true` if and only if
|
||||
/// `source` is a FIFO (also known as a named pipe). In this case,
|
||||
/// copy-on-write is not possible, so we copy the contents using
|
||||
/// [`std::io::copy`].
|
||||
pub(crate) fn copy_on_write(
|
||||
source: &Path,
|
||||
dest: &Path,
|
||||
reflink_mode: ReflinkMode,
|
||||
sparse_mode: SparseMode,
|
||||
context: &str,
|
||||
source_is_fifo: bool,
|
||||
) -> CopyResult<()> {
|
||||
let result = match (reflink_mode, sparse_mode) {
|
||||
(ReflinkMode::Never, _) => std::fs::copy(source, dest).map(|_| ()),
|
||||
(ReflinkMode::Auto, SparseMode::Always) => sparse_copy(source, dest),
|
||||
(ReflinkMode::Auto, _) => clone(source, dest, true),
|
||||
(ReflinkMode::Always, SparseMode::Auto) => clone(source, dest, false),
|
||||
|
||||
(ReflinkMode::Auto, _) => {
|
||||
if source_is_fifo {
|
||||
clone(source, dest, CloneFallback::IOCopy)
|
||||
} else {
|
||||
clone(source, dest, CloneFallback::FSCopy)
|
||||
}
|
||||
}
|
||||
(ReflinkMode::Always, SparseMode::Auto) => clone(source, dest, CloneFallback::Error),
|
||||
(ReflinkMode::Always, _) => {
|
||||
return Err("`--reflink=always` can be used only with --sparse=auto".into())
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
// * file that was distributed with this source code.
|
||||
// spell-checker:ignore reflink
|
||||
use std::ffi::CString;
|
||||
use std::fs;
|
||||
use std::fs::{self, File};
|
||||
use std::io;
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -13,12 +14,16 @@ use quick_error::ResultExt;
|
||||
use crate::{CopyResult, ReflinkMode, SparseMode};
|
||||
|
||||
/// Copies `source` to `dest` using copy-on-write if possible.
|
||||
///
|
||||
/// The `source_is_fifo` flag must be set to `true` if and only if
|
||||
/// `source` is a FIFO (also known as a named pipe).
|
||||
pub(crate) fn copy_on_write(
|
||||
source: &Path,
|
||||
dest: &Path,
|
||||
reflink_mode: ReflinkMode,
|
||||
sparse_mode: SparseMode,
|
||||
context: &str,
|
||||
source_is_fifo: bool,
|
||||
) -> CopyResult<()> {
|
||||
if sparse_mode != SparseMode::Auto {
|
||||
return Err("--sparse is only supported on linux".to_string().into());
|
||||
@@ -65,8 +70,15 @@ pub(crate) fn copy_on_write(
|
||||
format!("failed to clone {:?} from {:?}: {}", source, dest, error).into(),
|
||||
)
|
||||
}
|
||||
ReflinkMode::Auto => fs::copy(source, dest).context(context)?,
|
||||
ReflinkMode::Never => fs::copy(source, dest).context(context)?,
|
||||
_ => {
|
||||
if source_is_fifo {
|
||||
let mut src_file = File::open(source)?;
|
||||
let mut dst_file = File::create(dest)?;
|
||||
io::copy(&mut src_file, &mut dst_file).context(context)?
|
||||
} else {
|
||||
fs::copy(source, dest).context(context)?
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ fn unimplemented_flags_should_error() {
|
||||
fn test_status_level_absent() {
|
||||
let args = &["if=foo.file", "of=bar.file"];
|
||||
|
||||
assert_eq!(Parser::new().parse(args).unwrap().status, None)
|
||||
assert_eq!(Parser::new().parse(args).unwrap().status, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -96,7 +96,7 @@ fn test_status_level_none() {
|
||||
assert_eq!(
|
||||
Parser::new().parse(args).unwrap().status,
|
||||
Some(StatusLevel::None)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+9
-9
@@ -509,7 +509,7 @@ pub fn uu_app() -> Command {
|
||||
.short('B')
|
||||
.long("block-size")
|
||||
.value_name("SIZE")
|
||||
.overrides_with_all(&[OPT_KILO, OPT_BLOCKSIZE])
|
||||
.overrides_with_all([OPT_KILO, OPT_BLOCKSIZE])
|
||||
.help(
|
||||
"scale sizes by SIZE before printing them; e.g.\
|
||||
'-BM' prints sizes in units of 1,048,576 bytes",
|
||||
@@ -526,7 +526,7 @@ pub fn uu_app() -> Command {
|
||||
Arg::new(OPT_HUMAN_READABLE_BINARY)
|
||||
.short('h')
|
||||
.long("human-readable")
|
||||
.overrides_with_all(&[OPT_HUMAN_READABLE_DECIMAL, OPT_HUMAN_READABLE_BINARY])
|
||||
.overrides_with_all([OPT_HUMAN_READABLE_DECIMAL, OPT_HUMAN_READABLE_BINARY])
|
||||
.help("print sizes in human readable format (e.g., 1K 234M 2G)")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
@@ -534,7 +534,7 @@ pub fn uu_app() -> Command {
|
||||
Arg::new(OPT_HUMAN_READABLE_DECIMAL)
|
||||
.short('H')
|
||||
.long("si")
|
||||
.overrides_with_all(&[OPT_HUMAN_READABLE_BINARY, OPT_HUMAN_READABLE_DECIMAL])
|
||||
.overrides_with_all([OPT_HUMAN_READABLE_BINARY, OPT_HUMAN_READABLE_DECIMAL])
|
||||
.help("likewise, but use powers of 1000 not 1024")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
@@ -550,7 +550,7 @@ pub fn uu_app() -> Command {
|
||||
Arg::new(OPT_KILO)
|
||||
.short('k')
|
||||
.help("like --block-size=1K")
|
||||
.overrides_with_all(&[OPT_BLOCKSIZE, OPT_KILO])
|
||||
.overrides_with_all([OPT_BLOCKSIZE, OPT_KILO])
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
@@ -564,7 +564,7 @@ pub fn uu_app() -> Command {
|
||||
.arg(
|
||||
Arg::new(OPT_NO_SYNC)
|
||||
.long("no-sync")
|
||||
.overrides_with_all(&[OPT_SYNC, OPT_NO_SYNC])
|
||||
.overrides_with_all([OPT_SYNC, OPT_NO_SYNC])
|
||||
.help("do not invoke sync before getting usage info (default)")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
@@ -577,9 +577,9 @@ pub fn uu_app() -> Command {
|
||||
.require_equals(true)
|
||||
.use_value_delimiter(true)
|
||||
.value_parser(OUTPUT_FIELD_LIST)
|
||||
.default_missing_values(&OUTPUT_FIELD_LIST)
|
||||
.default_values(&["source", "size", "used", "avail", "pcent", "target"])
|
||||
.conflicts_with_all(&[OPT_INODES, OPT_PORTABILITY, OPT_PRINT_TYPE])
|
||||
.default_missing_values(OUTPUT_FIELD_LIST)
|
||||
.default_values(["source", "size", "used", "avail", "pcent", "target"])
|
||||
.conflicts_with_all([OPT_INODES, OPT_PORTABILITY, OPT_PRINT_TYPE])
|
||||
.help(
|
||||
"use the output format defined by FIELD_LIST, \
|
||||
or print all fields if FIELD_LIST is omitted.",
|
||||
@@ -596,7 +596,7 @@ pub fn uu_app() -> Command {
|
||||
.arg(
|
||||
Arg::new(OPT_SYNC)
|
||||
.long("sync")
|
||||
.overrides_with_all(&[OPT_NO_SYNC, OPT_SYNC])
|
||||
.overrides_with_all([OPT_NO_SYNC, OPT_SYNC])
|
||||
.help("invoke sync before getting usage info (non-windows only)")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
|
||||
@@ -17,7 +17,6 @@ path = "src/dir.rs"
|
||||
[dependencies]
|
||||
clap = { version = "4.0", features = ["wrap_help", "cargo", "env"] }
|
||||
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["entries", "fs"] }
|
||||
selinux = { version = "0.3", optional = true }
|
||||
uu_ls = { version = ">=0.0.16", path="../ls"}
|
||||
|
||||
[[bin]]
|
||||
|
||||
@@ -16,7 +16,6 @@ path = "src/dircolors.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.0", features = ["wrap_help", "cargo"] }
|
||||
glob = "0.3.0"
|
||||
uucore = { version=">=0.0.16", package="uucore", path="../../uucore" }
|
||||
|
||||
[[bin]]
|
||||
|
||||
@@ -64,6 +64,9 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result<bool> {
|
||||
|
||||
let mut buffer = ['\\'; 2];
|
||||
|
||||
// TODO `cargo +nightly clippy` complains that `.peek()` is never
|
||||
// called on `iter`. However, `peek()` is called inside the
|
||||
// `parse_code()` function that borrows `iter`.
|
||||
let mut iter = input.chars().peekable();
|
||||
while let Some(mut c) = iter.next() {
|
||||
let mut start = 1;
|
||||
|
||||
@@ -278,8 +278,8 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
|
||||
let tag = matches.get_flag("tag");
|
||||
let nonames = *matches
|
||||
.try_get_one("no-names")
|
||||
.unwrap_or(Some(&false))
|
||||
.unwrap();
|
||||
.unwrap_or(None)
|
||||
.unwrap_or(&false);
|
||||
let status = matches.get_flag("status");
|
||||
let quiet = matches.get_flag("quiet") || status;
|
||||
let strict = matches.get_flag("strict");
|
||||
|
||||
@@ -59,7 +59,7 @@ pub fn uu_app() -> Command {
|
||||
NUM bytes of each file\
|
||||
",
|
||||
)
|
||||
.overrides_with_all(&[options::BYTES_NAME, options::LINES_NAME])
|
||||
.overrides_with_all([options::BYTES_NAME, options::LINES_NAME])
|
||||
.allow_hyphen_values(true),
|
||||
)
|
||||
.arg(
|
||||
@@ -74,7 +74,7 @@ pub fn uu_app() -> Command {
|
||||
NUM lines of each file\
|
||||
",
|
||||
)
|
||||
.overrides_with_all(&[options::LINES_NAME, options::BYTES_NAME])
|
||||
.overrides_with_all([options::LINES_NAME, options::BYTES_NAME])
|
||||
.allow_hyphen_values(true),
|
||||
)
|
||||
.arg(
|
||||
@@ -83,7 +83,7 @@ pub fn uu_app() -> Command {
|
||||
.long("quiet")
|
||||
.visible_alias("silent")
|
||||
.help("never print headers giving file names")
|
||||
.overrides_with_all(&[options::VERBOSE_NAME, options::QUIET_NAME])
|
||||
.overrides_with_all([options::VERBOSE_NAME, options::QUIET_NAME])
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
@@ -91,7 +91,7 @@ pub fn uu_app() -> Command {
|
||||
.short('v')
|
||||
.long("verbose")
|
||||
.help("always print headers giving file names")
|
||||
.overrides_with_all(&[options::QUIET_NAME, options::VERBOSE_NAME])
|
||||
.overrides_with_all([options::QUIET_NAME, options::VERBOSE_NAME])
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
|
||||
@@ -16,7 +16,7 @@ path = "src/hostid.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.0", features = ["wrap_help", "cargo"] }
|
||||
libc = "0.2.135"
|
||||
libc = "0.2.137"
|
||||
uucore = { version=">=0.0.16", package="uucore", path="../../uucore" }
|
||||
|
||||
[[bin]]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user