Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wezterm-ssh: add support for comments in Match statements #5779

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hdonnay
Copy link

@hdonnay hdonnay commented Jul 3, 2024

Looking at the openssh-portable code, it seems that inline comments are only handled specially on Match and ProxyJump statements. This change adds inline comment handling.

Closes: #5498
See-also: https://github.com/openssh/openssh-portable/blob/ee6b9e661633fcefd29dba0c811cecbc4d027f6f/readconf.c#L652

Looking at the openssh-portable code, it seems that inline comments are
only handled specially on `Match` and `ProxyJump` statements. This
change adds inline comment handling.

Closes: wez#5498
See-also: https://github.com/openssh/openssh-portable/blob/ee6b9e661633fcefd29dba0c811cecbc4d027f6f/readconf.c#L652
Signed-off-by: Hank Donnay <[email protected]>
Copy link
Owner

@wez wez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

@@ -293,7 +295,14 @@ impl ParsedConfigFile {
let mut criteria = vec![];
let mut context = Context::FirstPass;

let mut tokens = v.split_ascii_whitespace();
let mut tokens = v.split_ascii_whitespace().map_while(|tok| {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I don't think this works as you intend, because I think this results in ignoring only the # fun token but not the games token from your expanded test case?

A more robust alternative would be to do something like:

let v, _commented = v.split_once('#').unwrap_or(v);
let mut tokens = v.split_ascii_whitespace();

Please expand the test case to explicitly verify the effective values for the games host so that we can prove/disprove this.

@wez wez marked this pull request as draft September 14, 2024 15:44
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.

Trips on inline comment in SSH config
2 participants