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?
The .
is short hand for sourcing the script. Sourcing a script is like calling each of the commands by hand.
Check this out The Dot
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments