"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
sftp: auto-detect shell type for fish
albertony1392793334c1
diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.goindex b6afcd355..109745267 100644--- a/backend/sftp/sftp.go+++ b/backend/sftp/sftp.go@@ -975,20 +975,24 @@ func NewFsWithConnection(ctx context.Context, f *Fs, name string, root string, mfs.Debugf(f, "Running shell type detection remote command: %s", shellCmd)err = session.Run(shellCmd)_ = session.Close()+ f.shellType = defaultShellTypeif err != nil {- f.shellType = defaultShellTypefs.Debugf(f, "Remote command failed: %v (stdout=%v) (stderr=%v)", err, bytes.TrimSpace(stdout.Bytes()), bytes.TrimSpace(stderr.Bytes()))} else {outBytes := stdout.Bytes()fs.Debugf(f, "Remote command result: %s", outBytes)outString := string(bytes.TrimSpace(stdout.Bytes()))- if strings.HasPrefix(outString, "Microsoft.PowerShell") { // If PowerShell: "Microsoft.PowerShell%ComSpec%"- f.shellType = "powershell"- } else if !strings.HasSuffix(outString, "%ComSpec%") { // If Command Prompt: "${ShellId}C:\WINDOWS\system32\cmd.exe"- f.shellType = "cmd"- } else { // If Unix: "%ComSpec%"- f.shellType = "unix"- }+ if outString != "" {+ if strings.HasPrefix(outString, "Microsoft.PowerShell") { // PowerShell: "Microsoft.PowerShell%ComSpec%"+ f.shellType = "powershell"+ } else if !strings.HasSuffix(outString, "%ComSpec%") { // Command Prompt: "${ShellId}C:\WINDOWS\system32\cmd.exe"+ // Additional positive test, to avoid misdetection on unpredicted Unix shell variants+ s := strings.ToLower(outString)+ if strings.Contains(s, ".exe") || strings.Contains(s, ".com") {+ f.shellType = "cmd"+ }+ } // POSIX-based Unix shell: "%ComSpec%"+ } // fish Unix shell: ""}}// Save permanently in config to avoid the extra work next time