mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 21:55:40 +08:00

POSIX's `head` specification states: "The application shall ensure that the number option-argument is a positive decimal integer" Negative values are supported on GNU `head`, so this works in the discourse docker image. However, in some environments (e.g. macOS), the system `head` version fails with a negative `n` parameter. This commit does two things: Checks the status at each stage of the pipe, so it cannot fail silently Flip the `ls` command to list in descending time order, and use `tail -n +501` instead of `head -n -500`. The visible result is that macOS users no longer see head: illegal line count -- -500 printed throughout the test suite.