When I try to run my bash function, defined in .bashrc, for a second time in the same terminal, it doesn't work.
The code is the following:
function nos (){
local option
while getopts cs option
do
case $option in
s)
#start my server
;;
c)
local cdir="~/mydirectory"
local cdir_arg=""
case $OPTARG in
p)
local cdir_arg="anotherdirectory"
;;
esac
local cdir="${cdir}${cdir_arg}"
cd $cdir
;;
*)
echo 'This function doesnt have Super Cow Powers'
return 1
;;
esac
done
}
I run this:
nos -c
it goes to ~/mydirectory
ok, worked.
but then I do this:
cd ~
nos -c
and nothing happens.
