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

config: support ~ as user's home directory for Include #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lonnywong
Copy link

e.g., Include ~/other/config on Linux, Include ~\other\config on Windows.

e.g., `Include ~/other/config` on Linux, `Include ~\other\config` on Windows.
@@ -732,6 +732,8 @@ func NewInclude(directives []string, hasEquals bool, pos Position, comment strin
path = directives[i]
} else if system {
path = filepath.Join("/etc/ssh", directives[i])
} else if strings.HasPrefix(directives[i], "~/") || strings.HasPrefix(directives[i], "~\\") {
path = filepath.Join(homedir(), directives[i][2:])
Copy link
Owner

Choose a reason for hiding this comment

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

Is 2: right here? Wouldn't it be different in the first condition (only 2 chars) vs. the second condition (3 chars) ?

Copy link
Author

Choose a reason for hiding this comment

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

The second one is 2 chars. The first \ of \\ is the escape char for \. "~\\" in source code means ~\.

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.

2 participants