Adds a stub for syscall.Exec when GOOS=js. We also had a separate branch for Windows, might as well use the same mechanism there too. For #3157 Signed-off-by: Mihai Parparita <mihai@tailscale.com>main
parent
cc91a05686
commit
eda647cb47
@ -0,0 +1,21 @@ |
||||
// Copyright (c) 2022 Tailscale Inc & AUTHORS All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !js && !windows
|
||||
// +build !js,!windows
|
||||
|
||||
package cli |
||||
|
||||
import ( |
||||
"errors" |
||||
"os" |
||||
"syscall" |
||||
) |
||||
|
||||
func execSSH(ssh string, argv []string) error { |
||||
if err := syscall.Exec(ssh, argv, os.Environ()); err != nil { |
||||
return err |
||||
} |
||||
return errors.New("unreachable") |
||||
} |
||||
@ -0,0 +1,13 @@ |
||||
// Copyright (c) 2022 Tailscale Inc & AUTHORS All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cli |
||||
|
||||
import ( |
||||
"errors" |
||||
) |
||||
|
||||
func execSSH(ssh string, argv []string) error { |
||||
return errors.New("Not implemented") |
||||
} |
||||
@ -0,0 +1,25 @@ |
||||
// Copyright (c) 2022 Tailscale Inc & AUTHORS All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cli |
||||
|
||||
import ( |
||||
"errors" |
||||
"os" |
||||
"os/exec" |
||||
) |
||||
|
||||
func execSSH(ssh string, argv []string) error { |
||||
// Don't use syscall.Exec on Windows, it's not fully implemented.
|
||||
cmd := exec.Command(ssh, argv[1:]...) |
||||
cmd.Stdin = os.Stdin |
||||
cmd.Stdout = os.Stdout |
||||
cmd.Stderr = os.Stderr |
||||
var ee *exec.ExitError |
||||
err := cmd.Run() |
||||
if errors.As(err, &ee) { |
||||
os.Exit(ee.ExitCode()) |
||||
} |
||||
return err |
||||
} |
||||
Loading…
Reference in new issue