Skip to content

Commit 248f25e

Browse files
authored
Revert "[path with spaces] run scripts for projects with paths in spaces (#1924)" (#1935)
## Summary Will rework these and do better testing. Revert "[path with spaces] run scripts for projects with paths in spaces (#1924)" This reverts commit 8171595. Revert "Support Project Directory having spaces (#1920)" This reverts commit 41294c2. ## How was it tested?
1 parent 1cc5ddd commit 248f25e

File tree

9 files changed

+13
-23
lines changed

9 files changed

+13
-23
lines changed

internal/devbox/devbox.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ func (d *Devbox) RunScript(ctx context.Context, cmdName string, cmdArgs []string
282282
env["DEVBOX_RUN_CMD"] = strings.Join(append([]string{cmdName}, cmdArgs...), " ")
283283
}
284284

285-
return nix.RunScript(d.projectDir, cmdWithArgs, env)
285+
return nix.RunScript(d.projectDir, strings.Join(cmdWithArgs, " "), env)
286286
}
287287

288288
// Install ensures that all the packages in the config are installed

internal/devbox/shellrc.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ working_dir="$(pwd)"
5656
cd "{{ .ProjectDir }}" || exit
5757

5858
# Source the hooks file, which contains the project's init hooks and plugin hooks.
59-
. "{{ .HooksFilePath }}"
59+
. {{ .HooksFilePath }}
6060

6161
cd "$working_dir" || exit
6262

internal/devbox/shellrc_fish.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ set workingDir (pwd)
5959
cd "{{ .ProjectDir }}" || exit
6060

6161
# Source the hooks file, which contains the project's init hooks and plugin hooks.
62-
source "{{ .HooksFilePath }}"
62+
source {{ .HooksFilePath }}
6363

6464
cd "$workingDir" || exit
6565

internal/devbox/testdata/shellrc/basic/shellrc.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ working_dir="$(pwd)"
2121
cd "/path/to/projectDir" || exit
2222

2323
# Source the hooks file, which contains the project's init hooks and plugin hooks.
24-
. "/path/to/projectDir/.devbox/gen/scripts/.hooks.sh"
24+
. /path/to/projectDir/.devbox/gen/scripts/.hooks.sh
2525

2626
cd "$working_dir" || exit
2727

internal/devbox/testdata/shellrc/noshellrc/shellrc.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ working_dir="$(pwd)"
1515
cd "/path/to/projectDir" || exit
1616

1717
# Source the hooks file, which contains the project's init hooks and plugin hooks.
18-
. "/path/to/projectDir/.devbox/gen/scripts/.hooks.sh"
18+
. /path/to/projectDir/.devbox/gen/scripts/.hooks.sh
1919

2020
cd "$working_dir" || exit
2121

internal/nix/nix.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"go.jetpack.io/devbox/internal/boxcli/featureflag"
2020
"go.jetpack.io/devbox/internal/boxcli/usererr"
2121
"go.jetpack.io/devbox/internal/redact"
22-
"go.jetpack.io/devbox/nix/flake"
2322

2423
"go.jetpack.io/devbox/internal/debug"
2524
)
@@ -70,19 +69,15 @@ func (*Nix) PrintDevEnv(ctx context.Context, args *PrintDevEnvArgs) (*PrintDevEn
7069
return nil, errors.WithStack(err)
7170
}
7271

73-
flakeRef, err := flake.ParseRef("path:" + flakeDirResolved)
74-
if err != nil {
75-
return nil, err
76-
}
77-
7872
if len(data) == 0 {
7973
cmd := exec.CommandContext(
8074
ctx,
81-
"nix", "print-dev-env", flakeRef.String(),
75+
"nix", "print-dev-env",
76+
"path:"+flakeDirResolved,
8277
)
8378
cmd.Args = append(cmd.Args, ExperimentalFlags()...)
8479
cmd.Args = append(cmd.Args, "--json")
85-
debug.Log("Running print-dev-env cmd: %s\n\n\n", cmd)
80+
debug.Log("Running print-dev-env cmd: %s\n", cmd)
8681
data, err = cmd.Output()
8782
if insecure, insecureErr := IsExitErrorInsecurePackage(err, "" /*pkgName*/, "" /*installable*/); insecure {
8883
return nil, insecureErr

internal/nix/run.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ import (
88
"fmt"
99
"os"
1010
"os/exec"
11-
"strings"
1211

1312
"go.jetpack.io/devbox/internal/boxcli/usererr"
1413
"go.jetpack.io/devbox/internal/cmdutil"
1514
"go.jetpack.io/devbox/internal/debug"
1615
)
1716

18-
func RunScript(projectDir string, cmdWithArgs []string, env map[string]string) error {
19-
if len(cmdWithArgs) == 0 {
17+
func RunScript(projectDir, cmdWithArgs string, env map[string]string) error {
18+
if cmdWithArgs == "" {
2019
return errors.New("attempted to run an empty command or script")
2120
}
2221

@@ -25,13 +24,9 @@ func RunScript(projectDir string, cmdWithArgs []string, env map[string]string) e
2524
envPairs = append(envPairs, fmt.Sprintf("%s=%s", k, v))
2625
}
2726

28-
// Wrap in quotations since the command's path may contain spaces.
29-
cmdWithArgs[0] = "\"" + cmdWithArgs[0] + "\""
30-
cmdWithArgsStr := strings.Join(cmdWithArgs, " ")
31-
3227
// Try to find sh in the PATH, if not, default to a well known absolute path.
3328
shPath := cmdutil.GetPathOrDefault("sh", "/bin/sh")
34-
cmd := exec.Command(shPath, "-c", cmdWithArgsStr)
29+
cmd := exec.Command(shPath, "-c", cmdWithArgs)
3530
cmd.Env = envPairs
3631
cmd.Dir = projectDir
3732
cmd.Stdin = os.Stdin

internal/shellgen/tmpl/init-hook-wrapper.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ Code here should be fish and POSIX compatible. That's why we use export to
55
remove the value
66
*/ -}}
77
export {{ .InitHookHash }}=true
8-
. "{{ .RawHooksFile }}"
8+
. {{ .RawHooksFile }}
99
export {{ .InitHookHash }}=""

internal/shellgen/tmpl/script-wrapper.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
if [ -z "${{ .InitHookHash }}" ]; then
1111
{{/* init hooks will export InitHookHash ensuring no recursive sourcing*/ -}}
12-
. "{{ .InitHookPath }}"
12+
. {{ .InitHookPath }}
1313
fi
1414

1515
{{ .Body }}

0 commit comments

Comments
 (0)