Thanks for the submission.
I'm not thrilled by the outcome style-wise, but given the starting point, I fully agree with you that it'll way too large to go further.
Two remarks though:
The commit message should read: "programs/cmd: Cleanup DIR /O logic."
(without the quotes) we want to trace which module is addressed by the change, and commit line should be terminated by a '.'
Content-wise, we definitively need to embed the tests (as the ones I posted above) inside the merge request in order to detect potential further regressions. This means the MR shall contain two patches:
* first patch in MR: the tests (marked with @todo_wine@ for the failing ones), * the second patch in MR: basically your current patch + removal of @todo_wine@ that now pass.
Either you feel up to do it (feel free to use the patch of tests above); if not, I can repackage your patch into the desired form.