Skip to content

Commit c694277

Browse files
authored
[sed] Fix bin wrappers when sed is installed with devbox (#1566)
## Summary TSIA ## How was it tested? Using this config: https://discord.com/channels/903306922852245526/1009933892385517619/1163763578399105064 Pre-change, could not shell in, got bash nesting error. Post-change, could shell in.
1 parent bb3a67c commit c694277

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

internal/wrapnix/wrapper.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func CreateWrappers(ctx context.Context, args CreateWrappersArgs) error {
4848
_ = os.MkdirAll(destPath, 0o755)
4949

5050
bashPath := cmdutil.GetPathOrDefault("bash", "/bin/bash")
51+
sedPath := cmdutil.GetPathOrDefault("sed", "sed")
5152

5253
if err := CreateDevboxSymlinkIfPossible(); err != nil {
5354
return err
@@ -58,6 +59,7 @@ func CreateWrappers(ctx context.Context, args CreateWrappersArgs) error {
5859
WrapperBinPath: destPath,
5960
CreateWrappersArgs: args,
6061
BashPath: bashPath,
62+
SedPath: sedPath,
6163
Command: bin,
6264
DevboxSymlinkDir: devboxSymlinkDir,
6365
destPath: filepath.Join(destPath, filepath.Base(bin)),
@@ -128,6 +130,7 @@ func CreateDevboxSymlinkIfPossible() error {
128130
type createWrapperArgs struct {
129131
CreateWrappersArgs
130132
BashPath string
133+
SedPath string
131134
Command string
132135
destPath string
133136
DevboxSymlinkDir string

internal/wrapnix/wrapper.sh.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ should be in PATH.
3232
This is implemented in sed for efficiency. sed is POSIX so we assume it's available.
3333

3434
*/ -}}
35-
export PATH=$(echo $PATH | sed -e 's#:{{ .WrapperBinPath }}##' -e 's#{{ .WrapperBinPath }}:##' -e 's#{{ .WrapperBinPath }}##')
35+
export PATH=$(echo $PATH | {{ .SedPath }} -e 's#:{{ .WrapperBinPath }}##' -e 's#{{ .WrapperBinPath }}:##' -e 's#{{ .WrapperBinPath }}##')
3636

3737
exec {{ .Command }} "$@"

0 commit comments

Comments
 (0)