diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5b7fb73..31ce5b4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,6 +2,26 @@ name: Compile and Test on: [push] jobs: + ShellTest: + strategy: + fail-fast: true + matrix: + command: + - go + - aws + - python + runs-on: ubuntu-latest + steps: + - name: Checkout Dockerized + uses: actions/checkout@v2 + - name: Compile + run: bin/dockerized --compile + - name: "Test: dockerized --shell ${{matrix.command}}" + env: + COMMAND: "${{matrix.command}}" + run: | + bin/dockerized --shell $COMMAND -c 'echo $HOST_HOSTNAME' | tee ~/shell.log + grep $(hostname) ~/shell.log CompileAndTest: runs-on: ${{ matrix.os }} strategy: @@ -40,6 +60,7 @@ jobs: ../bin/dockerized go version | grep "1.17.8" shell: bash + # region windows - if: runner.os == 'windows' name: "dockerized --compile (cmd)" diff --git a/lib/dockerized.go b/lib/dockerized.go index 9579a0c..2c29838 100644 --- a/lib/dockerized.go +++ b/lib/dockerized.go @@ -122,7 +122,7 @@ func main() { fmt.Printf("Opening shell in container for %s...\n", commandName) if len(commandArgs) > 0 { - fmt.Printf("Ignoring arguments: %s\n", commandArgs[0]) + fmt.Printf("Passing arguments to shell: %s\n", commandArgs) } } @@ -145,12 +145,13 @@ func main() { } welcomeMessage = strings.ReplaceAll(welcomeMessage, "\\", "\\\\") + preferredShells := "bash zsh sh" var cmdPrintWelcome = fmt.Sprintf("echo '%s'", color.YellowString(welcomeMessage)) - var cmdLaunchShell = "$(which bash || which zsh || which sh || command -v bash || command -v zsh || command -v | head -n 1)" + var cmdLaunchShell = fmt.Sprintf("$(command -v %[1]s | head -n1 || which %[1]s | head -n1)", preferredShells) runOptions.Environment = append(runOptions.Environment, "PS1="+ps1) runOptions.Entrypoint = []string{"/bin/sh"} - runOptions.Command = []string{"-c", fmt.Sprintf("%s; %s", cmdPrintWelcome, cmdLaunchShell)} + runOptions.Command = []string{"-c", fmt.Sprintf("%s; %s \"%s\"", cmdPrintWelcome, cmdLaunchShell, strings.Join(commandArgs, "\" \""))} } if !contains(project.ServiceNames(), commandName) {