Skip to content

Preserve values and quoting when parsing os-release - #85

Open
OskarEichler wants to merge 2 commits into
rdp:masterfrom
OskarEichler:codex/parse-os-release-values
Open

OskarEichler wants to merge 2 commits into
rdp:masterfrom
OskarEichler:codex/parse-os-release-values

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

NAME="a=b" was truncated to a; NAME= became nil; single quotes and shell escapes were not decoded; comments became keys. Split only at the first equals sign, accept assignment keys, remove matching outer quotes and decode the applicable escapes without evaluating shell input.

Reproduction and verification

The os-release specification defines quoting, comment handling and literal assignments. The corpus includes 500 deterministic quoted values, embedded equals/quotes/backslashes, UTF-8, empty values, EOF and duplicate keys. Existing #48 changes release parsing too, but retains the lossy split/quote behavior; this PR does not duplicate its new APIs.

  • External focused repro corpus: 539 checks pass against this isolated branch, under rbenv Ruby 4.0.6.
  • Existing upstream suite: 36 examples, zero failures before and after the patch (RBENV_VERSION=4.0.6 rbenv exec rspec -Ilib -Ispec).
  • Source-only change; no existing tests modified or new test files added, per the contributor's task constraint. The focused corpus lives outside the repository.
  • Local verification was on macOS. Other Ruby versions and native operating systems were not executed. Upstream RuboCop configuration cannot load its legacy rubocop-lts1_8.yml, including after installing current rubocop-lts; lint status is not represented as passing.

Breaking-change notes

Corrected values, empty strings and ignored comment/non-assignment lines may differ from the previous malformed results. This is a reader for valid os-release assignments, not a general shell parser or expansion engine.

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