Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installer can clobber local profile configuration #931

Open
connec opened this issue Apr 13, 2024 · 0 comments
Open

Installer can clobber local profile configuration #931

connec opened this issue Apr 13, 2024 · 0 comments

Comments

@connec
Copy link

connec commented Apr 13, 2024

Context:

The current logic for add_install_dir_to_path will write to the first file name in the list given to it if none of the files exist:

# If we didn't find anything, pick the first entry in the
# list as the default to create and write to
if [ -z "${_target:-}" ]; then
local _rcfile_relative
_rcfile_relative="$(echo "$_rcfiles" | awk '{ print $1 }')"
_home="$(print_home_for_script "$_rcfile_relative")"
_target="$_home/$_rcfile_relative"
fi

add_install_dir_to_path is called three times, with different file names:

add_install_dir_to_path "$_install_dir_expr" "$_env_script_path" "$_env_script_path_expr" ".profile"
exit1=$?
add_install_dir_to_path "$_install_dir_expr" "$_env_script_path" "$_env_script_path_expr" ".bash_profile .bash_login .bashrc"
exit2=$?
add_install_dir_to_path "$_install_dir_expr" "$_env_script_path" "$_env_script_path_expr" ".zshrc .zshenv"
exit3=$?

Each call will therefore write at least one file (.profile, .bash_profile, .zshrc), regardless of which other files exist.


Issue:

In my case, I use bash and put all my configuration in .profile. bash will only load .profile if a .bash_profile does not exist, so the current behaviour of the installer effectively clobbers my local profile.


Possible solution:

Assuming this is undesired behaviour rather than an unsupported configuration at my end (though correct me if I'm wrong), this could be improved by making a single call to add_install_dir_to_path:

add_install_dir_to_path "$_install_dir_expr" "$_env_script_path" "$_env_script_path_expr" ".profile .bash_profile .bash_login .bashrc .zshrc .zshenv"

if [ $? = 1 ]; then
  # ...
fi

This would have the effect of creating ~/.profile if none of the files exist. As a lowest common denominator this seems like a reasonable choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant