mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 23:32:39 +00:00
Merge branch 'main' into rm-correct-prompts
This commit is contained in:
commit
0079f73568
25 changed files with 138 additions and 92 deletions
|
@ -100,7 +100,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandLineMode::ContextBased { context } => {
|
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,
|
Ok(context) => context,
|
||||||
|
|
||||||
Err(_r) => {
|
Err(_r) => {
|
||||||
|
@ -198,7 +198,7 @@ pub fn uu_app() -> Command {
|
||||||
.long(options::REFERENCE)
|
.long(options::REFERENCE)
|
||||||
.value_name("RFILE")
|
.value_name("RFILE")
|
||||||
.value_hint(clap::ValueHint::FilePath)
|
.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(
|
.help(
|
||||||
"Use security context of RFILE, rather than specifying \
|
"Use security context of RFILE, rather than specifying \
|
||||||
a CONTEXT value.",
|
a CONTEXT value.",
|
||||||
|
@ -249,7 +249,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::sym_links::FOLLOW_ARG_DIR_SYM_LINK)
|
Arg::new(options::sym_links::FOLLOW_ARG_DIR_SYM_LINK)
|
||||||
.short('H')
|
.short('H')
|
||||||
.requires(options::RECURSIVE)
|
.requires(options::RECURSIVE)
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::sym_links::FOLLOW_DIR_SYM_LINKS,
|
options::sym_links::FOLLOW_DIR_SYM_LINKS,
|
||||||
options::sym_links::NO_FOLLOW_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)
|
Arg::new(options::sym_links::FOLLOW_DIR_SYM_LINKS)
|
||||||
.short('L')
|
.short('L')
|
||||||
.requires(options::RECURSIVE)
|
.requires(options::RECURSIVE)
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::sym_links::FOLLOW_ARG_DIR_SYM_LINK,
|
options::sym_links::FOLLOW_ARG_DIR_SYM_LINK,
|
||||||
options::sym_links::NO_FOLLOW_SYM_LINKS,
|
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)
|
Arg::new(options::sym_links::NO_FOLLOW_SYM_LINKS)
|
||||||
.short('P')
|
.short('P')
|
||||||
.requires(options::RECURSIVE)
|
.requires(options::RECURSIVE)
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::sym_links::FOLLOW_ARG_DIR_SYM_LINK,
|
options::sym_links::FOLLOW_ARG_DIR_SYM_LINK,
|
||||||
options::sym_links::FOLLOW_DIR_SYM_LINKS,
|
options::sym_links::FOLLOW_DIR_SYM_LINKS,
|
||||||
])
|
])
|
||||||
|
|
|
@ -146,7 +146,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::traverse::NO_TRAVERSE)
|
Arg::new(options::traverse::NO_TRAVERSE)
|
||||||
.short(options::traverse::NO_TRAVERSE.chars().next().unwrap())
|
.short(options::traverse::NO_TRAVERSE.chars().next().unwrap())
|
||||||
.help("do not traverse any symbolic links (default)")
|
.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),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -156,21 +156,21 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::traverse::TRAVERSE)
|
Arg::new(options::traverse::TRAVERSE)
|
||||||
.short(options::traverse::TRAVERSE.chars().next().unwrap())
|
.short(options::traverse::TRAVERSE.chars().next().unwrap())
|
||||||
.help("if a command line argument is a symbolic link to a directory, traverse it")
|
.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),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::traverse::EVERY)
|
Arg::new(options::traverse::EVERY)
|
||||||
.short(options::traverse::EVERY.chars().next().unwrap())
|
.short(options::traverse::EVERY.chars().next().unwrap())
|
||||||
.help("traverse every symbolic link to a directory encountered")
|
.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),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::traverse::NO_TRAVERSE)
|
Arg::new(options::traverse::NO_TRAVERSE)
|
||||||
.short(options::traverse::NO_TRAVERSE.chars().next().unwrap())
|
.short(options::traverse::NO_TRAVERSE.chars().next().unwrap())
|
||||||
.help("do not traverse any symbolic links (default)")
|
.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),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -66,7 +66,7 @@ fn get_local_to_root_parent(
|
||||||
adjust_canonicalization(path),
|
adjust_canonicalization(path),
|
||||||
adjust_canonicalization(parent),
|
adjust_canonicalization(parent),
|
||||||
);
|
);
|
||||||
let path = path.strip_prefix(&parent)?;
|
let path = path.strip_prefix(parent)?;
|
||||||
Ok(path.to_path_buf())
|
Ok(path.to_path_buf())
|
||||||
}
|
}
|
||||||
None => Ok(path.to_path_buf()),
|
None => Ok(path.to_path_buf()),
|
||||||
|
|
|
@ -427,7 +427,7 @@ pub fn uu_app() -> Command {
|
||||||
))
|
))
|
||||||
.num_args(0..)
|
.num_args(0..)
|
||||||
.value_name("ATTR_LIST")
|
.value_name("ATTR_LIST")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::ARCHIVE,
|
options::ARCHIVE,
|
||||||
options::PRESERVE_DEFAULT_ATTRIBUTES,
|
options::PRESERVE_DEFAULT_ATTRIBUTES,
|
||||||
options::NO_PRESERVE,
|
options::NO_PRESERVE,
|
||||||
|
@ -443,7 +443,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::PRESERVE_DEFAULT_ATTRIBUTES)
|
Arg::new(options::PRESERVE_DEFAULT_ATTRIBUTES)
|
||||||
.short('p')
|
.short('p')
|
||||||
.long(options::PRESERVE_DEFAULT_ATTRIBUTES)
|
.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")
|
.help("same as --preserve=mode,ownership(unix only),timestamps")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
@ -451,7 +451,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::NO_PRESERVE)
|
Arg::new(options::NO_PRESERVE)
|
||||||
.long(options::NO_PRESERVE)
|
.long(options::NO_PRESERVE)
|
||||||
.value_name("ATTR_LIST")
|
.value_name("ATTR_LIST")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::PRESERVE_DEFAULT_ATTRIBUTES,
|
options::PRESERVE_DEFAULT_ATTRIBUTES,
|
||||||
options::PRESERVE,
|
options::PRESERVE,
|
||||||
options::ARCHIVE,
|
options::ARCHIVE,
|
||||||
|
@ -492,7 +492,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::ARCHIVE)
|
Arg::new(options::ARCHIVE)
|
||||||
.short('a')
|
.short('a')
|
||||||
.long(options::ARCHIVE)
|
.long(options::ARCHIVE)
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::PRESERVE_DEFAULT_ATTRIBUTES,
|
options::PRESERVE_DEFAULT_ATTRIBUTES,
|
||||||
options::PRESERVE,
|
options::PRESERVE,
|
||||||
options::NO_PRESERVE,
|
options::NO_PRESERVE,
|
||||||
|
@ -1264,6 +1264,12 @@ fn copy_file(
|
||||||
symlinked_files: &mut HashSet<FileInformation>,
|
symlinked_files: &mut HashSet<FileInformation>,
|
||||||
source_in_command_line: bool,
|
source_in_command_line: bool,
|
||||||
) -> CopyResult<()> {
|
) -> CopyResult<()> {
|
||||||
|
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(());
|
||||||
|
}
|
||||||
|
|
||||||
if file_or_link_exists(dest) {
|
if file_or_link_exists(dest) {
|
||||||
handle_existing_dest(source, dest, options, source_in_command_line)?;
|
handle_existing_dest(source, dest, options, source_in_command_line)?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ fn unimplemented_flags_should_error() {
|
||||||
fn test_status_level_absent() {
|
fn test_status_level_absent() {
|
||||||
let args = &["if=foo.file", "of=bar.file"];
|
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]
|
#[test]
|
||||||
|
@ -96,7 +96,7 @@ fn test_status_level_none() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Parser::new().parse(args).unwrap().status,
|
Parser::new().parse(args).unwrap().status,
|
||||||
Some(StatusLevel::None)
|
Some(StatusLevel::None)
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -509,7 +509,7 @@ pub fn uu_app() -> Command {
|
||||||
.short('B')
|
.short('B')
|
||||||
.long("block-size")
|
.long("block-size")
|
||||||
.value_name("SIZE")
|
.value_name("SIZE")
|
||||||
.overrides_with_all(&[OPT_KILO, OPT_BLOCKSIZE])
|
.overrides_with_all([OPT_KILO, OPT_BLOCKSIZE])
|
||||||
.help(
|
.help(
|
||||||
"scale sizes by SIZE before printing them; e.g.\
|
"scale sizes by SIZE before printing them; e.g.\
|
||||||
'-BM' prints sizes in units of 1,048,576 bytes",
|
'-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)
|
Arg::new(OPT_HUMAN_READABLE_BINARY)
|
||||||
.short('h')
|
.short('h')
|
||||||
.long("human-readable")
|
.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)")
|
.help("print sizes in human readable format (e.g., 1K 234M 2G)")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
@ -534,7 +534,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(OPT_HUMAN_READABLE_DECIMAL)
|
Arg::new(OPT_HUMAN_READABLE_DECIMAL)
|
||||||
.short('H')
|
.short('H')
|
||||||
.long("si")
|
.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")
|
.help("likewise, but use powers of 1000 not 1024")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
@ -550,7 +550,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(OPT_KILO)
|
Arg::new(OPT_KILO)
|
||||||
.short('k')
|
.short('k')
|
||||||
.help("like --block-size=1K")
|
.help("like --block-size=1K")
|
||||||
.overrides_with_all(&[OPT_BLOCKSIZE, OPT_KILO])
|
.overrides_with_all([OPT_BLOCKSIZE, OPT_KILO])
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -564,7 +564,7 @@ pub fn uu_app() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(OPT_NO_SYNC)
|
Arg::new(OPT_NO_SYNC)
|
||||||
.long("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)")
|
.help("do not invoke sync before getting usage info (default)")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
@ -577,9 +577,9 @@ pub fn uu_app() -> Command {
|
||||||
.require_equals(true)
|
.require_equals(true)
|
||||||
.use_value_delimiter(true)
|
.use_value_delimiter(true)
|
||||||
.value_parser(OUTPUT_FIELD_LIST)
|
.value_parser(OUTPUT_FIELD_LIST)
|
||||||
.default_missing_values(&OUTPUT_FIELD_LIST)
|
.default_missing_values(OUTPUT_FIELD_LIST)
|
||||||
.default_values(&["source", "size", "used", "avail", "pcent", "target"])
|
.default_values(["source", "size", "used", "avail", "pcent", "target"])
|
||||||
.conflicts_with_all(&[OPT_INODES, OPT_PORTABILITY, OPT_PRINT_TYPE])
|
.conflicts_with_all([OPT_INODES, OPT_PORTABILITY, OPT_PRINT_TYPE])
|
||||||
.help(
|
.help(
|
||||||
"use the output format defined by FIELD_LIST, \
|
"use the output format defined by FIELD_LIST, \
|
||||||
or print all fields if FIELD_LIST is omitted.",
|
or print all fields if FIELD_LIST is omitted.",
|
||||||
|
@ -596,7 +596,7 @@ pub fn uu_app() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(OPT_SYNC)
|
Arg::new(OPT_SYNC)
|
||||||
.long("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)")
|
.help("invoke sync before getting usage info (non-windows only)")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
|
|
@ -64,6 +64,9 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result<bool> {
|
||||||
|
|
||||||
let mut buffer = ['\\'; 2];
|
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();
|
let mut iter = input.chars().peekable();
|
||||||
while let Some(mut c) = iter.next() {
|
while let Some(mut c) = iter.next() {
|
||||||
let mut start = 1;
|
let mut start = 1;
|
||||||
|
|
|
@ -59,7 +59,7 @@ pub fn uu_app() -> Command {
|
||||||
NUM bytes of each file\
|
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),
|
.allow_hyphen_values(true),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -74,7 +74,7 @@ pub fn uu_app() -> Command {
|
||||||
NUM lines of each file\
|
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),
|
.allow_hyphen_values(true),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -83,7 +83,7 @@ pub fn uu_app() -> Command {
|
||||||
.long("quiet")
|
.long("quiet")
|
||||||
.visible_alias("silent")
|
.visible_alias("silent")
|
||||||
.help("never print headers giving file names")
|
.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),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -91,7 +91,7 @@ pub fn uu_app() -> Command {
|
||||||
.short('v')
|
.short('v')
|
||||||
.long("verbose")
|
.long("verbose")
|
||||||
.help("always print headers giving file names")
|
.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),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -81,7 +81,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(OPT_DOMAIN)
|
Arg::new(OPT_DOMAIN)
|
||||||
.short('d')
|
.short('d')
|
||||||
.long("domain")
|
.long("domain")
|
||||||
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
.overrides_with_all([OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
||||||
.help("Display the name of the DNS domain if possible")
|
.help("Display the name of the DNS domain if possible")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
@ -89,7 +89,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(OPT_IP_ADDRESS)
|
Arg::new(OPT_IP_ADDRESS)
|
||||||
.short('i')
|
.short('i')
|
||||||
.long("ip-address")
|
.long("ip-address")
|
||||||
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
.overrides_with_all([OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
||||||
.help("Display the network address(es) of the host")
|
.help("Display the network address(es) of the host")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
@ -97,7 +97,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(OPT_FQDN)
|
Arg::new(OPT_FQDN)
|
||||||
.short('f')
|
.short('f')
|
||||||
.long("fqdn")
|
.long("fqdn")
|
||||||
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
.overrides_with_all([OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
||||||
.help("Display the FQDN (Fully Qualified Domain Name) (default)")
|
.help("Display the FQDN (Fully Qualified Domain Name) (default)")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
@ -105,7 +105,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(OPT_SHORT)
|
Arg::new(OPT_SHORT)
|
||||||
.short('s')
|
.short('s')
|
||||||
.long("short")
|
.long("short")
|
||||||
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
.overrides_with_all([OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
|
||||||
.help("Display the short hostname (the portion before the first dot) if possible")
|
.help("Display the short hostname (the portion before the first dot) if possible")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
|
|
@ -348,7 +348,7 @@ pub fn uu_app() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::OPT_AUDIT)
|
Arg::new(options::OPT_AUDIT)
|
||||||
.short('A')
|
.short('A')
|
||||||
.conflicts_with_all(&[
|
.conflicts_with_all([
|
||||||
options::OPT_GROUP,
|
options::OPT_GROUP,
|
||||||
options::OPT_EFFECTIVE_USER,
|
options::OPT_EFFECTIVE_USER,
|
||||||
options::OPT_HUMAN_READABLE,
|
options::OPT_HUMAN_READABLE,
|
||||||
|
@ -382,7 +382,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::OPT_GROUPS)
|
Arg::new(options::OPT_GROUPS)
|
||||||
.short('G')
|
.short('G')
|
||||||
.long(options::OPT_GROUPS)
|
.long(options::OPT_GROUPS)
|
||||||
.conflicts_with_all(&[
|
.conflicts_with_all([
|
||||||
options::OPT_GROUP,
|
options::OPT_GROUP,
|
||||||
options::OPT_EFFECTIVE_USER,
|
options::OPT_EFFECTIVE_USER,
|
||||||
options::OPT_CONTEXT,
|
options::OPT_CONTEXT,
|
||||||
|
@ -443,7 +443,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::OPT_CONTEXT)
|
Arg::new(options::OPT_CONTEXT)
|
||||||
.short('Z')
|
.short('Z')
|
||||||
.long(options::OPT_CONTEXT)
|
.long(options::OPT_CONTEXT)
|
||||||
.conflicts_with_all(&[options::OPT_GROUP, options::OPT_EFFECTIVE_USER])
|
.conflicts_with_all([options::OPT_GROUP, options::OPT_EFFECTIVE_USER])
|
||||||
.help(CONTEXT_HELP_TEXT)
|
.help(CONTEXT_HELP_TEXT)
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
|
|
@ -981,7 +981,7 @@ pub fn uu_app() -> Command {
|
||||||
])
|
])
|
||||||
.hide_possible_values(true)
|
.hide_possible_values(true)
|
||||||
.require_equals(true)
|
.require_equals(true)
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::FORMAT,
|
options::FORMAT,
|
||||||
options::format::COLUMNS,
|
options::format::COLUMNS,
|
||||||
options::format::LONG,
|
options::format::LONG,
|
||||||
|
@ -993,7 +993,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::format::COLUMNS)
|
Arg::new(options::format::COLUMNS)
|
||||||
.short('C')
|
.short('C')
|
||||||
.help("Display the files in columns.")
|
.help("Display the files in columns.")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::FORMAT,
|
options::FORMAT,
|
||||||
options::format::COLUMNS,
|
options::format::COLUMNS,
|
||||||
options::format::LONG,
|
options::format::LONG,
|
||||||
|
@ -1007,7 +1007,7 @@ pub fn uu_app() -> Command {
|
||||||
.short('l')
|
.short('l')
|
||||||
.long(options::format::LONG)
|
.long(options::format::LONG)
|
||||||
.help("Display detailed information.")
|
.help("Display detailed information.")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::FORMAT,
|
options::FORMAT,
|
||||||
options::format::COLUMNS,
|
options::format::COLUMNS,
|
||||||
options::format::LONG,
|
options::format::LONG,
|
||||||
|
@ -1020,7 +1020,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::format::ACROSS)
|
Arg::new(options::format::ACROSS)
|
||||||
.short('x')
|
.short('x')
|
||||||
.help("List entries in rows instead of in columns.")
|
.help("List entries in rows instead of in columns.")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::FORMAT,
|
options::FORMAT,
|
||||||
options::format::COLUMNS,
|
options::format::COLUMNS,
|
||||||
options::format::LONG,
|
options::format::LONG,
|
||||||
|
@ -1042,7 +1042,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::format::COMMAS)
|
Arg::new(options::format::COMMAS)
|
||||||
.short('m')
|
.short('m')
|
||||||
.help("List entries separated by commas.")
|
.help("List entries separated by commas.")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::FORMAT,
|
options::FORMAT,
|
||||||
options::format::COLUMNS,
|
options::format::COLUMNS,
|
||||||
options::format::LONG,
|
options::format::LONG,
|
||||||
|
@ -1114,7 +1114,7 @@ pub fn uu_app() -> Command {
|
||||||
"c",
|
"c",
|
||||||
"escape",
|
"escape",
|
||||||
])
|
])
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::QUOTING_STYLE,
|
options::QUOTING_STYLE,
|
||||||
options::quoting::LITERAL,
|
options::quoting::LITERAL,
|
||||||
options::quoting::ESCAPE,
|
options::quoting::ESCAPE,
|
||||||
|
@ -1126,7 +1126,7 @@ pub fn uu_app() -> Command {
|
||||||
.short('N')
|
.short('N')
|
||||||
.long(options::quoting::LITERAL)
|
.long(options::quoting::LITERAL)
|
||||||
.help("Use literal quoting style. Equivalent to `--quoting-style=literal`")
|
.help("Use literal quoting style. Equivalent to `--quoting-style=literal`")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::QUOTING_STYLE,
|
options::QUOTING_STYLE,
|
||||||
options::quoting::LITERAL,
|
options::quoting::LITERAL,
|
||||||
options::quoting::ESCAPE,
|
options::quoting::ESCAPE,
|
||||||
|
@ -1139,7 +1139,7 @@ pub fn uu_app() -> Command {
|
||||||
.short('b')
|
.short('b')
|
||||||
.long(options::quoting::ESCAPE)
|
.long(options::quoting::ESCAPE)
|
||||||
.help("Use escape quoting style. Equivalent to `--quoting-style=escape`")
|
.help("Use escape quoting style. Equivalent to `--quoting-style=escape`")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::QUOTING_STYLE,
|
options::QUOTING_STYLE,
|
||||||
options::quoting::LITERAL,
|
options::quoting::LITERAL,
|
||||||
options::quoting::ESCAPE,
|
options::quoting::ESCAPE,
|
||||||
|
@ -1152,7 +1152,7 @@ pub fn uu_app() -> Command {
|
||||||
.short('Q')
|
.short('Q')
|
||||||
.long(options::quoting::C)
|
.long(options::quoting::C)
|
||||||
.help("Use C quoting style. Equivalent to `--quoting-style=c`")
|
.help("Use C quoting style. Equivalent to `--quoting-style=c`")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::QUOTING_STYLE,
|
options::QUOTING_STYLE,
|
||||||
options::quoting::LITERAL,
|
options::quoting::LITERAL,
|
||||||
options::quoting::ESCAPE,
|
options::quoting::ESCAPE,
|
||||||
|
@ -1166,14 +1166,14 @@ pub fn uu_app() -> Command {
|
||||||
.short('q')
|
.short('q')
|
||||||
.long(options::HIDE_CONTROL_CHARS)
|
.long(options::HIDE_CONTROL_CHARS)
|
||||||
.help("Replace control characters with '?' if they are not escaped.")
|
.help("Replace control characters with '?' if they are not escaped.")
|
||||||
.overrides_with_all(&[options::HIDE_CONTROL_CHARS, options::SHOW_CONTROL_CHARS])
|
.overrides_with_all([options::HIDE_CONTROL_CHARS, options::SHOW_CONTROL_CHARS])
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::SHOW_CONTROL_CHARS)
|
Arg::new(options::SHOW_CONTROL_CHARS)
|
||||||
.long(options::SHOW_CONTROL_CHARS)
|
.long(options::SHOW_CONTROL_CHARS)
|
||||||
.help("Show control characters 'as is' if they are not escaped.")
|
.help("Show control characters 'as is' if they are not escaped.")
|
||||||
.overrides_with_all(&[options::HIDE_CONTROL_CHARS, options::SHOW_CONTROL_CHARS])
|
.overrides_with_all([options::HIDE_CONTROL_CHARS, options::SHOW_CONTROL_CHARS])
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
// Time arguments
|
// Time arguments
|
||||||
|
@ -1192,7 +1192,7 @@ pub fn uu_app() -> Command {
|
||||||
])
|
])
|
||||||
.hide_possible_values(true)
|
.hide_possible_values(true)
|
||||||
.require_equals(true)
|
.require_equals(true)
|
||||||
.overrides_with_all(&[options::TIME, options::time::ACCESS, options::time::CHANGE]),
|
.overrides_with_all([options::TIME, options::time::ACCESS, options::time::CHANGE]),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::time::CHANGE)
|
Arg::new(options::time::CHANGE)
|
||||||
|
@ -1203,7 +1203,7 @@ pub fn uu_app() -> Command {
|
||||||
time. When explicitly sorting by time (--sort=time or -t) or when not \
|
time. When explicitly sorting by time (--sort=time or -t) or when not \
|
||||||
using a long listing format, sort according to the status change time.",
|
using a long listing format, sort according to the status change time.",
|
||||||
)
|
)
|
||||||
.overrides_with_all(&[options::TIME, options::time::ACCESS, options::time::CHANGE])
|
.overrides_with_all([options::TIME, options::time::ACCESS, options::time::CHANGE])
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -1215,7 +1215,7 @@ pub fn uu_app() -> Command {
|
||||||
sorting by time (--sort=time or -t) or when not using a long listing \
|
sorting by time (--sort=time or -t) or when not using a long listing \
|
||||||
format, sort according to the access time.",
|
format, sort according to the access time.",
|
||||||
)
|
)
|
||||||
.overrides_with_all(&[options::TIME, options::time::ACCESS, options::time::CHANGE])
|
.overrides_with_all([options::TIME, options::time::ACCESS, options::time::CHANGE])
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
// Hide and ignore
|
// Hide and ignore
|
||||||
|
@ -1251,7 +1251,7 @@ pub fn uu_app() -> Command {
|
||||||
.value_name("field")
|
.value_name("field")
|
||||||
.value_parser(["name", "none", "time", "size", "version", "extension"])
|
.value_parser(["name", "none", "time", "size", "version", "extension"])
|
||||||
.require_equals(true)
|
.require_equals(true)
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::SORT,
|
options::SORT,
|
||||||
options::sort::SIZE,
|
options::sort::SIZE,
|
||||||
options::sort::TIME,
|
options::sort::TIME,
|
||||||
|
@ -1264,7 +1264,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::sort::SIZE)
|
Arg::new(options::sort::SIZE)
|
||||||
.short('S')
|
.short('S')
|
||||||
.help("Sort by file size, largest first.")
|
.help("Sort by file size, largest first.")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::SORT,
|
options::SORT,
|
||||||
options::sort::SIZE,
|
options::sort::SIZE,
|
||||||
options::sort::TIME,
|
options::sort::TIME,
|
||||||
|
@ -1278,7 +1278,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::sort::TIME)
|
Arg::new(options::sort::TIME)
|
||||||
.short('t')
|
.short('t')
|
||||||
.help("Sort by modification time (the 'mtime' in the inode), newest first.")
|
.help("Sort by modification time (the 'mtime' in the inode), newest first.")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::SORT,
|
options::SORT,
|
||||||
options::sort::SIZE,
|
options::sort::SIZE,
|
||||||
options::sort::TIME,
|
options::sort::TIME,
|
||||||
|
@ -1292,7 +1292,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::sort::VERSION)
|
Arg::new(options::sort::VERSION)
|
||||||
.short('v')
|
.short('v')
|
||||||
.help("Natural sort of (version) numbers in the filenames.")
|
.help("Natural sort of (version) numbers in the filenames.")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::SORT,
|
options::SORT,
|
||||||
options::sort::SIZE,
|
options::sort::SIZE,
|
||||||
options::sort::TIME,
|
options::sort::TIME,
|
||||||
|
@ -1306,7 +1306,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::sort::EXTENSION)
|
Arg::new(options::sort::EXTENSION)
|
||||||
.short('X')
|
.short('X')
|
||||||
.help("Sort alphabetically by entry extension.")
|
.help("Sort alphabetically by entry extension.")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::SORT,
|
options::SORT,
|
||||||
options::sort::SIZE,
|
options::sort::SIZE,
|
||||||
options::sort::TIME,
|
options::sort::TIME,
|
||||||
|
@ -1324,7 +1324,7 @@ pub fn uu_app() -> Command {
|
||||||
directory. This is especially useful when listing very large directories, \
|
directory. This is especially useful when listing very large directories, \
|
||||||
since not doing any sorting can be noticeably faster.",
|
since not doing any sorting can be noticeably faster.",
|
||||||
)
|
)
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::SORT,
|
options::SORT,
|
||||||
options::sort::SIZE,
|
options::sort::SIZE,
|
||||||
options::sort::TIME,
|
options::sort::TIME,
|
||||||
|
@ -1343,7 +1343,7 @@ pub fn uu_app() -> Command {
|
||||||
"When showing file information for a symbolic link, show information for the \
|
"When showing file information for a symbolic link, show information for the \
|
||||||
file the link references rather than the link itself.",
|
file the link references rather than the link itself.",
|
||||||
)
|
)
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::dereference::ALL,
|
options::dereference::ALL,
|
||||||
options::dereference::DIR_ARGS,
|
options::dereference::DIR_ARGS,
|
||||||
options::dereference::ARGS,
|
options::dereference::ARGS,
|
||||||
|
@ -1357,7 +1357,7 @@ pub fn uu_app() -> Command {
|
||||||
"Do not dereference symlinks except when they link to directories and are \
|
"Do not dereference symlinks except when they link to directories and are \
|
||||||
given as command line arguments.",
|
given as command line arguments.",
|
||||||
)
|
)
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::dereference::ALL,
|
options::dereference::ALL,
|
||||||
options::dereference::DIR_ARGS,
|
options::dereference::DIR_ARGS,
|
||||||
options::dereference::ARGS,
|
options::dereference::ARGS,
|
||||||
|
@ -1369,7 +1369,7 @@ pub fn uu_app() -> Command {
|
||||||
.short('H')
|
.short('H')
|
||||||
.long(options::dereference::ARGS)
|
.long(options::dereference::ARGS)
|
||||||
.help("Do not dereference symlinks except when given as command line arguments.")
|
.help("Do not dereference symlinks except when given as command line arguments.")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::dereference::ALL,
|
options::dereference::ALL,
|
||||||
options::dereference::DIR_ARGS,
|
options::dereference::DIR_ARGS,
|
||||||
options::dereference::ARGS,
|
options::dereference::ARGS,
|
||||||
|
@ -1509,7 +1509,7 @@ pub fn uu_app() -> Command {
|
||||||
none (default), slash (-p), file-type (--file-type), classify (-F)",
|
none (default), slash (-p), file-type (--file-type), classify (-F)",
|
||||||
)
|
)
|
||||||
.value_parser(["none", "slash", "file-type", "classify"])
|
.value_parser(["none", "slash", "file-type", "classify"])
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::indicator_style::FILE_TYPE,
|
options::indicator_style::FILE_TYPE,
|
||||||
options::indicator_style::SLASH,
|
options::indicator_style::SLASH,
|
||||||
options::indicator_style::CLASSIFY,
|
options::indicator_style::CLASSIFY,
|
||||||
|
@ -1545,7 +1545,7 @@ pub fn uu_app() -> Command {
|
||||||
.default_missing_value("always")
|
.default_missing_value("always")
|
||||||
.require_equals(true)
|
.require_equals(true)
|
||||||
.num_args(0..=1)
|
.num_args(0..=1)
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::indicator_style::FILE_TYPE,
|
options::indicator_style::FILE_TYPE,
|
||||||
options::indicator_style::SLASH,
|
options::indicator_style::SLASH,
|
||||||
options::indicator_style::CLASSIFY,
|
options::indicator_style::CLASSIFY,
|
||||||
|
@ -1556,7 +1556,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::indicator_style::FILE_TYPE)
|
Arg::new(options::indicator_style::FILE_TYPE)
|
||||||
.long(options::indicator_style::FILE_TYPE)
|
.long(options::indicator_style::FILE_TYPE)
|
||||||
.help("Same as --classify, but do not append '*'")
|
.help("Same as --classify, but do not append '*'")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::indicator_style::FILE_TYPE,
|
options::indicator_style::FILE_TYPE,
|
||||||
options::indicator_style::SLASH,
|
options::indicator_style::SLASH,
|
||||||
options::indicator_style::CLASSIFY,
|
options::indicator_style::CLASSIFY,
|
||||||
|
@ -1568,7 +1568,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::indicator_style::SLASH)
|
Arg::new(options::indicator_style::SLASH)
|
||||||
.short('p')
|
.short('p')
|
||||||
.help("Append / indicator to directories.")
|
.help("Append / indicator to directories.")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all([
|
||||||
options::indicator_style::FILE_TYPE,
|
options::indicator_style::FILE_TYPE,
|
||||||
options::indicator_style::SLASH,
|
options::indicator_style::SLASH,
|
||||||
options::indicator_style::CLASSIFY,
|
options::indicator_style::CLASSIFY,
|
||||||
|
@ -1584,7 +1584,7 @@ pub fn uu_app() -> Command {
|
||||||
.value_name("TIME_STYLE")
|
.value_name("TIME_STYLE")
|
||||||
.env("TIME_STYLE")
|
.env("TIME_STYLE")
|
||||||
.value_parser(NonEmptyStringValueParser::new())
|
.value_parser(NonEmptyStringValueParser::new())
|
||||||
.overrides_with_all(&[options::TIME_STYLE]),
|
.overrides_with_all([options::TIME_STYLE]),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::FULL_TIME)
|
Arg::new(options::FULL_TIME)
|
||||||
|
|
|
@ -371,6 +371,12 @@ fn rename(from: &Path, to: &Path, b: &Behavior) -> io::Result<()> {
|
||||||
let mut backup_path = None;
|
let mut backup_path = None;
|
||||||
|
|
||||||
if to.exists() {
|
if to.exists() {
|
||||||
|
if b.update && b.overwrite == OverwriteMode::Interactive {
|
||||||
|
// `mv -i --update old new` when `new` exists doesn't move anything
|
||||||
|
// and exit with 0
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
match b.overwrite {
|
match b.overwrite {
|
||||||
OverwriteMode::NoClobber => return Ok(()),
|
OverwriteMode::NoClobber => return Ok(()),
|
||||||
OverwriteMode::Interactive => {
|
OverwriteMode::Interactive => {
|
||||||
|
|
|
@ -130,7 +130,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(OPT_PHYSICAL)
|
Arg::new(OPT_PHYSICAL)
|
||||||
.short('P')
|
.short('P')
|
||||||
.long(OPT_PHYSICAL)
|
.long(OPT_PHYSICAL)
|
||||||
.overrides_with_all(&[OPT_STRIP, OPT_LOGICAL])
|
.overrides_with_all([OPT_STRIP, OPT_LOGICAL])
|
||||||
.help("resolve symlinks as encountered (default)")
|
.help("resolve symlinks as encountered (default)")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1336,7 +1336,7 @@ pub fn uu_app() -> Command {
|
||||||
"version",
|
"version",
|
||||||
"random",
|
"random",
|
||||||
])
|
])
|
||||||
.conflicts_with_all(&options::modes::ALL_SORT_MODES),
|
.conflicts_with_all(options::modes::ALL_SORT_MODES),
|
||||||
)
|
)
|
||||||
.arg(make_sort_mode_arg(
|
.arg(make_sort_mode_arg(
|
||||||
options::modes::HUMAN_NUMERIC,
|
options::modes::HUMAN_NUMERIC,
|
||||||
|
@ -1373,7 +1373,7 @@ pub fn uu_app() -> Command {
|
||||||
.short('d')
|
.short('d')
|
||||||
.long(options::DICTIONARY_ORDER)
|
.long(options::DICTIONARY_ORDER)
|
||||||
.help("consider only blanks and alphanumeric characters")
|
.help("consider only blanks and alphanumeric characters")
|
||||||
.conflicts_with_all(&[
|
.conflicts_with_all([
|
||||||
options::modes::NUMERIC,
|
options::modes::NUMERIC,
|
||||||
options::modes::GENERAL_NUMERIC,
|
options::modes::GENERAL_NUMERIC,
|
||||||
options::modes::HUMAN_NUMERIC,
|
options::modes::HUMAN_NUMERIC,
|
||||||
|
@ -1425,7 +1425,7 @@ pub fn uu_app() -> Command {
|
||||||
.short('i')
|
.short('i')
|
||||||
.long(options::IGNORE_NONPRINTING)
|
.long(options::IGNORE_NONPRINTING)
|
||||||
.help("ignore nonprinting characters")
|
.help("ignore nonprinting characters")
|
||||||
.conflicts_with_all(&[
|
.conflicts_with_all([
|
||||||
options::modes::NUMERIC,
|
options::modes::NUMERIC,
|
||||||
options::modes::GENERAL_NUMERIC,
|
options::modes::GENERAL_NUMERIC,
|
||||||
options::modes::HUMAN_NUMERIC,
|
options::modes::HUMAN_NUMERIC,
|
||||||
|
|
|
@ -334,7 +334,7 @@ pub fn uu_app() -> Command {
|
||||||
.short('c')
|
.short('c')
|
||||||
.long(options::BYTES)
|
.long(options::BYTES)
|
||||||
.allow_hyphen_values(true)
|
.allow_hyphen_values(true)
|
||||||
.overrides_with_all(&[options::BYTES, options::LINES])
|
.overrides_with_all([options::BYTES, options::LINES])
|
||||||
.help("Number of bytes to print"),
|
.help("Number of bytes to print"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -352,7 +352,7 @@ pub fn uu_app() -> Command {
|
||||||
.short('n')
|
.short('n')
|
||||||
.long(options::LINES)
|
.long(options::LINES)
|
||||||
.allow_hyphen_values(true)
|
.allow_hyphen_values(true)
|
||||||
.overrides_with_all(&[options::BYTES, options::LINES])
|
.overrides_with_all([options::BYTES, options::LINES])
|
||||||
.help("Number of lines to print"),
|
.help("Number of lines to print"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -366,7 +366,7 @@ pub fn uu_app() -> Command {
|
||||||
.short('q')
|
.short('q')
|
||||||
.long(options::verbosity::QUIET)
|
.long(options::verbosity::QUIET)
|
||||||
.visible_alias("silent")
|
.visible_alias("silent")
|
||||||
.overrides_with_all(&[options::verbosity::QUIET, options::verbosity::VERBOSE])
|
.overrides_with_all([options::verbosity::QUIET, options::verbosity::VERBOSE])
|
||||||
.help("Never output headers giving file names")
|
.help("Never output headers giving file names")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
@ -392,7 +392,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::verbosity::VERBOSE)
|
Arg::new(options::verbosity::VERBOSE)
|
||||||
.short('v')
|
.short('v')
|
||||||
.long(options::verbosity::VERBOSE)
|
.long(options::verbosity::VERBOSE)
|
||||||
.overrides_with_all(&[options::verbosity::QUIET, options::verbosity::VERBOSE])
|
.overrides_with_all([options::verbosity::QUIET, options::verbosity::VERBOSE])
|
||||||
.help("Always output headers giving file names")
|
.help("Always output headers giving file names")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
@ -421,7 +421,7 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::FOLLOW_RETRY)
|
Arg::new(options::FOLLOW_RETRY)
|
||||||
.short('F')
|
.short('F')
|
||||||
.help("Same as --follow=name --retry")
|
.help("Same as --follow=name --retry")
|
||||||
.overrides_with_all(&[options::RETRY, options::FOLLOW])
|
.overrides_with_all([options::RETRY, options::FOLLOW])
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -452,18 +452,18 @@ mod tests {
|
||||||
fn test_integer_op() {
|
fn test_integer_op() {
|
||||||
let a = OsStr::new("18446744073709551616");
|
let a = OsStr::new("18446744073709551616");
|
||||||
let b = OsStr::new("0");
|
let b = OsStr::new("0");
|
||||||
assert_eq!(integers(a, b, OsStr::new("-lt")).unwrap(), false);
|
assert!(!integers(a, b, OsStr::new("-lt")).unwrap());
|
||||||
let a = OsStr::new("18446744073709551616");
|
let a = OsStr::new("18446744073709551616");
|
||||||
let b = OsStr::new("0");
|
let b = OsStr::new("0");
|
||||||
assert_eq!(integers(a, b, OsStr::new("-gt")).unwrap(), true);
|
assert!(integers(a, b, OsStr::new("-gt")).unwrap());
|
||||||
let a = OsStr::new("-1");
|
let a = OsStr::new("-1");
|
||||||
let b = OsStr::new("0");
|
let b = OsStr::new("0");
|
||||||
assert_eq!(integers(a, b, OsStr::new("-lt")).unwrap(), true);
|
assert!(integers(a, b, OsStr::new("-lt")).unwrap());
|
||||||
let a = OsStr::new("42");
|
let a = OsStr::new("42");
|
||||||
let b = OsStr::new("42");
|
let b = OsStr::new("42");
|
||||||
assert_eq!(integers(a, b, OsStr::new("-eq")).unwrap(), true);
|
assert!(integers(a, b, OsStr::new("-eq")).unwrap());
|
||||||
let a = OsStr::new("42");
|
let a = OsStr::new("42");
|
||||||
let b = OsStr::new("42");
|
let b = OsStr::new("42");
|
||||||
assert_eq!(integers(a, b, OsStr::new("-ne")).unwrap(), false);
|
assert!(!integers(a, b, OsStr::new("-ne")).unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,7 +254,7 @@ pub fn uu_app() -> Command {
|
||||||
.value_parser(ValueParser::os_string())
|
.value_parser(ValueParser::os_string())
|
||||||
.value_hint(clap::ValueHint::AnyPath),
|
.value_hint(clap::ValueHint::AnyPath),
|
||||||
)
|
)
|
||||||
.group(ArgGroup::new(options::SOURCES).args(&[
|
.group(ArgGroup::new(options::SOURCES).args([
|
||||||
options::sources::CURRENT,
|
options::sources::CURRENT,
|
||||||
options::sources::DATE,
|
options::sources::DATE,
|
||||||
options::sources::REFERENCE,
|
options::sources::REFERENCE,
|
||||||
|
|
|
@ -336,7 +336,7 @@ pub fn uu_app() -> Command {
|
||||||
.num_args(0..=1)
|
.num_args(0..=1)
|
||||||
.default_missing_value("separate")
|
.default_missing_value("separate")
|
||||||
.require_equals(true)
|
.require_equals(true)
|
||||||
.conflicts_with_all(&[
|
.conflicts_with_all([
|
||||||
options::REPEATED,
|
options::REPEATED,
|
||||||
options::ALL_REPEATED,
|
options::ALL_REPEATED,
|
||||||
options::UNIQUE,
|
options::UNIQUE,
|
||||||
|
|
|
@ -250,7 +250,7 @@ pub fn uu_app() -> Command {
|
||||||
.long(options::MESG)
|
.long(options::MESG)
|
||||||
.short('T')
|
.short('T')
|
||||||
.visible_short_alias('w')
|
.visible_short_alias('w')
|
||||||
.visible_aliases(&["message", "writable"])
|
.visible_aliases(["message", "writable"])
|
||||||
.help("add user's message status as +, - or ?")
|
.help("add user's message status as +, - or ?")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
@ -350,7 +350,7 @@ impl Who {
|
||||||
println!("{}", users.join(" "));
|
println!("{}", users.join(" "));
|
||||||
println!("# users={}", users.len());
|
println!("# users={}", users.len());
|
||||||
} else {
|
} else {
|
||||||
let records = Utmpx::iter_all_records_from(f).peekable();
|
let records = Utmpx::iter_all_records_from(f);
|
||||||
|
|
||||||
if self.include_heading {
|
if self.include_heading {
|
||||||
self.print_heading();
|
self.print_heading();
|
||||||
|
|
|
@ -708,7 +708,7 @@ fn test_chown_file_notexisting() {
|
||||||
.fails();
|
.fails();
|
||||||
|
|
||||||
// TODO: uncomment once "failed to change ownership of '{}' to {}" added to stdout
|
// TODO: uncomment once "failed to change ownership of '{}' to {}" added to stdout
|
||||||
// result.stderr_contains(&"retained as");
|
// result.stderr_contains("retained as");
|
||||||
// TODO: uncomment once message changed from "cannot dereference" to "cannot access"
|
// TODO: uncomment once message changed from "cannot dereference" to "cannot access"
|
||||||
// result.stderr_contains(&"cannot access 'not_existing': No such file or directory");
|
// result.stderr_contains("cannot access 'not_existing': No such file or directory");
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,6 +215,18 @@ fn test_cp_target_directory_is_file() {
|
||||||
.stderr_contains(format!("'{}' is not a directory", TEST_HOW_ARE_YOU_SOURCE));
|
.stderr_contains(format!("'{}' is not a directory", TEST_HOW_ARE_YOU_SOURCE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_cp_arg_update_interactive() {
|
||||||
|
new_ucmd!()
|
||||||
|
.arg(TEST_HELLO_WORLD_SOURCE)
|
||||||
|
.arg(TEST_HOW_ARE_YOU_SOURCE)
|
||||||
|
.arg("-i")
|
||||||
|
.arg("--update")
|
||||||
|
.succeeds()
|
||||||
|
.no_stdout()
|
||||||
|
.no_stderr();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cp_arg_interactive() {
|
fn test_cp_arg_interactive() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
|
@ -1863,7 +1863,7 @@ fn test_ls_recursive() {
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
result.stdout_contains("a/b:\nb");
|
result.stdout_contains("a/b:\nb");
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
result.stdout_contains(&"a\\b:\nb");
|
result.stdout_contains("a\\b:\nb");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -2093,13 +2093,13 @@ fn test_ls_indicator_style() {
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg(format!("--indicator-style={}", opt))
|
.arg(format!("--indicator-style={}", opt))
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_contains(&"/");
|
.stdout_contains("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same test as above, but with the alternate flags.
|
// Same test as above, but with the alternate flags.
|
||||||
let options = vec!["--classify", "--file-type", "-p"];
|
let options = vec!["--classify", "--file-type", "-p"];
|
||||||
for opt in options {
|
for opt in options {
|
||||||
scene.ucmd().arg(opt).succeeds().stdout_contains(&"/");
|
scene.ucmd().arg(opt).succeeds().stdout_contains("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Classify and File-Type all contain indicators for pipes and links.
|
// Classify and File-Type all contain indicators for pipes and links.
|
||||||
|
@ -2110,7 +2110,7 @@ fn test_ls_indicator_style() {
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg(format!("--indicator-style={}", opt))
|
.arg(format!("--indicator-style={}", opt))
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_contains(&"@");
|
.stdout_contains("@");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3195,7 +3195,7 @@ fn test_ls_context_format() {
|
||||||
] {
|
] {
|
||||||
let format = format!("--format={}", word);
|
let format = format!("--format={}", word);
|
||||||
ts.ucmd()
|
ts.ucmd()
|
||||||
.args(&[&"-Z", &format.as_str(), &"/"])
|
.args(&["-Z", format.as_str(), "/"])
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_only(
|
.stdout_only(
|
||||||
unwrap_or_return!(expected_result(&ts, &["-Z", format.as_str(), "/"])).stdout_str(),
|
unwrap_or_return!(expected_result(&ts, &["-Z", format.as_str(), "/"])).stdout_str(),
|
||||||
|
|
|
@ -184,6 +184,25 @@ fn test_mv_interactive() {
|
||||||
assert!(at.file_exists(file_b));
|
assert!(at.file_exists(file_b));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_mv_arg_update_interactive() {
|
||||||
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
||||||
|
let file_a = "test_mv_replace_file_a";
|
||||||
|
let file_b = "test_mv_replace_file_b";
|
||||||
|
|
||||||
|
at.touch(file_a);
|
||||||
|
at.touch(file_b);
|
||||||
|
|
||||||
|
ucmd.arg(file_a)
|
||||||
|
.arg(file_b)
|
||||||
|
.arg("-i")
|
||||||
|
.arg("--update")
|
||||||
|
.succeeds()
|
||||||
|
.no_stdout()
|
||||||
|
.no_stderr();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mv_no_clobber() {
|
fn test_mv_no_clobber() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
|
@ -58,11 +58,11 @@ impl Distribution<u8> for AlphanumericNewline {
|
||||||
/// use rand::distributions::Alphanumeric;
|
/// use rand::distributions::Alphanumeric;
|
||||||
///
|
///
|
||||||
/// // generates a 100 byte string with characters from AlphanumericNewline
|
/// // generates a 100 byte string with characters from AlphanumericNewline
|
||||||
/// let random_string = RandomString::generate(&AlphanumericNewline, 100);
|
/// let random_string = RandomString::generate(AlphanumericNewline, 100);
|
||||||
/// assert_eq!(100, random_string.len());
|
/// assert_eq!(100, random_string.len());
|
||||||
///
|
///
|
||||||
/// // generates a 100 byte string with 10 newline characters not ending with a newline
|
/// // generates a 100 byte string with 10 newline characters not ending with a newline
|
||||||
/// let string = RandomString::generate_with_delimiter(&Alphanumeric, b'\n', 10, false, 100);
|
/// let string = RandomString::generate_with_delimiter(Alphanumeric, b'\n', 10, false, 100);
|
||||||
/// assert_eq!(100, random_string.len());
|
/// assert_eq!(100, random_string.len());
|
||||||
/// ```
|
/// ```
|
||||||
pub struct RandomString;
|
pub struct RandomString;
|
||||||
|
@ -108,7 +108,7 @@ impl RandomString {
|
||||||
/// use crate::common::random::{AlphanumericNewline, RandomString};
|
/// use crate::common::random::{AlphanumericNewline, RandomString};
|
||||||
///
|
///
|
||||||
/// // generates a 100 byte string with 10 '\0' byte characters not ending with a '\0' byte
|
/// // generates a 100 byte string with 10 '\0' byte characters not ending with a '\0' byte
|
||||||
/// let string = RandomString::generate_with_delimiter(&AlphanumericNewline, 0, 10, false, 100);
|
/// let string = RandomString::generate_with_delimiter(AlphanumericNewline, 0, 10, false, 100);
|
||||||
/// assert_eq!(100, random_string.len());
|
/// assert_eq!(100, random_string.len());
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// 10,
|
/// 10,
|
||||||
|
|
Loading…
Reference in a new issue