1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-06 00:03:32 +00:00

refactor: use strings.Cut to simplify code

Signed-off-by: vicerace <vicerace@sohu.com>
This commit is contained in:
vicerace
2025-11-25 18:26:16 +08:00
committed by dougal
parent 6858bf242e
commit 9be7f99bf8
4 changed files with 15 additions and 15 deletions

View File

@@ -58,10 +58,10 @@ type conn struct {
// interoperate with the rclone sftp backend
func (c *conn) execCommand(ctx context.Context, out io.Writer, command string) (err error) {
binary, args := command, ""
space := strings.Index(command, " ")
if space >= 0 {
binary = command[:space]
args = strings.TrimLeft(command[space+1:], " ")
before, after, ok := strings.Cut(command, " ")
if ok {
binary = before
args = strings.TrimLeft(after, " ")
}
args = shellUnEscape(args)
fs.Debugf(c.what, "exec command: binary = %q, args = %q", binary, args)