Skip to content

Commit

Permalink
Added SH_WORD_SPLIT to inject script
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Kosiewski <[email protected]>
  • Loading branch information
Thomas Kosiewski committed May 19, 2023
1 parent 854ffd3 commit 07a9281
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 57 deletions.
9 changes: 2 additions & 7 deletions cmd/agent/workspace/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,10 @@ func InstallDocker(log log.Logger) error {

log.Debug("Installing Docker...")

script, err := scripts.InstallDocker()
if err != nil {
return err
}

shellCommand := exec.Command("sh", "-c", script)
shellCommand := exec.Command("sh", "-c", scripts.InstallDocker)
shellCommand.Stdout = writer
shellCommand.Stderr = writer
err = shellCommand.Run()
err := shellCommand.Run()
if err != nil {
return err
}
Expand Down
5 changes: 0 additions & 5 deletions pkg/inject/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/loft-sh/devpod/pkg/log"
"github.com/loft-sh/devpod/pkg/template"
"github.com/loft-sh/devpod/scripts"
perrors "github.com/pkg/errors"
)

Expand Down Expand Up @@ -63,10 +62,6 @@ func InjectAndExecute(
return true, err
}

t, err = scripts.WrapScript(t)
if err != nil {
return true, err
}
log.Debugf("execute inject script")
defer log.Debugf("done injecting")

Expand Down
12 changes: 8 additions & 4 deletions pkg/inject/inject.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/sh
set -e

if [ "$SHELL" != "${SHELL%"/zsh"*}" ]; then
setopt SH_WORD_SPLIT
fi

INSTALL_DIR="{{ .InstallDir }}"
INSTALL_FILENAME="{{ .InstallFilename }}"

Expand Down Expand Up @@ -51,19 +55,19 @@ download() {
fi

while :; do
status=""
cmd_status=""
if command_exists curl; then
$sh_c "curl -fsSL $DOWNLOAD_URL -o $INSTALL_PATH" && break
status=$?
cmd_status=$?
elif command_exists wget; then
$sh_c "wget -q $DOWNLOAD_URL -O $INSTALL_PATH" && break
status=$?
cmd_status=$?
else
echo "error: no download tool found, please install curl or wget"
exit 127
fi
>&2 echo "error: failed to download devpod"
>&2 echo " command returned: ${status}"
>&2 echo " command returned: ${cmd_status}"
>&2 echo "Trying again in 10 seconds..."
sleep 10
done
Expand Down
11 changes: 1 addition & 10 deletions scripts/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,4 @@ package scripts
import _ "embed"

//go:embed install_docker.sh
var installDocker string

func InstallDocker() (string, error) {
script, err := WrapScript(installDocker)
if err != nil {
return "", err
}

return script, nil
}
var InstallDocker string
22 changes: 0 additions & 22 deletions scripts/wrapper.go

This file was deleted.

9 changes: 0 additions & 9 deletions scripts/wrapper.sh

This file was deleted.

0 comments on commit 07a9281

Please sign in to comment.