I've written a simple bash script that adds an alias to my .bashrc automatically, and when it finishes, I would like it to source the .bashrc
It works fine as of now, for example
./addalias.sh ls 'ls -l'
properly appends 'alias ls='ls -l' to the .bashrc, but doesn't source it.
The code is as follows:
#!/bin/bash
FIRST=$1
SECOND=${2:-cd `pwd`}
echo alias $FIRST="'$SECOND'" >> /home/oscar/.bashrc
echo alias $FIRST="'$SECOND'"
source /home/oscar/.bashrc
That doesn't work, nor does running an alias ("sourcebash") to source the bash instead of the last line.
Any thoughts on how this could be fixed?
ifstatement withSECOND=${2:-cd `pwd`}