The simple solution is to not source them. Since ~/.bash_aliases isn't a standard file, you must be explicitly sourcing it in one of your config files. So an easy solution would be to find the line that source it (most likely in your ~/.bashrc) and change it from this (or whatever your system has, this one is from Ubuntu):
if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi To this:
if [ -f ~/.bash_aliases ] && [ -n "$BASH_VERSION" ]; then . ~/.bash_aliases fi That way, the .bash_aliases file will only be sourced when running bash.
To clarify, what I am assuming is happening here based on the information in your question and comments, is the following:
You are sshing into a machine.
Because you are sshing into it, this launches the default
/bin/shas a login shell.Since this is a login shell, it will source
~/.profile.Because your
.profileis set up to source~/.bashrc(again, not standard, but common), you now read.bashrcalthough you might not be running bash.Since your
.bashrcis set up to source~/.bash_aliases, you read that file too and that produces the errors.
Yet another reason why I personally am not a fan of the decision some systems have made to make the default ~/.bashrc source ~/.profile.