mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
seq: trim leading whitespace from inputs
This commit is contained in:
parent
e9d63519dd
commit
60025800c3
2 changed files with 25 additions and 0 deletions
|
@ -99,6 +99,7 @@ impl Number {
|
|||
impl FromStr for Number {
|
||||
type Err = String;
|
||||
fn from_str(mut s: &str) -> Result<Self, Self::Err> {
|
||||
s = s.trim_start();
|
||||
if s.starts_with('+') {
|
||||
s = &s[1..];
|
||||
}
|
||||
|
|
|
@ -200,3 +200,27 @@ fn test_neg_inf() {
|
|||
fn test_inf() {
|
||||
run(&["inf"], b"1\n2\n3\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ignore_leading_whitespace() {
|
||||
new_ucmd!()
|
||||
.arg(" 1")
|
||||
.succeeds()
|
||||
.stdout_is("1\n")
|
||||
.no_stderr();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_trailing_whitespace_error() {
|
||||
// In some locales, the GNU error message has curly quotes (‘)
|
||||
// instead of straight quotes ('). We just test the straight single
|
||||
// quotes.
|
||||
new_ucmd!()
|
||||
.arg("1 ")
|
||||
.fails()
|
||||
.no_stdout()
|
||||
.stderr_contains("seq: invalid floating point argument: '1 '")
|
||||
// FIXME The second line of the error message is "Try 'seq
|
||||
// --help' for more information."
|
||||
.stderr_contains("for more information.");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue