Open sirupsen opened 10 years ago
This is an issue e.g. if you source chruby
twice, but only set RUBIES before sourcing it the first time.
This is a good question. Since RUBIES
is an Array variable it cannot be exported, so it will never be passed to a sub-shell.
Is there any way to prevent that from happening?
@Sirupsen I don't think we could easily pass RUBIES
between shells. We could however add a simple empty check, in case chruby is loaded twice or the user defines RUBIES
before hand.
That sounds great.
Should we still auto-populate RUBIES
with /opt/rubies/*
or ~/.rubies/*
, or should we assume the user has explicitly set RUBIES
.
I'm not entirely familiar with how bash works in this case, but to me the expected behaviour would be that chruby
made sure /opt/rubies/*
and ~/rubies/*
is always in RUBIES
. But however many times you source chruby
afterwards (say you source it in /etc/profile.d/chruby.sh
and a user on the system sources it too when importing his dotfiles), these will still be in RUBIES
, in addition to whatever has been appended to RUBIES
in /etc/profile.d/*
or ~/.bashrc
.
Since RUBIES
is only used in the chruby
function, we could leave it unset at the global level, and have the chruby
function copy it to another variable if it's set, or set that other variable to the default otherwise.
If
RUBIES
is already set, is it intentional we are overriding it?