Skip to content

last: show the first record's time in "begins" when -n, --since or --until skip records - #673

Merged
sylvestre merged 1 commit into
uutils:mainfrom
jayhemnani9910:last-begins-first-record
Oct 24, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
jayhemnani9910:last-begins-first-record

Conversation

@jayhemnani9910

@jayhemnani9910 jayhemnani9910 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

The "begins" line is set only when the loop reaches the oldest record. When -n, --since or --until skips it, last prints the file's ctime instead. util-linux 2.41.3 always prints the first record's time:

$ last -f tests/fixtures/last/last.input.1 --since "2025-03-08 16:28"
util-linux 2.41.3:  last.input.1 begins Sat Mar  8 16:24:36 2025
uutils:             last.input.1 begins Wed Oct 21 18:56:18 2026   (ctime of the file)

The time now comes from the first record in the file, before any filtering. An empty file still falls back to the ctime.

test_since_only_shows_entries_after_time checked that "16:24" appears nowhere in the output. That held only because of this bug: the correct "begins" line is Sat Mar 8 16:24:36 2025, as util-linux prints it. The test now checks the entry lines only.

New test test_begins_is_the_first_record_when_records_are_skipped (-n 1 and --since) fails without the change. cargo test for the tools that build here (all but lsipc, lslocks and lsns, which need libsmartcols): 233 passed. With TZ=UTC, the "begins" line matches util-linux 2.41.3 for -n 1, --since and no options.

Copilot AI balanced review requested due to automatic review settings October 22, 2026 05:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@sylvestre
sylvestre merged commit a8beacc into uutils:main Oct 24, 2026
14 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants