Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion libs/exec/execv.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ type ExecvOptions struct {
// Env is set the environment variables to set in the child process.
Env []string

// Dir is the working directory of the child process.
// Dir specifies the working directory of the command.
// If Dir is an empty string, Execv runs the command in the
// calling process's current directory.
Dir string

// It is not possible to execute a cmd.exe script inlined as a argument
Expand Down
8 changes: 5 additions & 3 deletions libs/exec/execv_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import (
)

func execv(opts ExecvOptions) error {
err := os.Chdir(opts.Dir)
if err != nil {
return fmt.Errorf("changing directory to %s failed: %w", opts.Dir, err)
if opts.Dir != "" {
err := os.Chdir(opts.Dir)
if err != nil {
return fmt.Errorf("changing directory to %s failed: %w", opts.Dir, err)
}
}

// execve syscall does not perform PATH lookup. Thus we need to query path
Expand Down
7 changes: 0 additions & 7 deletions libs/lakebase/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ func Connect(ctx context.Context, databaseInstanceName string, extraArgs ...stri
}
cmdio.LogString(ctx, "Successfully fetched database credentials")

// Get current working directory
dir, err := os.Getwd()
if err != nil {
return fmt.Errorf("error getting working directory: %w", err)
}

// Check if database name and port are already specified in extra arguments
hasDbName := false
hasPort := false
Expand Down Expand Up @@ -103,6 +97,5 @@ func Connect(ctx context.Context, databaseInstanceName string, extraArgs ...stri
return exec.Execv(exec.ExecvOptions{
Args: args,
Env: cmdEnv,
Dir: dir,
})
}
Loading