mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
tr
should error out when if user provides more than 2 sets
Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>
This commit is contained in:
parent
2177b8dc37
commit
db79b5abb2
1 changed files with 11 additions and 2 deletions
|
@ -235,7 +235,7 @@ fn get_usage() -> String {
|
|||
}
|
||||
|
||||
fn get_long_usage() -> String {
|
||||
String::from(
|
||||
format!(
|
||||
"Translate, squeeze, and/or delete characters from standard input,
|
||||
writing to standard output.",
|
||||
)
|
||||
|
@ -259,7 +259,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
|||
let squeeze_flag = matches.is_present(options::SQUEEZE);
|
||||
let truncate_flag = matches.is_present(options::TRUNCATE);
|
||||
|
||||
let sets: Vec<String> = match matches.values_of(options::SETS) {
|
||||
let sets = match matches.values_of(options::SETS) {
|
||||
Some(v) => v.map(|v| v.to_string()).collect(),
|
||||
None => vec![],
|
||||
};
|
||||
|
@ -281,6 +281,15 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
|||
return 1;
|
||||
}
|
||||
|
||||
if sets.len() > 2 {
|
||||
show_error!(
|
||||
"extra operand '{}'\nTry `{} --help` for more information.",
|
||||
sets[2],
|
||||
executable!()
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
let stdin = stdin();
|
||||
let mut locked_stdin = stdin.lock();
|
||||
let stdout = stdout();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue