mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
Merge pull request #5582 from zhitkoff/wc-files
wc: pass GNU test wc-files0-from.pl
This commit is contained in:
commit
55d931e853
2 changed files with 12 additions and 5 deletions
|
@ -167,7 +167,9 @@ impl<'a> Inputs<'a> {
|
||||||
None => Ok(Self::Files0From(input)),
|
None => Ok(Self::Files0From(input)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(Some(_), Some(_)) => Err(WcError::FilesDisabled.into()),
|
(Some(mut files), Some(_)) => {
|
||||||
|
Err(WcError::files_disabled(files.next().unwrap()).into())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,8 +344,8 @@ impl TotalWhen {
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
enum WcError {
|
enum WcError {
|
||||||
#[error("file operands cannot be combined with --files0-from")]
|
#[error("extra operand '{extra}'\nfile operands cannot be combined with --files0-from")]
|
||||||
FilesDisabled,
|
FilesDisabled { extra: Cow<'static, str> },
|
||||||
#[error("when reading file names from stdin, no file name of '-' allowed")]
|
#[error("when reading file names from stdin, no file name of '-' allowed")]
|
||||||
StdinReprNotAllowed,
|
StdinReprNotAllowed,
|
||||||
#[error("invalid zero-length file name")]
|
#[error("invalid zero-length file name")]
|
||||||
|
@ -365,11 +367,15 @@ impl WcError {
|
||||||
None => Self::ZeroLengthFileName,
|
None => Self::ZeroLengthFileName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn files_disabled(first_extra: &OsString) -> Self {
|
||||||
|
let extra = first_extra.to_string_lossy().into_owned().into();
|
||||||
|
Self::FilesDisabled { extra }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UError for WcError {
|
impl UError for WcError {
|
||||||
fn usage(&self) -> bool {
|
fn usage(&self) -> bool {
|
||||||
matches!(self, Self::FilesDisabled)
|
matches!(self, Self::FilesDisabled { .. })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -423,7 +423,8 @@ fn test_files_from_pseudo_filesystem() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_files0_disabled_files_argument() {
|
fn test_files0_disabled_files_argument() {
|
||||||
const MSG: &str = "file operands cannot be combined with --files0-from";
|
const MSG: &str =
|
||||||
|
"extra operand 'lorem_ipsum.txt'\nfile operands cannot be combined with --files0-from";
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--files0-from=files0_list.txt"])
|
.args(&["--files0-from=files0_list.txt"])
|
||||||
.arg("lorem_ipsum.txt")
|
.arg("lorem_ipsum.txt")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue