I'm currently trying to refactor a software of mine. I wrote this script:
shopt -ps cdable_vars
. ~/.config/butler/butler_aliases
while getopts 'a:' OPTION; do
case "$OPTION" in
a)
echo "Adding stuff. $OPTARG"
echo "$OPTARG=$PWD" >> ~/.config/butler/butler_aliases
return;;
?)
echo "Usage: $(basename $0) [-a]"
return;;
esac
done
It's meant to be sourced in the current shell to be able to resource the alias file immediately. It all works great for the first time:
u@h:~/.local/bin$ . butler -a test13
Adding stuff. test13
u@h:~/.local/bin$ . butler -a test14
u@h:~/.local/bin$
When running after the first invocation, it does not do anything, which I don't quite get. Can anybody explain why it behaves like this?