Within .bashrc, I define a function: mipinfo () {...}
function mipinfo () {
outfile="~/path/`date +%Y%m%d`_mipinfo"
printf "%s\n" "$outfile"; touch $outfile
.....
}
Sourcing .bashrc results in exit value 0.
Typing mipinfo
in Gnome terminal, I get:
~/path/20150807_mipinfo
touch: cannot touch ‘~/path/20150807_mipinfo’: No such file or directory
bash: ~/path/20150807_mipinfo: No such file or directory
I guess this has to do with the parameter $outfile
being local and not being passed to the calling shell where the execution of touch
takes effect. I realize that to pass a called script's variables back to the calling shell one needs to source the called script in that shell, but I am not clear how I can circumvent that for a simple function using bash scripting only (not C++, as here).
It seems to be a case of passing the pertinent variable $outfile
from within the function to the calling script/shell (and not the usual opposite). Not even sure about that actually.
Any pointer greatly appreciated...