hpcflow / install-scripts

Scripts to install pyinstaller folder version on a local machine.
0 stars 0 forks source link

Methods to ensure symlinks and aliases are useable immediately after script completes #23

Open cjfullerton opened 1 year ago

cjfullerton commented 1 year ago

Assume this is possible:

If script adds hpcflow/links folder to path, want to reload .bashrc so path is updated when script is finished and user can instantly run the installed app.

cjfullerton commented 1 year ago

Looks like there are two methods to do this:

  1. ~/.bashrc or source ~/.bashrc preserves current shell and augments with any additions made to .bashrc. This means (for example) that removing lines that add folders to the path will not remove them from the current path.

  2. exec bash, or, more robustly, exec "$BASH". This replaces the current shell with a new one, wiping the slate clean.

The first of these options sounds preferable to use in the script to avoid clearing any parameters the script is using.

cjfullerton commented 1 year ago

This seems to work, although have had to use an alternate solution for zsh users.

Script runs in bash, so if user has zsh as default and .zshrc is modified, cannot source .zshrc within script.

Instead, just before exit if .zshrc exists the script runs exec .zshrc.

This could cause some issues if user has bash as default and .zshrc exists - they will find themselves in a zsh shell unexpectedly.

cjfullerton commented 1 year ago

Actually, might have to do something similar for bash at the end of the script - the script runs in its own shell, so any changes to path aren't reflected when the script finishes.

cjfullerton commented 1 year ago

Have tried several formulations of this for bash, but none have worked so far. May need to advise user to run source ~/.bashrc manually?

cjfullerton commented 1 year ago

Retitled as aliases require a shell restart under Powershell too.