Skip to content

mode: reject empty clauses and bare numeric modes in a list - #15373

Closed
ozenyunus35 wants to merge 1 commit into
uutils:mainfrom
ozenyunus35:mkdir-invalid-mode-message
Closed

ozenyunus35 wants to merge 1 commit into
uutils:mainfrom
ozenyunus35:mkdir-invalid-mode-message

Conversation

@ozenyunus35

Copy link
Copy Markdown
Contributor

Part of #15254 (the mkdir -m 1,2 and mkdir --mo=1,2 rows).

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,' or chmod 644,u+x f succeeded. GNU coreutils 9.12 rejects all of these with "invalid mode":

mode GNU before
u+x, / ,u+x / u+r,,g+w / , invalid accepted (chmod: invalid mode ())
644,u+x / u+x,644 / 1,2 invalid accepted
=644,u+x / u+x,+644 / =,u+x / +,- accepted accepted

A new uucore::mode::check_clause checks each clause: it can't be empty, and a numeric mode without an operator has to be the whole mode. parse_chmod (used by mkdir, mkfifo, mknod and, through parse, install) and the clause loop in chmod both call it. For chmod, the message now names the whole mode, e.g. invalid mode (u+x,) instead of invalid mode ().

A few mode.rs unit tests asserted the old behavior (parse("644,u+x"), parse("u+w,755"), parse(",,") and parse("") succeeding). GNU rejects those, so they now use =644,... / ...,=755, and the empty cases moved to test_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) and test_chmod_numeric_mode_with_operator_in_a_list. The chmod, mkdir, mkfifo, mknod and install tests and the uucore mode unit tests pass.

Not changed here: GNU also rejects spaces around clauses (' u+x', 'u+rw, g+rw'), which parse_chmod still trims.

I used an AI assistant to help draft parts of the code and tests; I reviewed the changes and ran the tests myself.

@codspeed

codspeed Bot commented Oct 15, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 0.42%

⚠️ 119 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

ℹ️ 1 benchmark has no flame graph

The flamegraph could not be generated because too much time was spent in runtime internals, making the visualization not useful for performance analysis.

⚡ 1 improved benchmark
❌ 2 regressed benchmarks
✅ 398 untouched benchmarks
⏩ 70 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

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)

Open in CodSpeed

Footnotes

  1. 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. ↩

@ozenyunus35

Copy link
Copy Markdown
Contributor Author

Closing this, as I can't follow up on it further. Thanks for the reviews.

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.

1 participant