So I've got a .bash_aliases file with many exported bash functions inside; a good deal of which are incompatible with sh...
The problem is that sh is used all over my laptop (OS X) and linux machines that I ssh into. In addition it always tries to import my bash functions and spams errors.
The functions in question are:
- all of my functions that have a '-' in their name (NOTE: these only spam errors on OS X, not linux)
and a log() function (below) with syntax that is only legal in bash
log() { # braces allow for piping of same output to multiple files { $@ 2> >(tee .err.log); } &> >(tee .out.log); echo; echo logged output to .err.log \& .out.log respectively; } export -f log
So how can I solve this problem? I'd prefer it if I didn't have to rename the functions or put them in separate scripts inside a */bin directory...
Thanks for the help!
P.S. screenshot:
EDIT: I see I didn't include enough info.
So yes .bash_profile
does source .bashrc
which in turn sources .bash_aliases
(I have no .profile
).
In addition I have already tried to create an exit clause in .bash_aliases when $SHELL='sh'
but it didn't work which is because they are being imported directly from my environment (as @Bodo and the import errors in screen cap indicate).
EDIT2 IMPORTANT: Also strangely I just found out that in the linux machine that I ssh into /bin/sh is a symbolic link to bash. Which means that bash although throwing no errors when sourcing log() actually does throw errors when importing it from the environment??
.bash_aliases
isn't a standard file. Where are you sourcing it from? Ubuntu sources it in.bashrc
, are you doing that? And does your.profile
also source.bashrc
?.bashrc
files I've seen source it. Also yes, both my.bash_profile
and my.bashrc
do that.grep -R .bash_aliases ~/
~/.profile
do it too or only your~/.bash_profile
? And what operating systems are you using? Is their/bin/sh
actuallysh
or is it a symlink to/bin/bash
or/bin/dash
or something else?