mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #2447 from jhscheer/locale_c
fix some issues with locale (replace "LANGUAGE" with "LC_ALL")
This commit is contained in:
commit
87eaf6e80a
41 changed files with 135 additions and 140 deletions
|
@ -39,7 +39,7 @@ impl Config {
|
||||||
Some(mut values) => {
|
Some(mut values) => {
|
||||||
let name = values.next().unwrap();
|
let name = values.next().unwrap();
|
||||||
if values.len() != 0 {
|
if values.len() != 0 {
|
||||||
return Err(format!("extra operand ‘{}’", name));
|
return Err(format!("extra operand '{}'", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if name == "-" {
|
if name == "-" {
|
||||||
|
@ -58,7 +58,7 @@ impl Config {
|
||||||
.value_of(options::WRAP)
|
.value_of(options::WRAP)
|
||||||
.map(|num| {
|
.map(|num| {
|
||||||
num.parse::<usize>()
|
num.parse::<usize>()
|
||||||
.map_err(|e| format!("Invalid wrap size: ‘{}’: {}", num, e))
|
.map_err(|e| format!("Invalid wrap size: '{}': {}", num, e))
|
||||||
})
|
})
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
|
||||||
|
|
|
@ -281,7 +281,7 @@ fn parse_spec(spec: &str) -> Result<(Option<u32>, Option<u32>), String> {
|
||||||
let uid = if usr_only || usr_grp {
|
let uid = if usr_only || usr_grp {
|
||||||
Some(
|
Some(
|
||||||
Passwd::locate(args[0])
|
Passwd::locate(args[0])
|
||||||
.map_err(|_| format!("invalid user: ‘{}’", spec))?
|
.map_err(|_| format!("invalid user: '{}'", spec))?
|
||||||
.uid(),
|
.uid(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -290,7 +290,7 @@ fn parse_spec(spec: &str) -> Result<(Option<u32>, Option<u32>), String> {
|
||||||
let gid = if grp_only || usr_grp {
|
let gid = if grp_only || usr_grp {
|
||||||
Some(
|
Some(
|
||||||
Group::locate(args[1])
|
Group::locate(args[1])
|
||||||
.map_err(|_| format!("invalid group: ‘{}’", spec))?
|
.map_err(|_| format!("invalid group: '{}'", spec))?
|
||||||
.gid(),
|
.gid(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1254,7 +1254,7 @@ fn copy_link(source: &Path, dest: &Path) -> CopyResult<()> {
|
||||||
Some(name) => dest.join(name).into(),
|
Some(name) => dest.join(name).into(),
|
||||||
None => crash!(
|
None => crash!(
|
||||||
EXIT_ERR,
|
EXIT_ERR,
|
||||||
"cannot stat ‘{}’: No such file or directory",
|
"cannot stat '{}': No such file or directory",
|
||||||
source.display()
|
source.display()
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
|
||||||
let format = if let Some(form) = matches.value_of(OPT_FORMAT) {
|
let format = if let Some(form) = matches.value_of(OPT_FORMAT) {
|
||||||
if !form.starts_with('+') {
|
if !form.starts_with('+') {
|
||||||
eprintln!("date: invalid date ‘{}’", form);
|
eprintln!("date: invalid date '{}'", form);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
let form = form[1..].to_string();
|
let form = form[1..].to_string();
|
||||||
|
@ -239,7 +239,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
let set_to = match matches.value_of(OPT_SET).map(parse_date) {
|
let set_to = match matches.value_of(OPT_SET).map(parse_date) {
|
||||||
None => None,
|
None => None,
|
||||||
Some(Err((input, _err))) => {
|
Some(Err((input, _err))) => {
|
||||||
eprintln!("date: invalid date ‘{}’", input);
|
eprintln!("date: invalid date '{}'", input);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Some(Ok(date)) => Some(date),
|
Some(Ok(date)) => Some(date),
|
||||||
|
@ -305,7 +305,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
println!("{}", formatted);
|
println!("{}", formatted);
|
||||||
}
|
}
|
||||||
Err((input, _err)) => {
|
Err((input, _err)) => {
|
||||||
println!("date: invalid date ‘{}’", input);
|
println!("date: invalid date '{}'", input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
if matches.is_present(options::PRINT_DATABASE) {
|
if matches.is_present(options::PRINT_DATABASE) {
|
||||||
if !files.is_empty() {
|
if !files.is_empty() {
|
||||||
show_usage_error!(
|
show_usage_error!(
|
||||||
"extra operand ‘{}’\nfile operands cannot be combined with \
|
"extra operand '{}'\nfile operands cannot be combined with \
|
||||||
--print-database (-p)",
|
--print-database (-p)",
|
||||||
files[0]
|
files[0]
|
||||||
);
|
);
|
||||||
|
@ -155,7 +155,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
result = parse(INTERNAL_DB.lines(), out_format, "")
|
result = parse(INTERNAL_DB.lines(), out_format, "")
|
||||||
} else {
|
} else {
|
||||||
if files.len() > 1 {
|
if files.len() > 1 {
|
||||||
show_usage_error!("extra operand ‘{}’", files[1]);
|
show_usage_error!("extra operand '{}'", files[1]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
match File::open(files[0]) {
|
match File::open(files[0]) {
|
||||||
|
|
|
@ -274,7 +274,7 @@ fn du(
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
safe_writeln!(
|
safe_writeln!(
|
||||||
stderr(),
|
stderr(),
|
||||||
"{}: cannot read directory ‘{}‘: {}",
|
"{}: cannot read directory '{}': {}",
|
||||||
options.program_name,
|
options.program_name,
|
||||||
my_stat.path.display(),
|
my_stat.path.display(),
|
||||||
e
|
e
|
||||||
|
@ -318,9 +318,7 @@ fn du(
|
||||||
let error_message = "Permission denied";
|
let error_message = "Permission denied";
|
||||||
show_error_custom_description!(description, "{}", error_message)
|
show_error_custom_description!(description, "{}", error_message)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => show_error!("cannot access '{}': {}", entry.path().display(), error),
|
||||||
show_error!("cannot access '{}': {}", entry.path().display(), error)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Err(error) => show_error!("{}", error),
|
Err(error) => show_error!("{}", error),
|
||||||
|
@ -594,9 +592,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
|
||||||
let files = match matches.value_of(options::FILE) {
|
let files = match matches.value_of(options::FILE) {
|
||||||
Some(_) => matches.values_of(options::FILE).unwrap().collect(),
|
Some(_) => matches.values_of(options::FILE).unwrap().collect(),
|
||||||
None => {
|
None => vec!["."],
|
||||||
vec!["."]
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let block_size = u64::try_from(read_block_size(matches.value_of(options::BLOCK_SIZE))).unwrap();
|
let block_size = u64::try_from(read_block_size(matches.value_of(options::BLOCK_SIZE))).unwrap();
|
||||||
|
@ -693,8 +689,8 @@ Try '{} --help' for more information.",
|
||||||
time
|
time
|
||||||
} else {
|
} else {
|
||||||
show_error!(
|
show_error!(
|
||||||
"Invalid argument ‘{}‘ for --time.
|
"Invalid argument '{}' for --time.
|
||||||
‘birth‘ and ‘creation‘ arguments are not supported on this platform.",
|
'birth' and 'creation' arguments are not supported on this platform.",
|
||||||
s
|
s
|
||||||
);
|
);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -269,7 +269,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
match Passwd::locate(users[i].as_str()) {
|
match Passwd::locate(users[i].as_str()) {
|
||||||
Ok(p) => Some(p),
|
Ok(p) => Some(p),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
show_error!("‘{}’: no such user", users[i]);
|
show_error!("'{}': no such user", users[i]);
|
||||||
exit_code = 1;
|
exit_code = 1;
|
||||||
if i + 1 >= users.len() {
|
if i + 1 >= users.len() {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -373,7 +373,7 @@ impl Config {
|
||||||
.value_of(options::WIDTH)
|
.value_of(options::WIDTH)
|
||||||
.map(|x| {
|
.map(|x| {
|
||||||
x.parse::<u16>().unwrap_or_else(|_e| {
|
x.parse::<u16>().unwrap_or_else(|_e| {
|
||||||
show_error!("invalid line width: ‘{}’", x);
|
show_error!("invalid line width: '{}'", x);
|
||||||
exit(2);
|
exit(2);
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -756,7 +756,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
Arg::with_name(options::time::CHANGE)
|
Arg::with_name(options::time::CHANGE)
|
||||||
.short(options::time::CHANGE)
|
.short(options::time::CHANGE)
|
||||||
.help("If the long listing format (e.g., -l, -o) is being used, print the status \
|
.help("If the long listing format (e.g., -l, -o) is being used, print the status \
|
||||||
change time (the ‘ctime’ in the inode) instead of the modification time. When \
|
change time (the 'ctime' in the inode) instead of the modification time. When \
|
||||||
explicitly sorting by time (--sort=time or -t) or when not using a long listing \
|
explicitly sorting by time (--sort=time or -t) or when not using a long listing \
|
||||||
format, sort according to the status change time.")
|
format, sort according to the status change time.")
|
||||||
.overrides_with_all(&[
|
.overrides_with_all(&[
|
||||||
|
|
|
@ -210,7 +210,7 @@ fn valid_type(tpe: String) -> Result<(), String> {
|
||||||
if vec!['b', 'c', 'u', 'p'].contains(&first_char) {
|
if vec!['b', 'c', 'u', 'p'].contains(&first_char) {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(format!("invalid device type ‘{}’", tpe))
|
Err(format!("invalid device type '{}'", tpe))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
|
||||||
if matches.is_present(OPT_TMPDIR) && PathBuf::from(prefix).is_absolute() {
|
if matches.is_present(OPT_TMPDIR) && PathBuf::from(prefix).is_absolute() {
|
||||||
show_error!(
|
show_error!(
|
||||||
"invalid template, ‘{}’; with --tmpdir, it may not be absolute",
|
"invalid template, '{}'; with --tmpdir, it may not be absolute",
|
||||||
template
|
template
|
||||||
);
|
);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -230,7 +230,7 @@ fn exec(files: &[PathBuf], b: Behavior) -> i32 {
|
||||||
// lacks permission to access metadata.
|
// lacks permission to access metadata.
|
||||||
if source.symlink_metadata().is_err() {
|
if source.symlink_metadata().is_err() {
|
||||||
show_error!(
|
show_error!(
|
||||||
"cannot stat ‘{}’: No such file or directory",
|
"cannot stat '{}': No such file or directory",
|
||||||
source.display()
|
source.display()
|
||||||
);
|
);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -240,7 +240,7 @@ fn exec(files: &[PathBuf], b: Behavior) -> i32 {
|
||||||
if b.no_target_dir {
|
if b.no_target_dir {
|
||||||
if !source.is_dir() {
|
if !source.is_dir() {
|
||||||
show_error!(
|
show_error!(
|
||||||
"cannot overwrite directory ‘{}’ with non-directory",
|
"cannot overwrite directory '{}' with non-directory",
|
||||||
target.display()
|
target.display()
|
||||||
);
|
);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -249,7 +249,7 @@ fn exec(files: &[PathBuf], b: Behavior) -> i32 {
|
||||||
return match rename(source, target, &b) {
|
return match rename(source, target, &b) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
show_error!(
|
show_error!(
|
||||||
"cannot move ‘{}’ to ‘{}’: {}",
|
"cannot move '{}' to '{}': {}",
|
||||||
source.display(),
|
source.display(),
|
||||||
target.display(),
|
target.display(),
|
||||||
e.to_string()
|
e.to_string()
|
||||||
|
@ -263,7 +263,7 @@ fn exec(files: &[PathBuf], b: Behavior) -> i32 {
|
||||||
return move_files_into_dir(&[source.clone()], target, &b);
|
return move_files_into_dir(&[source.clone()], target, &b);
|
||||||
} else if target.exists() && source.is_dir() {
|
} else if target.exists() && source.is_dir() {
|
||||||
show_error!(
|
show_error!(
|
||||||
"cannot overwrite non-directory ‘{}’ with directory ‘{}’",
|
"cannot overwrite non-directory '{}' with directory '{}'",
|
||||||
target.display(),
|
target.display(),
|
||||||
source.display()
|
source.display()
|
||||||
);
|
);
|
||||||
|
@ -278,7 +278,7 @@ fn exec(files: &[PathBuf], b: Behavior) -> i32 {
|
||||||
_ => {
|
_ => {
|
||||||
if b.no_target_dir {
|
if b.no_target_dir {
|
||||||
show_error!(
|
show_error!(
|
||||||
"mv: extra operand ‘{}’\n\
|
"mv: extra operand '{}'\n\
|
||||||
Try '{} --help' for more information.",
|
Try '{} --help' for more information.",
|
||||||
files[2].display(),
|
files[2].display(),
|
||||||
executable!()
|
executable!()
|
||||||
|
@ -294,7 +294,7 @@ fn exec(files: &[PathBuf], b: Behavior) -> i32 {
|
||||||
|
|
||||||
fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> i32 {
|
fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> i32 {
|
||||||
if !target_dir.is_dir() {
|
if !target_dir.is_dir() {
|
||||||
show_error!("target ‘{}’ is not a directory", target_dir.display());
|
show_error!("target '{}' is not a directory", target_dir.display());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> i3
|
||||||
Some(name) => target_dir.join(name),
|
Some(name) => target_dir.join(name),
|
||||||
None => {
|
None => {
|
||||||
show_error!(
|
show_error!(
|
||||||
"cannot stat ‘{}’: No such file or directory",
|
"cannot stat '{}': No such file or directory",
|
||||||
sourcepath.display()
|
sourcepath.display()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> i3
|
||||||
|
|
||||||
if let Err(e) = rename(sourcepath, &targetpath, b) {
|
if let Err(e) = rename(sourcepath, &targetpath, b) {
|
||||||
show_error!(
|
show_error!(
|
||||||
"cannot move ‘{}’ to ‘{}’: {}",
|
"cannot move '{}' to '{}': {}",
|
||||||
sourcepath.display(),
|
sourcepath.display(),
|
||||||
targetpath.display(),
|
targetpath.display(),
|
||||||
e.to_string()
|
e.to_string()
|
||||||
|
@ -338,7 +338,7 @@ fn rename(from: &Path, to: &Path, b: &Behavior) -> io::Result<()> {
|
||||||
match b.overwrite {
|
match b.overwrite {
|
||||||
OverwriteMode::NoClobber => return Ok(()),
|
OverwriteMode::NoClobber => return Ok(()),
|
||||||
OverwriteMode::Interactive => {
|
OverwriteMode::Interactive => {
|
||||||
println!("{}: overwrite ‘{}’? ", executable!(), to.display());
|
println!("{}: overwrite '{}'? ", executable!(), to.display());
|
||||||
if !read_yes() {
|
if !read_yes() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -371,9 +371,9 @@ fn rename(from: &Path, to: &Path, b: &Behavior) -> io::Result<()> {
|
||||||
rename_with_fallback(from, to)?;
|
rename_with_fallback(from, to)?;
|
||||||
|
|
||||||
if b.verbose {
|
if b.verbose {
|
||||||
print!("‘{}’ -> ‘{}’", from.display(), to.display());
|
print!("'{}' -> '{}'", from.display(), to.display());
|
||||||
match backup_path {
|
match backup_path {
|
||||||
Some(path) => println!(" (backup: ‘{}’)", path.display()),
|
Some(path) => println!(" (backup: '{}')", path.display()),
|
||||||
None => println!(),
|
None => println!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ impl<'a> Iterator for WhitespaceSplitter<'a> {
|
||||||
|
|
||||||
fn parse_suffix(s: &str) -> Result<(f64, Option<Suffix>)> {
|
fn parse_suffix(s: &str) -> Result<(f64, Option<Suffix>)> {
|
||||||
if s.is_empty() {
|
if s.is_empty() {
|
||||||
return Err("invalid number: ‘’".to_string());
|
return Err("invalid number: ''".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
let with_i = s.ends_with('i');
|
let with_i = s.ends_with('i');
|
||||||
|
@ -80,7 +80,7 @@ fn parse_suffix(s: &str) -> Result<(f64, Option<Suffix>)> {
|
||||||
Some('Z') => Ok(Some((RawSuffix::Z, with_i))),
|
Some('Z') => Ok(Some((RawSuffix::Z, with_i))),
|
||||||
Some('Y') => Ok(Some((RawSuffix::Y, with_i))),
|
Some('Y') => Ok(Some((RawSuffix::Y, with_i))),
|
||||||
Some('0'..='9') => Ok(None),
|
Some('0'..='9') => Ok(None),
|
||||||
_ => Err(format!("invalid suffix in input: ‘{}’", s)),
|
_ => Err(format!("invalid suffix in input: '{}'", s)),
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
let suffix_len = match suffix {
|
let suffix_len = match suffix {
|
||||||
|
@ -91,7 +91,7 @@ fn parse_suffix(s: &str) -> Result<(f64, Option<Suffix>)> {
|
||||||
|
|
||||||
let number = s[..s.len() - suffix_len]
|
let number = s[..s.len() - suffix_len]
|
||||||
.parse::<f64>()
|
.parse::<f64>()
|
||||||
.map_err(|_| format!("invalid number: ‘{}’", s))?;
|
.map_err(|_| format!("invalid number: '{}'", s))?;
|
||||||
|
|
||||||
Ok((number, suffix))
|
Ok((number, suffix))
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ fn parse_options(args: &ArgMatches) -> Result<NumfmtOptions> {
|
||||||
0 => Err(value),
|
0 => Err(value),
|
||||||
_ => Ok(n),
|
_ => Ok(n),
|
||||||
})
|
})
|
||||||
.map_err(|value| format!("invalid header value ‘{}’", value))
|
.map_err(|value| format!("invalid header value '{}'", value))
|
||||||
}
|
}
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,7 @@ fn idle_string(when: i64) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn time_string(ut: &Utmpx) -> String {
|
fn time_string(ut: &Utmpx) -> String {
|
||||||
time::strftime("%Y-%m-%d %H:%M", &ut.login_time()).unwrap()
|
time::strftime("%b %e %H:%M", &ut.login_time()).unwrap() // LC_ALL=C
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Pinky {
|
impl Pinky {
|
||||||
|
|
|
@ -234,7 +234,7 @@ impl LineSplitter {
|
||||||
fn new(settings: &Settings) -> LineSplitter {
|
fn new(settings: &Settings) -> LineSplitter {
|
||||||
LineSplitter {
|
LineSplitter {
|
||||||
lines_per_split: settings.strategy_param.parse().unwrap_or_else(|_| {
|
lines_per_split: settings.strategy_param.parse().unwrap_or_else(|_| {
|
||||||
crash!(1, "invalid number of lines: ‘{}’", settings.strategy_param)
|
crash!(1, "invalid number of lines: '{}'", settings.strategy_param)
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ use std::{cmp, fs, iter};
|
||||||
macro_rules! check_bound {
|
macro_rules! check_bound {
|
||||||
($str: ident, $bound:expr, $beg: expr, $end: expr) => {
|
($str: ident, $bound:expr, $beg: expr, $end: expr) => {
|
||||||
if $end >= $bound {
|
if $end >= $bound {
|
||||||
return Err(format!("‘{}’: invalid directive", &$str[$beg..$end]));
|
return Err(format!("'{}': invalid directive", &$str[$beg..$end]));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ impl Parser {
|
||||||
self.expr();
|
self.expr();
|
||||||
match self.next_token() {
|
match self.next_token() {
|
||||||
Symbol::Literal(s) if s == ")" => (),
|
Symbol::Literal(s) if s == ")" => (),
|
||||||
_ => panic!("expected ‘)’"),
|
_ => panic!("expected ')'"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -314,7 +314,7 @@ impl Parser {
|
||||||
self.expr();
|
self.expr();
|
||||||
|
|
||||||
match self.tokens.next() {
|
match self.tokens.next() {
|
||||||
Some(token) => Err(format!("extra argument ‘{}’", token.to_string_lossy())),
|
Some(token) => Err(format!("extra argument '{}'", token.to_string_lossy())),
|
||||||
None => Ok(()),
|
None => Ok(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ fn eval(stack: &mut Vec<Symbol>) -> Result<bool, String> {
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(format!("missing argument after ‘{:?}’", op));
|
return Err(format!("missing argument after '{:?}'", op));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ fn eval(stack: &mut Vec<Symbol>) -> Result<bool, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn integers(a: &OsStr, b: &OsStr, op: &OsStr) -> Result<bool, String> {
|
fn integers(a: &OsStr, b: &OsStr, op: &OsStr) -> Result<bool, String> {
|
||||||
let format_err = |value| format!("invalid integer ‘{}’", value);
|
let format_err = |value| format!("invalid integer '{}'", value);
|
||||||
|
|
||||||
let a = a.to_string_lossy();
|
let a = a.to_string_lossy();
|
||||||
let a: i64 = a.parse().map_err(|_| format_err(a))?;
|
let a: i64 = a.parse().map_err(|_| format_err(a))?;
|
||||||
|
@ -156,7 +156,7 @@ fn integers(a: &OsStr, b: &OsStr, op: &OsStr) -> Result<bool, String> {
|
||||||
"-ge" => a >= b,
|
"-ge" => a >= b,
|
||||||
"-lt" => a < b,
|
"-lt" => a < b,
|
||||||
"-le" => a <= b,
|
"-le" => a <= b,
|
||||||
_ => return Err(format!("unknown operator ‘{}’", operator)),
|
_ => return Err(format!("unknown operator '{}'", operator)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ fn isatty(fd: &OsStr) -> Result<bool, String> {
|
||||||
let fd = fd.to_string_lossy();
|
let fd = fd.to_string_lossy();
|
||||||
|
|
||||||
fd.parse()
|
fd.parse()
|
||||||
.map_err(|_| format!("invalid integer ‘{}’", fd))
|
.map_err(|_| format!("invalid integer '{}'", fd))
|
||||||
.map(|i| {
|
.map(|i| {
|
||||||
#[cfg(not(target_os = "redox"))]
|
#[cfg(not(target_os = "redox"))]
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -311,7 +311,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
|
||||||
if !(delete_flag || squeeze_flag) && sets.len() < 2 {
|
if !(delete_flag || squeeze_flag) && sets.len() < 2 {
|
||||||
show_error!(
|
show_error!(
|
||||||
"missing operand after ‘{}’\nTry `{} --help` for more information.",
|
"missing operand after '{}'\nTry `{} --help` for more information.",
|
||||||
sets[0],
|
sets[0],
|
||||||
executable!()
|
executable!()
|
||||||
);
|
);
|
||||||
|
|
|
@ -210,7 +210,7 @@ fn truncate_reference_and_size(
|
||||||
let mode = match parse_mode_and_size(size_string) {
|
let mode = match parse_mode_and_size(size_string) {
|
||||||
Ok(m) => match m {
|
Ok(m) => match m {
|
||||||
TruncateMode::Absolute(_) => {
|
TruncateMode::Absolute(_) => {
|
||||||
crash!(1, "you must specify a relative ‘--size’ with ‘--reference’")
|
crash!(1, "you must specify a relative '--size' with '--reference'")
|
||||||
}
|
}
|
||||||
_ => m,
|
_ => m,
|
||||||
},
|
},
|
||||||
|
|
|
@ -300,7 +300,7 @@ fn idle_string<'a>(when: i64, boottime: i64) -> Cow<'a, str> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn time_string(ut: &Utmpx) -> String {
|
fn time_string(ut: &Utmpx) -> String {
|
||||||
time::strftime("%Y-%m-%d %H:%M", &ut.login_time()).unwrap()
|
time::strftime("%b %e %H:%M", &ut.login_time()).unwrap() // LC_ALL=C
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -523,8 +523,8 @@ impl Who {
|
||||||
buf.push_str(&msg);
|
buf.push_str(&msg);
|
||||||
}
|
}
|
||||||
buf.push_str(&format!(" {:<12}", line));
|
buf.push_str(&format!(" {:<12}", line));
|
||||||
// "%Y-%m-%d %H:%M"
|
// "%b %e %H:%M" (LC_ALL=C)
|
||||||
let time_size = 4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2;
|
let time_size = 3 + 2 + 2 + 1 + 2;
|
||||||
buf.push_str(&format!(" {:<1$}", time, time_size));
|
buf.push_str(&format!(" {:<1$}", time, time_size));
|
||||||
|
|
||||||
if !self.short_output {
|
if !self.short_output {
|
||||||
|
|
|
@ -18,7 +18,7 @@ use std::fmt;
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// Will return `ParseSizeError` if it’s not possible to parse this
|
/// Will return `ParseSizeError` if it's not possible to parse this
|
||||||
/// string into a number, e.g. if the string does not begin with a
|
/// string into a number, e.g. if the string does not begin with a
|
||||||
/// numeral, or if the unit is not one of the supported units described
|
/// numeral, or if the unit is not one of the supported units described
|
||||||
/// in the preceding section.
|
/// in the preceding section.
|
||||||
|
@ -109,19 +109,19 @@ impl fmt::Display for ParseSizeError {
|
||||||
|
|
||||||
impl ParseSizeError {
|
impl ParseSizeError {
|
||||||
fn parse_failure(s: &str) -> ParseSizeError {
|
fn parse_failure(s: &str) -> ParseSizeError {
|
||||||
// stderr on linux (GNU coreutils 8.32)
|
// stderr on linux (GNU coreutils 8.32) (LC_ALL=C)
|
||||||
// has to be handled in the respective uutils because strings differ, e.g.:
|
// has to be handled in the respective uutils because strings differ, e.g.:
|
||||||
//
|
//
|
||||||
// `NUM`
|
// `NUM`
|
||||||
// head: invalid number of bytes: ‘1fb’
|
// head: invalid number of bytes: '1fb'
|
||||||
// tail: invalid number of bytes: ‘1fb’
|
// tail: invalid number of bytes: '1fb'
|
||||||
//
|
//
|
||||||
// `SIZE`
|
// `SIZE`
|
||||||
// split: invalid number of bytes: ‘1fb’
|
// split: invalid number of bytes: '1fb'
|
||||||
// truncate: Invalid number: ‘1fb’
|
// truncate: Invalid number: '1fb'
|
||||||
//
|
//
|
||||||
// `MODE`
|
// `MODE`
|
||||||
// stdbuf: invalid mode ‘1fb’
|
// stdbuf: invalid mode '1fb'
|
||||||
//
|
//
|
||||||
// `SIZE`
|
// `SIZE`
|
||||||
// sort: invalid suffix in --buffer-size argument '1fb'
|
// sort: invalid suffix in --buffer-size argument '1fb'
|
||||||
|
@ -140,27 +140,27 @@ impl ParseSizeError {
|
||||||
// --width
|
// --width
|
||||||
// --strings
|
// --strings
|
||||||
// etc.
|
// etc.
|
||||||
ParseSizeError::ParseFailure(format!("‘{}’", s))
|
ParseSizeError::ParseFailure(format!("'{}'", s))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size_too_big(s: &str) -> ParseSizeError {
|
fn size_too_big(s: &str) -> ParseSizeError {
|
||||||
// stderr on linux (GNU coreutils 8.32)
|
// stderr on linux (GNU coreutils 8.32) (LC_ALL=C)
|
||||||
// has to be handled in the respective uutils because strings differ, e.g.:
|
// has to be handled in the respective uutils because strings differ, e.g.:
|
||||||
//
|
//
|
||||||
// head: invalid number of bytes: ‘1Y’: Value too large for defined data type
|
// head: invalid number of bytes: '1Y': Value too large for defined data type
|
||||||
// tail: invalid number of bytes: ‘1Y’: Value too large for defined data type
|
// tail: invalid number of bytes: '1Y': Value too large for defined data type
|
||||||
// split: invalid number of bytes: ‘1Y’: Value too large for defined data type
|
// split: invalid number of bytes: '1Y': Value too large for defined data type
|
||||||
// truncate: Invalid number: ‘1Y’: Value too large for defined data type
|
// truncate: Invalid number: '1Y': Value too large for defined data type
|
||||||
// stdbuf: invalid mode ‘1Y’: Value too large for defined data type
|
// stdbuf: invalid mode '1Y': Value too large for defined data type
|
||||||
// sort: -S argument '1Y' too large
|
// sort: -S argument '1Y' too large
|
||||||
// du: -B argument '1Y' too large
|
// du: -B argument '1Y' too large
|
||||||
// od: -N argument '1Y' too large
|
// od: -N argument '1Y' too large
|
||||||
// etc.
|
// etc.
|
||||||
//
|
//
|
||||||
// stderr on macos (brew - GNU coreutils 8.32) also differs for the same version, e.g.:
|
// stderr on macos (brew - GNU coreutils 8.32) also differs for the same version, e.g.:
|
||||||
// ghead: invalid number of bytes: ‘1Y’: Value too large to be stored in data type
|
// ghead: invalid number of bytes: '1Y': Value too large to be stored in data type
|
||||||
// gtail: invalid number of bytes: ‘1Y’: Value too large to be stored in data type
|
// gtail: invalid number of bytes: '1Y': Value too large to be stored in data type
|
||||||
ParseSizeError::SizeTooBig(format!("‘{}’: Value too large for defined data type", s))
|
ParseSizeError::SizeTooBig(format!("'{}': Value too large for defined data type", s))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ mod tests {
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ParseSizeError::SizeTooBig("‘1Y’: Value too large for defined data type".to_string()),
|
ParseSizeError::SizeTooBig("'1Y': Value too large for defined data type".to_string()),
|
||||||
parse_size("1Y").unwrap_err()
|
parse_size("1Y").unwrap_err()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ mod tests {
|
||||||
for &test_string in &test_strings {
|
for &test_string in &test_strings {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_size(test_string).unwrap_err(),
|
parse_size(test_string).unwrap_err(),
|
||||||
ParseSizeError::ParseFailure(format!("‘{}’", test_string))
|
ParseSizeError::ParseFailure(format!("'{}'", test_string))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ fn test_wrap_bad_arg() {
|
||||||
.arg(wrap_param)
|
.arg(wrap_param)
|
||||||
.arg("b")
|
.arg("b")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("base32: Invalid wrap size: ‘b’: invalid digit found in string\n");
|
.stderr_only("base32: Invalid wrap size: 'b': invalid digit found in string\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ fn test_base32_extra_operand() {
|
||||||
.arg("a.txt")
|
.arg("a.txt")
|
||||||
.arg("a.txt")
|
.arg("a.txt")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("base32: extra operand ‘a.txt’");
|
.stderr_only("base32: extra operand 'a.txt'");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -89,7 +89,7 @@ fn test_wrap_bad_arg() {
|
||||||
.arg(wrap_param)
|
.arg(wrap_param)
|
||||||
.arg("b")
|
.arg("b")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("base64: Invalid wrap size: ‘b’: invalid digit found in string\n");
|
.stderr_only("base64: Invalid wrap size: 'b': invalid digit found in string\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ fn test_base64_extra_operand() {
|
||||||
.arg("a.txt")
|
.arg("a.txt")
|
||||||
.arg("a.txt")
|
.arg("a.txt")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("base64: extra operand ‘a.txt’");
|
.stderr_only("base64: extra operand 'a.txt'");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -172,14 +172,14 @@ fn test_chown_only_colon() {
|
||||||
// expected:
|
// expected:
|
||||||
// $ chown -v :: file.txt 2>out_err ; echo $? ; cat out_err
|
// $ chown -v :: file.txt 2>out_err ; echo $? ; cat out_err
|
||||||
// 1
|
// 1
|
||||||
// chown: invalid group: ‘::’
|
// chown: invalid group: '::'
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg("::")
|
.arg("::")
|
||||||
.arg("--verbose")
|
.arg("--verbose")
|
||||||
.arg(file1)
|
.arg(file1)
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_contains(&"invalid group: ‘::’");
|
.stderr_contains(&"invalid group: '::'");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -117,7 +117,7 @@ fn test_date_format_without_plus() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("%s")
|
.arg("%s")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_contains("date: invalid date ‘%s’")
|
.stderr_contains("date: invalid date '%s'")
|
||||||
.code_is(1);
|
.code_is(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -355,7 +355,7 @@ fn test_du_no_permission() {
|
||||||
|
|
||||||
let result = scene.ucmd().arg(SUB_DIR_LINKS).run(); // TODO: replace with ".fails()" once `du` is fixed
|
let result = scene.ucmd().arg(SUB_DIR_LINKS).run(); // TODO: replace with ".fails()" once `du` is fixed
|
||||||
result.stderr_contains(
|
result.stderr_contains(
|
||||||
"du: cannot read directory ‘subdir/links‘: Permission denied (os error 13)",
|
"du: cannot read directory 'subdir/links': Permission denied (os error 13)",
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
|
|
@ -255,21 +255,21 @@ fn test_head_invalid_num() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-c", "1024R", "emptyfile.txt"])
|
.args(&["-c", "1024R", "emptyfile.txt"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("head: invalid number of bytes: ‘1024R’");
|
.stderr_is("head: invalid number of bytes: '1024R'");
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-n", "1024R", "emptyfile.txt"])
|
.args(&["-n", "1024R", "emptyfile.txt"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("head: invalid number of lines: ‘1024R’");
|
.stderr_is("head: invalid number of lines: '1024R'");
|
||||||
#[cfg(not(target_pointer_width = "128"))]
|
#[cfg(not(target_pointer_width = "128"))]
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-c", "1Y", "emptyfile.txt"])
|
.args(&["-c", "1Y", "emptyfile.txt"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("head: invalid number of bytes: ‘1Y’: Value too large for defined data type");
|
.stderr_is("head: invalid number of bytes: '1Y': Value too large for defined data type");
|
||||||
#[cfg(not(target_pointer_width = "128"))]
|
#[cfg(not(target_pointer_width = "128"))]
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-n", "1Y", "emptyfile.txt"])
|
.args(&["-n", "1Y", "emptyfile.txt"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("head: invalid number of lines: ‘1Y’: Value too large for defined data type");
|
.stderr_is("head: invalid number of lines: '1Y': Value too large for defined data type");
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
{
|
{
|
||||||
let sizes = ["1000G", "10T"];
|
let sizes = ["1000G", "10T"];
|
||||||
|
@ -279,7 +279,7 @@ fn test_head_invalid_num() {
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only(format!(
|
.stderr_only(format!(
|
||||||
"head: invalid number of bytes: ‘{}’: Value too large for defined data type",
|
"head: invalid number of bytes: '{}': Value too large for defined data type",
|
||||||
size
|
size
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -432,7 +432,7 @@ fn check_coreutil_version(util_name: &str, version_expected: &str) -> String {
|
||||||
let scene = TestScenario::new(util_name);
|
let scene = TestScenario::new(util_name);
|
||||||
let version_check = scene
|
let version_check = scene
|
||||||
.cmd_keepenv(&util_name)
|
.cmd_keepenv(&util_name)
|
||||||
.env("LANGUAGE", "C")
|
.env("LC_ALL", "C")
|
||||||
.arg("--version")
|
.arg("--version")
|
||||||
.run();
|
.run();
|
||||||
version_check
|
version_check
|
||||||
|
@ -476,7 +476,7 @@ fn expected_result(args: &[&str]) -> Result<CmdResult, String> {
|
||||||
let scene = TestScenario::new(util_name);
|
let scene = TestScenario::new(util_name);
|
||||||
let result = scene
|
let result = scene
|
||||||
.cmd_keepenv(util_name)
|
.cmd_keepenv(util_name)
|
||||||
.env("LANGUAGE", "C")
|
.env("LC_ALL", "C")
|
||||||
.args(args)
|
.args(args)
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ fn test_ls_width() {
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.args(&option.split(' ').collect::<Vec<_>>())
|
.args(&option.split(' ').collect::<Vec<_>>())
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("ls: invalid line width: ‘1a’");
|
.stderr_only("ls: invalid line width: '1a'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -614,7 +614,7 @@ fn test_mv_overwrite_nonempty_dir() {
|
||||||
// Not same error as GNU; the error message is a rust builtin
|
// Not same error as GNU; the error message is a rust builtin
|
||||||
// TODO: test (and implement) correct error message (or at least decide whether to do so)
|
// TODO: test (and implement) correct error message (or at least decide whether to do so)
|
||||||
// Current: "mv: couldn't rename path (Directory not empty; from=a; to=b)"
|
// Current: "mv: couldn't rename path (Directory not empty; from=a; to=b)"
|
||||||
// GNU: "mv: cannot move ‘a’ to ‘b’: Directory not empty"
|
// GNU: "mv: cannot move 'a' to 'b': Directory not empty"
|
||||||
|
|
||||||
// Verbose output for the move should not be shown on failure
|
// Verbose output for the move should not be shown on failure
|
||||||
let result = ucmd.arg("-vT").arg(dir_a).arg(dir_b).fails();
|
let result = ucmd.arg("-vT").arg(dir_a).arg(dir_b).fails();
|
||||||
|
@ -638,7 +638,7 @@ fn test_mv_backup_dir() {
|
||||||
.arg(dir_b)
|
.arg(dir_b)
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_only(format!(
|
.stdout_only(format!(
|
||||||
"‘{}’ -> ‘{}’ (backup: ‘{}~’)\n",
|
"'{}' -> '{}' (backup: '{}~')\n",
|
||||||
dir_a, dir_b, dir_b
|
dir_a, dir_b, dir_b
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -672,7 +672,7 @@ fn test_mv_errors() {
|
||||||
|
|
||||||
// $ at.touch file && at.mkdir dir
|
// $ at.touch file && at.mkdir dir
|
||||||
// $ mv -T file dir
|
// $ mv -T file dir
|
||||||
// err == mv: cannot overwrite directory ‘dir’ with non-directory
|
// err == mv: cannot overwrite directory 'dir' with non-directory
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg("-T")
|
.arg("-T")
|
||||||
|
@ -680,13 +680,13 @@ fn test_mv_errors() {
|
||||||
.arg(dir)
|
.arg(dir)
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is(format!(
|
.stderr_is(format!(
|
||||||
"mv: cannot overwrite directory ‘{}’ with non-directory\n",
|
"mv: cannot overwrite directory '{}' with non-directory\n",
|
||||||
dir
|
dir
|
||||||
));
|
));
|
||||||
|
|
||||||
// $ at.mkdir dir && at.touch file
|
// $ at.mkdir dir && at.touch file
|
||||||
// $ mv dir file
|
// $ mv dir file
|
||||||
// err == mv: cannot overwrite non-directory ‘file’ with directory ‘dir’
|
// err == mv: cannot overwrite non-directory 'file' with directory 'dir'
|
||||||
assert!(!scene
|
assert!(!scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg(dir)
|
.arg(dir)
|
||||||
|
@ -713,7 +713,7 @@ fn test_mv_verbose() {
|
||||||
.arg(file_a)
|
.arg(file_a)
|
||||||
.arg(file_b)
|
.arg(file_b)
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_only(format!("‘{}’ -> ‘{}’\n", file_a, file_b));
|
.stdout_only(format!("'{}' -> '{}'\n", file_a, file_b));
|
||||||
|
|
||||||
at.touch(file_a);
|
at.touch(file_a);
|
||||||
scene
|
scene
|
||||||
|
@ -723,7 +723,7 @@ fn test_mv_verbose() {
|
||||||
.arg(file_b)
|
.arg(file_b)
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_only(format!(
|
.stdout_only(format!(
|
||||||
"‘{}’ -> ‘{}’ (backup: ‘{}~’)\n",
|
"'{}' -> '{}' (backup: '{}~')\n",
|
||||||
file_a, file_b, file_b
|
file_a, file_b, file_b
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -756,5 +756,5 @@ fn test_mv_permission_error() {
|
||||||
// -r--r--r-- 1 user user 0 okt 25 11:21 b
|
// -r--r--r-- 1 user user 0 okt 25 11:21 b
|
||||||
// $
|
// $
|
||||||
// $ mv -v a b
|
// $ mv -v a b
|
||||||
// mv: try to overwrite ‘b’, overriding mode 0444 (r--r--r--)? y
|
// mv: try to overwrite 'b', overriding mode 0444 (r--r--r--)? y
|
||||||
// ‘a’ -> ‘b’
|
// 'a' -> 'b'
|
||||||
|
|
|
@ -35,7 +35,7 @@ fn test_from_iec_i_requires_suffix() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--from=iec-i", "1024"])
|
.args(&["--from=iec-i", "1024"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("numfmt: missing 'i' suffix in input: ‘1024’ (e.g Ki/Mi/Gi)");
|
.stderr_is("numfmt: missing 'i' suffix in input: '1024' (e.g Ki/Mi/Gi)");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -123,7 +123,7 @@ fn test_header_error_if_non_numeric() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--header=two"])
|
.args(&["--header=two"])
|
||||||
.run()
|
.run()
|
||||||
.stderr_is("numfmt: invalid header value ‘two’");
|
.stderr_is("numfmt: invalid header value 'two'");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -131,7 +131,7 @@ fn test_header_error_if_0() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--header=0"])
|
.args(&["--header=0"])
|
||||||
.run()
|
.run()
|
||||||
.stderr_is("numfmt: invalid header value ‘0’");
|
.stderr_is("numfmt: invalid header value '0'");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -139,7 +139,7 @@ fn test_header_error_if_negative() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--header=-3"])
|
.args(&["--header=-3"])
|
||||||
.run()
|
.run()
|
||||||
.stderr_is("numfmt: invalid header value ‘-3’");
|
.stderr_is("numfmt: invalid header value '-3'");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -187,7 +187,7 @@ fn test_should_report_invalid_empty_number_on_empty_stdin() {
|
||||||
.args(&["--from=auto"])
|
.args(&["--from=auto"])
|
||||||
.pipe_in("\n")
|
.pipe_in("\n")
|
||||||
.run()
|
.run()
|
||||||
.stderr_is("numfmt: invalid number: ‘’\n");
|
.stderr_is("numfmt: invalid number: ''\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -196,7 +196,7 @@ fn test_should_report_invalid_empty_number_on_blank_stdin() {
|
||||||
.args(&["--from=auto"])
|
.args(&["--from=auto"])
|
||||||
.pipe_in(" \t \n")
|
.pipe_in(" \t \n")
|
||||||
.run()
|
.run()
|
||||||
.stderr_is("numfmt: invalid number: ‘’\n");
|
.stderr_is("numfmt: invalid number: ''\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -205,14 +205,14 @@ fn test_should_report_invalid_suffix_on_stdin() {
|
||||||
.args(&["--from=auto"])
|
.args(&["--from=auto"])
|
||||||
.pipe_in("1k")
|
.pipe_in("1k")
|
||||||
.run()
|
.run()
|
||||||
.stderr_is("numfmt: invalid suffix in input: ‘1k’\n");
|
.stderr_is("numfmt: invalid suffix in input: '1k'\n");
|
||||||
|
|
||||||
// GNU numfmt reports this one as “invalid number”
|
// GNU numfmt reports this one as “invalid number”
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--from=auto"])
|
.args(&["--from=auto"])
|
||||||
.pipe_in("NaN")
|
.pipe_in("NaN")
|
||||||
.run()
|
.run()
|
||||||
.stderr_is("numfmt: invalid suffix in input: ‘NaN’\n");
|
.stderr_is("numfmt: invalid suffix in input: 'NaN'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -222,7 +222,7 @@ fn test_should_report_invalid_number_with_interior_junk() {
|
||||||
.args(&["--from=auto"])
|
.args(&["--from=auto"])
|
||||||
.pipe_in("1x0K")
|
.pipe_in("1x0K")
|
||||||
.run()
|
.run()
|
||||||
.stderr_is("numfmt: invalid number: ‘1x0K’\n");
|
.stderr_is("numfmt: invalid number: '1x0K'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -461,7 +461,7 @@ fn test_delimiter_overrides_whitespace_separator() {
|
||||||
.args(&["-d,"])
|
.args(&["-d,"])
|
||||||
.pipe_in("1 234,56")
|
.pipe_in("1 234,56")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("numfmt: invalid number: ‘1 234’\n");
|
.stderr_is("numfmt: invalid number: '1 234'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -106,7 +106,7 @@ fn expected_result(args: &[&str]) -> String {
|
||||||
#[allow(clippy::needless_borrow)]
|
#[allow(clippy::needless_borrow)]
|
||||||
TestScenario::new(&util_name)
|
TestScenario::new(&util_name)
|
||||||
.cmd_keepenv(util_name)
|
.cmd_keepenv(util_name)
|
||||||
.env("LANGUAGE", "C")
|
.env("LC_ALL", "C")
|
||||||
.args(args)
|
.args(args)
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_move_str()
|
.stdout_move_str()
|
||||||
|
|
|
@ -309,7 +309,7 @@ fn test_split_lines_number() {
|
||||||
.args(&["--lines", "2fb", "file"])
|
.args(&["--lines", "2fb", "file"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only("split: invalid number of lines: ‘2fb’");
|
.stderr_only("split: invalid number of lines: '2fb'");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -318,13 +318,13 @@ fn test_split_invalid_bytes_size() {
|
||||||
.args(&["-b", "1024R"])
|
.args(&["-b", "1024R"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only("split: invalid number of bytes: ‘1024R’");
|
.stderr_only("split: invalid number of bytes: '1024R'");
|
||||||
#[cfg(not(target_pointer_width = "128"))]
|
#[cfg(not(target_pointer_width = "128"))]
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-b", "1Y"])
|
.args(&["-b", "1Y"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only("split: invalid number of bytes: ‘1Y’: Value too large for defined data type");
|
.stderr_only("split: invalid number of bytes: '1Y': Value too large for defined data type");
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
{
|
{
|
||||||
let sizes = ["1000G", "10T"];
|
let sizes = ["1000G", "10T"];
|
||||||
|
@ -334,7 +334,7 @@ fn test_split_invalid_bytes_size() {
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only(format!(
|
.stderr_only(format!(
|
||||||
"split: invalid number of bytes: ‘{}’: Value too large for defined data type",
|
"split: invalid number of bytes: '{}': Value too large for defined data type",
|
||||||
size
|
size
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,7 +317,7 @@ fn expected_result(args: &[&str]) -> String {
|
||||||
#[allow(clippy::needless_borrow)]
|
#[allow(clippy::needless_borrow)]
|
||||||
TestScenario::new(&util_name)
|
TestScenario::new(&util_name)
|
||||||
.cmd_keepenv(util_name)
|
.cmd_keepenv(util_name)
|
||||||
.env("LANGUAGE", "C")
|
.env("LC_ALL", "C")
|
||||||
.args(args)
|
.args(args)
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_move_str()
|
.stdout_move_str()
|
||||||
|
|
|
@ -63,12 +63,12 @@ fn test_stdbuf_invalid_mode_fails() {
|
||||||
.args(&[*option, "1024R", "head"])
|
.args(&[*option, "1024R", "head"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(125)
|
.code_is(125)
|
||||||
.stderr_only("stdbuf: invalid mode ‘1024R’");
|
.stderr_only("stdbuf: invalid mode '1024R'");
|
||||||
#[cfg(not(target_pointer_width = "128"))]
|
#[cfg(not(target_pointer_width = "128"))]
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&[*option, "1Y", "head"])
|
.args(&[*option, "1Y", "head"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(125)
|
.code_is(125)
|
||||||
.stderr_contains("stdbuf: invalid mode ‘1Y’: Value too large for defined data type");
|
.stderr_contains("stdbuf: invalid mode '1Y': Value too large for defined data type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -364,21 +364,21 @@ fn test_tail_invalid_num() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-c", "1024R", "emptyfile.txt"])
|
.args(&["-c", "1024R", "emptyfile.txt"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("tail: invalid number of bytes: ‘1024R’");
|
.stderr_is("tail: invalid number of bytes: '1024R'");
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-n", "1024R", "emptyfile.txt"])
|
.args(&["-n", "1024R", "emptyfile.txt"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("tail: invalid number of lines: ‘1024R’");
|
.stderr_is("tail: invalid number of lines: '1024R'");
|
||||||
#[cfg(not(target_pointer_width = "128"))]
|
#[cfg(not(target_pointer_width = "128"))]
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-c", "1Y", "emptyfile.txt"])
|
.args(&["-c", "1Y", "emptyfile.txt"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("tail: invalid number of bytes: ‘1Y’: Value too large for defined data type");
|
.stderr_is("tail: invalid number of bytes: '1Y': Value too large for defined data type");
|
||||||
#[cfg(not(target_pointer_width = "128"))]
|
#[cfg(not(target_pointer_width = "128"))]
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-n", "1Y", "emptyfile.txt"])
|
.args(&["-n", "1Y", "emptyfile.txt"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("tail: invalid number of lines: ‘1Y’: Value too large for defined data type");
|
.stderr_is("tail: invalid number of lines: '1Y': Value too large for defined data type");
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
{
|
{
|
||||||
let sizes = ["1000G", "10T"];
|
let sizes = ["1000G", "10T"];
|
||||||
|
@ -388,7 +388,7 @@ fn test_tail_invalid_num() {
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only(format!(
|
.stderr_only(format!(
|
||||||
"tail: invalid number of bytes: ‘{}’: Value too large for defined data type",
|
"tail: invalid number of bytes: '{}': Value too large for defined data type",
|
||||||
size
|
size
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,7 @@ fn test_dangling_string_comparison_is_error() {
|
||||||
.args(&["missing_something", "="])
|
.args(&["missing_something", "="])
|
||||||
.run()
|
.run()
|
||||||
.status_code(2)
|
.status_code(2)
|
||||||
.stderr_is("test: missing argument after ‘=’");
|
.stderr_is("test: missing argument after '='");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -265,7 +265,7 @@ fn test_float_inequality_is_error() {
|
||||||
.args(&["123.45", "-ge", "6"])
|
.args(&["123.45", "-ge", "6"])
|
||||||
.run()
|
.run()
|
||||||
.status_code(2)
|
.status_code(2)
|
||||||
.stderr_is("test: invalid integer ‘123.45’");
|
.stderr_is("test: invalid integer '123.45'");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -283,7 +283,7 @@ fn test_invalid_utf8_integer_compare() {
|
||||||
|
|
||||||
cmd.run()
|
cmd.run()
|
||||||
.status_code(2)
|
.status_code(2)
|
||||||
.stderr_is("test: invalid integer ‘fo<EFBFBD>o’");
|
.stderr_is("test: invalid integer 'fo<66>o'");
|
||||||
|
|
||||||
let mut cmd = new_ucmd!();
|
let mut cmd = new_ucmd!();
|
||||||
cmd.raw.arg(arg);
|
cmd.raw.arg(arg);
|
||||||
|
@ -291,7 +291,7 @@ fn test_invalid_utf8_integer_compare() {
|
||||||
|
|
||||||
cmd.run()
|
cmd.run()
|
||||||
.status_code(2)
|
.status_code(2)
|
||||||
.stderr_is("test: invalid integer ‘fo<EFBFBD>o’");
|
.stderr_is("test: invalid integer 'fo<66>o'");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -674,7 +674,7 @@ fn test_erroneous_parenthesized_expression() {
|
||||||
.args(&["a", "!=", "(", "b", "-a", "b", ")", "!=", "c"])
|
.args(&["a", "!=", "(", "b", "-a", "b", ")", "!=", "c"])
|
||||||
.run()
|
.run()
|
||||||
.status_code(2)
|
.status_code(2)
|
||||||
.stderr_is("test: extra argument ‘b’");
|
.stderr_is("test: extra argument 'b'");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -249,7 +249,7 @@ fn test_size_and_reference() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_error_filename_only() {
|
fn test_error_filename_only() {
|
||||||
// truncate: you must specify either ‘--size’ or ‘--reference’
|
// truncate: you must specify either '--size' or '--reference'
|
||||||
new_ucmd!().args(&["file"]).fails().stderr_contains(
|
new_ucmd!().args(&["file"]).fails().stderr_contains(
|
||||||
"error: The following required arguments were not provided:
|
"error: The following required arguments were not provided:
|
||||||
--reference <RFILE>
|
--reference <RFILE>
|
||||||
|
@ -262,15 +262,15 @@ fn test_invalid_numbers() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-s", "0X", "file"])
|
.args(&["-s", "0X", "file"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_contains("Invalid number: ‘0X’");
|
.stderr_contains("Invalid number: '0X'");
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-s", "0XB", "file"])
|
.args(&["-s", "0XB", "file"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_contains("Invalid number: ‘0XB’");
|
.stderr_contains("Invalid number: '0XB'");
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-s", "0B", "file"])
|
.args(&["-s", "0B", "file"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_contains("Invalid number: ‘0B’");
|
.stderr_contains("Invalid number: '0B'");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -299,13 +299,13 @@ fn test_truncate_bytes_size() {
|
||||||
.args(&["--size", "1024R", "file"])
|
.args(&["--size", "1024R", "file"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only("truncate: Invalid number: ‘1024R’");
|
.stderr_only("truncate: Invalid number: '1024R'");
|
||||||
#[cfg(not(target_pointer_width = "128"))]
|
#[cfg(not(target_pointer_width = "128"))]
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--size", "1Y", "file"])
|
.args(&["--size", "1Y", "file"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only("truncate: Invalid number: ‘1Y’: Value too large for defined data type");
|
.stderr_only("truncate: Invalid number: '1Y': Value too large for defined data type");
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
{
|
{
|
||||||
let sizes = ["1000G", "10T"];
|
let sizes = ["1000G", "10T"];
|
||||||
|
@ -315,7 +315,7 @@ fn test_truncate_bytes_size() {
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only(format!(
|
.stderr_only(format!(
|
||||||
"truncate: Invalid number: ‘{}’: Value too large for defined data type",
|
"truncate: Invalid number: '{}': Value too large for defined data type",
|
||||||
size
|
size
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ fn test_users_check_name() {
|
||||||
#[allow(clippy::needless_borrow)]
|
#[allow(clippy::needless_borrow)]
|
||||||
let expected = TestScenario::new(&util_name)
|
let expected = TestScenario::new(&util_name)
|
||||||
.cmd_keepenv(util_name)
|
.cmd_keepenv(util_name)
|
||||||
.env("LANGUAGE", "C")
|
.env("LC_ALL", "C")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_move_str();
|
.stdout_move_str();
|
||||||
|
|
||||||
|
|
|
@ -158,13 +158,12 @@ fn test_users() {
|
||||||
let mut v_actual: Vec<&str> = actual.split_whitespace().collect();
|
let mut v_actual: Vec<&str> = actual.split_whitespace().collect();
|
||||||
let mut v_expect: Vec<&str> = expect.split_whitespace().collect();
|
let mut v_expect: Vec<&str> = expect.split_whitespace().collect();
|
||||||
|
|
||||||
// TODO: `--users` differs from GNU's output on macOS
|
// TODO: `--users` sometimes differs from GNU's output on macOS (race condition?)
|
||||||
// Diff < left / right > :
|
// actual: "runner console Jun 23 06:37 00:34 196\n"
|
||||||
// <"runner console 2021-05-20 22:03 00:08 196\n"
|
// expect: "runner console Jun 23 06:37 old 196\n"
|
||||||
// >"runner console 2021-05-20 22:03 old 196\n"
|
|
||||||
if cfg!(target_os = "macos") {
|
if cfg!(target_os = "macos") {
|
||||||
v_actual.remove(4);
|
v_actual.remove(5);
|
||||||
v_expect.remove(4);
|
v_expect.remove(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(v_actual, v_expect);
|
assert_eq!(v_actual, v_expect);
|
||||||
|
@ -242,7 +241,7 @@ fn expected_result(args: &[&str]) -> String {
|
||||||
#[allow(clippy::needless_borrow)]
|
#[allow(clippy::needless_borrow)]
|
||||||
TestScenario::new(&util_name)
|
TestScenario::new(&util_name)
|
||||||
.cmd_keepenv(util_name)
|
.cmd_keepenv(util_name)
|
||||||
.env("LANGUAGE", "C")
|
.env("LC_ALL", "C")
|
||||||
.args(args)
|
.args(args)
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_move_str()
|
.stdout_move_str()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue