mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
windows ssh fixes (#250)
a couple small bug fixes - wsh not being executable in windows (this doesn't add it to the path yet) - windows using the wrong slash for the path to wsh on the remote
This commit is contained in:
parent
2f020099ec
commit
5cbf2673f4
@ -72,7 +72,7 @@ func GetWshVersion(client *ssh.Client) (string, error) {
|
||||
}
|
||||
|
||||
func GetWshPath(client *ssh.Client) string {
|
||||
defaultPath := filepath.Join("~", ".waveterm", "bin", "wsh")
|
||||
defaultPath := "~/.waveterm/bin/wsh"
|
||||
|
||||
session, err := client.NewSession()
|
||||
if err != nil {
|
||||
@ -96,6 +96,18 @@ func GetWshPath(client *ssh.Client) string {
|
||||
return strings.TrimSpace(string(out))
|
||||
}
|
||||
|
||||
// check cmd on windows since it requires an absolute path with backslashes
|
||||
session, err = client.NewSession()
|
||||
if err != nil {
|
||||
log.Printf("unable to detect client's wsh path. using default. error: %v", err)
|
||||
return defaultPath
|
||||
}
|
||||
|
||||
out, cmdErr := session.Output("(dir 2>&1 *``|echo %userprofile%\\.waveterm%\\.waveterm\\bin\\wsh.exe);&<# rem #>echo none") //todo
|
||||
if cmdErr == nil && strings.TrimSpace(string(out)) != "none" {
|
||||
return strings.TrimSpace(string(out))
|
||||
}
|
||||
|
||||
// no custom install, use default path
|
||||
return defaultPath
|
||||
}
|
||||
@ -279,6 +291,9 @@ func CpHostToRemote(client *ssh.Client, sourcePath string, destPath string) erro
|
||||
|
||||
func InstallClientRcFiles(client *ssh.Client) error {
|
||||
path := GetWshPath(client)
|
||||
log.Printf("path to wsh searched is: %s", path)
|
||||
log.Printf("in bytes is: %v", []byte(path))
|
||||
log.Printf("in bytes expected would be: %v", []byte("~/.waveterm/bin/wsh"))
|
||||
|
||||
session, err := client.NewSession()
|
||||
if err != nil {
|
||||
|
@ -268,6 +268,9 @@ func initCustomShellStartupFilesInternal() error {
|
||||
return nil
|
||||
}
|
||||
wshDstPath := filepath.Join(binDir, "wsh")
|
||||
if runtime.GOOS == "windows" {
|
||||
wshDstPath = wshDstPath + ".exe"
|
||||
}
|
||||
err = utilfn.AtomicRenameCopy(wshDstPath, wshFullPath, 0755)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error copying wsh binary to bin: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user