I have a .bashrc file that needs to be sourced non-interactively. The problem is that on the file there is this return statement preventing from sourcing by code:
[ -z "$PS1" ] && return
To overcome this without modifying the remote .bashrc file I cat
the file, grep
out this line and source
it as below:
user@host -t "
source <( echo \"\$(cat /home/release/.bashrc | grep -v \"return\")\" );
alias v;
v"
P.S: Had I sourced .bash_profile the results would be the same as if I hadn't sourced it at all.
What I find strange is that if I declare an alias like so:
alias v='cat somefile'
and then run these two commands as previously:
alias v;
v;
I get the following output for each:
alias v='cat somefile'
bash: v: command not found
My question is: If it can see that there is an alias defined, why it won't recognize the command?