Skip to content

Loading…

Replace BashEnv with ShellEnv allowing bash and zsh executions #90

Open
marc0der opened this Issue · 3 comments

2 participants

@marc0der
SDKMAN! member

Generalise the BashEnv to ShellEnv so that it can run bash or zsh.

This will help us run the cucumber suite against multiple environments in order to ensure compatibility with these shells.

Proposing a new -Dshell=bash|zsh parameter to the build, allowing the appropriate shell to be used to run the tests.

@ladios

+1
When logging in an X-Session, .profile is invoked by default shell. source won't work with sh (or dash, where /bin/sh is symlinked to in Ubuntu), so init script is not sourced. If I change source to ., it crashes X-Session and login fails.

We need a /bin/sh compatible init script just adding *_HOME environment variables, and then subsequently source advanced features only when the shell is an interactive terminal shell (bash, zsh, etc.).

The following is my workaround in .profile:

#THIS MUST BE AT THE END OF THE FILE FOR GVM TO WORK!!!
#[[ -s "${HOME}/.gvm/bin/gvm-init.sh" ]] && source "${HOME}/.gvm/bin/gvm-init.sh"
# commented out the above line and use the following to set GVM's *_HOME env vars in /bin/sh
[ -z "${GVM_DIR}" ] && GVM_DIR="${HOME}/.gvm"
export GVM_DIR
if [ -f "${GVM_DIR}/var/candidates" ]; then
    for GVM_CANDIDATE_NAME in `tr ',' ' ' < "${GVM_DIR}/var/candidates"`; do
        GVM_CANDIDATE_HOME_VAR="$(echo $GVM_CANDIDATE_NAME | tr '[:lower:]' '[:upper:]')_HOME"
        GVM_CANDIDATE_DIR="${GVM_DIR}/${GVM_CANDIDATE_NAME}/current"
        eval "export ${GVM_CANDIDATE_HOME_VAR}='${GVM_CANDIDATE_DIR}'"
        PATH="${GVM_CANDIDATE_DIR}/bin:${PATH}"
    done
    export PATH
    unset GVM_CANDIDATE_NAME
    unset GVM_CANDIDATE_HOME_VAR
    unset GVM_CANDIDATE_DIR
fi
@marc0der
SDKMAN! member

This issue actually refers to test classes that we use when we spin up our test suite. It tests the full set of bash scripts agains a bash env, and we want the same for zsh.

I have used (and tested) GVM on many linux distros all with X desktops, and have never experienced what you are seeing. This is probably because modern linux distros use bash by default, not sh. Unfortunately we do not support sh, but only bash and zsh at this time. If you want your default shell to be bash, you can do so with usermod by running the following command:

sudo usermod -s /bin/bash myusername

Hope it helps!

@ladios

I know this issue refers to test suite. I hope *_HOME and PATH could be setup even with /bin/sh, and you would need tests for that.

After I've switched to GVM, I noticed that Intellij IDEA wasn't picking up GRADLE_HOME like it had been when I had it set in .profile. In ~/.xsession-errors I saw something like ~/.gvm/bin/gvm-init.sh: source: not found. What came after that was what I described in my last comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.