Prevent jdk_switcher from resetting PATH #338

Merged
merged 4 commits into from Jun 30, 2014

Conversation

Projects
None yet
3 participants
@BanzaiMan
Member

BanzaiMan commented Jun 30, 2014

Since /etc/profile.d/load_jdk_switcher.sh always sources
$HOME/.jdk_switcher_rc, jdk_switcher reverting to the original $PATH
causes problems when other stuff (such as PostgreSQL service)
starts a login shell after manipulating $PATH and subshell is expected
to find stuff in the modified $PATH.

Prevent jdk_switcher from resetting PATH
Since /etc/profile.d/load_jdk_switcher.sh always sources
$HOME/.jdk_switcher_rc, jdk_switcher reverting to the original PATH
causes problems when other stuff (such as PostgreSQL service)
starts a login shell after manipulating PATH and subshell is expected
to find stuff in the modified PATH.

BanzaiMan added some commits Jun 30, 2014

Append : to $PATH in remove_dir_from_path
: at the end is necessary in case the last PATH element has
trailing slashes
@@ -108,6 +103,14 @@ warn_gcj_user () {
echo "We do not support GCJ." >&2
}
+remove_dir_from_path() {
+ local target=$(echo $1 | sed -e 's:/*$::') # remove all occurrences of / at the end
+ PATH=:$(echo $PATH: | sed -e 's_/*:_:_g'):

This comment has been minimized.

@sarahhodne

sarahhodne Jun 30, 2014

Contributor
$ PATH=foo:bar/
$ echo :$(echo $PATH: | sed -e 's_/*:_:_g'):
:foo:bar::

I think this'll work better:

PATH="$(echo :$PATH: | sed -e 's_/*:_:_g')"
@sarahhodne

sarahhodne Jun 30, 2014

Contributor
$ PATH=foo:bar/
$ echo :$(echo $PATH: | sed -e 's_/*:_:_g'):
:foo:bar::

I think this'll work better:

PATH="$(echo :$PATH: | sed -e 's_/*:_:_g')"

joshk added a commit that referenced this pull request Jun 30, 2014

Merge pull request #338 from travis-ci/ha-bug-jdk_switcher-path-manip…
…ulation

Prevent jdk_switcher from resetting PATH

@joshk joshk merged commit 5c9bec6 into master Jun 30, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details

@joshk joshk deleted the ha-bug-jdk_switcher-path-manipulation branch Jun 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment