Posts

Showing posts with the label Scripts

Add Android-studio/bin/ To PATH Environmental Variable

Answer : It looks like you edited this code snippet: if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi which is included in ~/.profile by default. The answer which lead you to do so is confusing IMNSHO. I'd suggest that you change that code back to what it looked like before, and instead add a new line underneath it: if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi PATH="$PATH:/usr/local/Android/android-studio/bin" Then, next time you log in, PATH ought to be altered, whether $HOME/bin exists or not.

Cannot Successfully Source .bashrc From A Shell Script

Answer : A shell script is run in its own shell instance. All the variable settings, function definitions and such only affect this instance (and maybe its children) but not the calling shell so they are gone after the script finished. By contrast the source command doesn't start a new shell instance but uses the current shell so the changes remain. If you want a shortcut to read your .bashrc use a shell function or an alias instead of a shell script, like alias brc='source ~/.bashrc' I want to complement ravi's answer: This behavior is specific to Ubuntu (and probably most derived distros), since your default ~/.bashrc file starts with a short-circuit, Ubuntu 18.04, for example: # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac That will stop the evaluation of the file if it is running in a non-interactive shell, which is the case of your script since all scripts are run in a non-interactive shell, and...