I'm making myself a few "helper" scripts, and the first one is to install NodeJS. The first issue I've just solved, was getting
source ~/.profile to persist changes. I found out running
. /scripts/install-nodejs.sh makes this work, but without the leading
., it doesn't.
Is there anyway I can tell in the script if it was called with the period before it, so if it isn't I can output myself a message remind me how to call the script properly?
For reference, this is the script so far
#!/bin/bash echo -n "Installing NVM..." apt-get -qq install curl > /dev/null curl -s https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh > /dev/null echo "Done!" source ~/.profile
Also, side question, is there a way to describe when a script is called with a preceding period?
sourceto run a script. Doing so runs the script in the context of the current shell. You don't know how that will affect the environment within the current shell -- it may have unintended consequences on future operations performed from that shell.