Repository navigation
mode: reject empty clauses and bare numeric modes in a list - #15373
ozenyunus35 wants to merge 1 commit into
Conversation
Merging this PR will degrade performance by 0.42%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | factor_five_38_bit_primes |
1.8 s | 1.9 s | -8.17% |
| ❌ | Simulation | factor_thirteen_39_bit_primes |
8.7 s | 9 s | -3.63% |
| ⚡ | Simulation | factor_three_39_bit_primes |
800.7 ms | 717.6 ms | +11.58% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing ozenyunus35:mkdir-invalid-mode-message (cdd1a1a) with main (2fb77e8)
Footnotes
-
70 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
Closing this, as I can't follow up on it further. Thanks for the reviews. |
Part of #15254 (the
mkdir -m 1,2andmkdir --mo=1,2rows).The mode parser skipped empty comma-separated clauses and accepted a numeric mode without an operator anywhere in a list, so
mkdir -m 1,2,mkdir -m 'u+x,'orchmod 644,u+x fsucceeded. GNU coreutils 9.12 rejects all of these with "invalid mode":u+x,/,u+x/u+r,,g+w/,chmod:invalid mode ())644,u+x/u+x,644/1,2=644,u+x/u+x,+644/=,u+x/+,-A new
uucore::mode::check_clausechecks each clause: it can't be empty, and a numeric mode without an operator has to be the whole mode.parse_chmod(used bymkdir,mkfifo,mknodand, throughparse,install) and the clause loop inchmodboth call it. Forchmod, the message now names the whole mode, e.g.invalid mode (u+x,)instead ofinvalid mode ().A few
mode.rsunit tests asserted the old behavior (parse("644,u+x"),parse("u+w,755"),parse(",,")andparse("")succeeding). GNU rejects those, so they now use=644,.../...,=755, and the empty cases moved totest_parse_empty_clauses, which expects an error.Tests:
test_mkdir_mode_rejects_empty_and_bare_numeric_clauses,test_chmod_rejects_empty_and_bare_numeric_clauses(both fail without the change) andtest_chmod_numeric_mode_with_operator_in_a_list. Thechmod,mkdir,mkfifo,mknodandinstalltests and the uucoremodeunit tests pass.Not changed here: GNU also rejects spaces around clauses (
' u+x','u+rw, g+rw'), whichparse_chmodstill trims.I used an AI assistant to help draft parts of the code and tests; I reviewed the changes and ran the tests myself.