Repository navigation
date: treat empty --file lines as midnight today like GNU - #14673
Open
Dummy-pixel-hash wants to merge 2 commits into
Open
Dummy-pixel-hash wants to merge 2 commits into
Dummy-pixel-hash wants to merge 2 commits into
Conversation
Empty, whitespace-only, and lone "-" lines in --file/stdin input printed the current time instead of midnight. Normalize them to midnight, mirroring the existing -d handling. Fixes uutils#14498.
|
GNU testsuite comparison: |
sylvestre
reviewed
Nov 14, 2026
| Ok(s) => parse_date(s, now, dbg_opts, allow_extended), | ||
| Ok(s) => { | ||
| let trimmed = s.trim(); | ||
| if trimmed.is_empty() || trimmed == "-" { |
Contributor
There was a problem hiding this comment.
this duplicates the -d logic around line 493, could we share it?
the -d path also handles j and prints the --debug midnight warning, which we lose here
|
|
||
| /// Midnight at the start of `now`'s civil date, in its time zone. | ||
| /// | ||
| /// Empty (whitespace-only or lone `-`) lines in `--file`/stdin input mean |
Contributor
There was a problem hiding this comment.
the doc comment repeats the one at the call site, please keep only the first line
| fn test_date_file_empty_lines_are_midnight() { | ||
| // Empty, whitespace-only, and lone `-` lines mean midnight today, | ||
| // like GNU, not the current time (#14498). | ||
| let (at, mut ucmd) = at_and_ucmd!(); |
Contributor
There was a problem hiding this comment.
could you please add a j line and a --debug case too?
| } | ||
|
|
||
| #[test] | ||
| fn test_date_file_empty_lines_are_midnight() { |
Contributor
There was a problem hiding this comment.
did you check this with the GNU test suite?
bash util/build-gnu.sh && bash util/run-gnu-test.sh tests/date/date.pl
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14498.
Empty, whitespace-only, and lone
-lines in--file/stdin input printed the current time; GNU treats them as midnight today. This normalizes such lines to midnight, mirroring the existing-dhandling.