dahlbyk / posh-sshell

PowerShell helpers for SSH (previously part of posh-git.)
MIT License
143 stars 8 forks source link

ignore quotes in core.sshCommand warning #24

Open adamralph opened 4 years ago

adamralph commented 4 years ago

System Details

Issue Description

WARNING: core.sshCommand in your .gitconfig is set to "C:/Windows/System32/OpenSSH/ssh.exe", but it should be set to C:/WINDOWS/System32/OpenSSH/ssh.exe.

The quotes are redundant, since the path contains no spaces, but they should be ignored.

JeremySkinner commented 4 years ago

Hi, it isn't actually the case that this is complaining about - it's already doing a case-insensitive comparison (powershell string comparisons are case insensitive by default). It's actually creating the warning because of the quotes.

I think you should be able to just remove the quotes around the path and the warning will go away (you don't need them unless the path contains spaces), but I can also look at making the check more robust so it ignores the quotes for a future version (or if you wanted to submit a pull request to do this, that would be welcome too).

adamralph commented 4 years ago

Ah, I see, thanks. I'll alter the title and description.

darthstark1138 commented 4 years ago

Removing the quotes is an option if you don't have spaces, but not if you do have them. WARNING: core.sshCommand in your .gitconfig is set to 'C:/Program Files/OpenSSH-Win64/ssh.exe', but it should be set to C:/Program Files/OpenSSH-Win64/ssh.exe. That is the default Chocolatey install location for OpenSSH btw.

Edit to add: I've tested and my Git (git for windows, 2.27.0.windows.1) doesn't consider double-quoted paths on any config files.

With [core] sshCommand = "C:/Program Files/OpenSSH-Win64/ssh.exe" I get > git pull C:/Program Files/OpenSSH-Win64/ssh.exe: C:/Program: No such file or directory fatal: Could not read from remote repository.

With [core] sshCommand = 'C:/Program Files/OpenSSH-Win64/ssh.exe' I get WARNING: core.sshCommand in your .gitconfig is set to 'C:/Program Files/OpenSSH-Win64/ssh.exe', but it should be set to C:/Program Files/OpenSSH-Win64/ssh.exe.

With other combinations, I get fatal: bad config line 35 in file C:/Users/mvhec/.gitconfig

Anyway, I'm issuing a pull request to ignore single-quoted paths.

nemchik commented 2 years ago

I just installed posh-sshell and added Start-SshAgent -Quiet to my Powershell profile and it seems to have added the core.sshCommand configuration to my C:\Users\me\.gitconfig file as

[core]
    sshCommand = C:/Program Files/OpenSSH/ssh.exe

which causes errors when using git, saying:

C:/Program Files/OpenSSH/ssh.exe: C:/Program: No such file or directory

wrapping the value in .gitconfig in single quotes is the only way I've found to make things work, but then every time I open a shell I get

WARNING: core.sshCommand in your .gitconfig is set to 'C:/Program Files/OpenSSH/ssh.exe', but it should be set to C:/Program Files/OpenSSH/ssh.exe.

It seems like this value isn't needed at all. If I remove Start-SshAgent -Quiet from my Powershell profile and remove the core.sshCommand configuration from my .gitconfig everything works fine, and the configuration is not automatically re-added.