summaryrefslogtreecommitdiff
path: root/go/internal/command/fallback/fallback.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/internal/command/fallback/fallback.go')
-rw-r--r--go/internal/command/fallback/fallback.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/go/internal/command/fallback/fallback.go b/go/internal/command/fallback/fallback.go
index 6e6d526..71e2a98 100644
--- a/go/internal/command/fallback/fallback.go
+++ b/go/internal/command/fallback/fallback.go
@@ -8,14 +8,25 @@ import (
"gitlab.com/gitlab-org/gitlab-shell/go/internal/command/readwriter"
)
-type Command struct{}
+type Command struct {
+ RootDir string
+ Args []string
+}
var (
- binDir = filepath.Dir(os.Args[0])
+ // execFunc is overridden in tests
+ execFunc = syscall.Exec
+)
+
+const (
+ RubyProgram = "gitlab-shell-ruby"
)
-func (c *Command) Execute(_ *readwriter.ReadWriter) error {
- rubyCmd := filepath.Join(binDir, "gitlab-shell-ruby")
- execErr := syscall.Exec(rubyCmd, os.Args, os.Environ())
- return execErr
+func (c *Command) Execute(*readwriter.ReadWriter) error {
+ rubyCmd := filepath.Join(c.RootDir, "bin", RubyProgram)
+
+ // Ensure rubyArgs[0] is the full path to gitlab-shell-ruby
+ rubyArgs := append([]string{rubyCmd}, c.Args[1:]...)
+
+ return execFunc(rubyCmd, rubyArgs, os.Environ())
}