Diff Detail
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 39858 Build 36747: arc lint + arc unit
Event Timeline
tail/tail.c | ||
---|---|---|
214 | Might be better to do that in a separate review. |
What version of FreeBSD are you using there? For me, it doesn't work on 14-CURRENT without these changes.
I should clarify, tail works, but tail -f doesn't. That is, tail -f returns the last few lines of the file and exits. With this change, tail -f continues running and also shows any new lines added to the end of the file.
Sorry for taking a while to get to this. I wrote a regression test for this and a few related things: https://reviews.freebsd.org/D31055
usr.bin/tail/tail.c | ||
---|---|---|
274 ↗ | (On Diff #91617) | file doesn't need to be dynamically allocated, it can live on the stack. In fact, by marking the file_name field const, we can eliminate all of the strdup calls too. |
281 ↗ | (On Diff #91617) | There's no need to call forward() if we're also calling follow(). I think it should basically look like this: if (rflag) { reverse(); } else if (fflag) { file.file_name = strdup(fn); if (file.file_name == NULL) err(); file.fp = stdin; follow() } else { forward(); } |
Thanks for the review and writing the test! I've made the change to only call foward() if we're not calling follow().
Changing file_name to const makes sense, but seems like a larger change, could we perhaps do that in a separate commit, just for clarity?
Ok. I still think we should not be malloc()ing file in this change though. Other than that and the inline comment, the change looks good to me.
usr.bin/tail/tail.c | ||
---|---|---|
272 ↗ | (On Diff #91971) | You can reduce the indentation here, else if (fflag) {. |
I tried several different ways but can't quite seem to find a way to make this work without the malloc(). It seems that changing file_name to const requires changes elsewhere, and even making a const file_info_t sfile and passing that to follow() runs into issues. I must be missing something.