Skip to content

fix(parser): keep negated Host patterns when saving - #127

Open
lord-helicon wants to merge 1 commit into
Adembc:mainfrom
lord-helicon:upstream-pr/fix-negated-patterns
Open

lord-helicon wants to merge 1 commit into
Adembc:mainfrom
lord-helicon:upstream-pr/fix-negated-patterns

Conversation

@lord-helicon

Copy link
Copy Markdown

The ssh_config parser strips the leading ! from Pattern.Str and tracks negation only internally. So every save through lazyssh rewrote Host * !foo as Host * foo, which reverses its meaning. It also made Host !foo show up in the server list as a server named foo, and adding a server called foo was refused as a duplicate.

The ! is now restored right after parsing. Matches still uses the parser's internal negation, so pattern matching is unchanged.

Testing

  • TestSaveKeepsNegatedPatterns checks that Host !bastion and Host * !lab-? !b survive a save unchanged and aren't listed as servers.
  • make build (gofumpt, vet, golangci-lint) and make test pass.

This PR is independent of my other two config fixes. The small helpers_test.go is identical in all three, so they merge cleanly in any order.

The ssh_config parser strips the leading "!" from Pattern.Str and only
tracks the negation internally, so every save rewrote "Host * !foo" as
"Host * foo", inverting its meaning. It also made "Host !foo" show up
as a server named foo. Restore the "!" right after parsing.
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