Skip to main content
edited tags
Link
terdon
  • 252.7k
  • 69
  • 481
  • 719
added more info
Source Link

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:

enter image description here

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 I assume is because they are being imported directly from my environment imported directly from my environment (as @Bodo mentionedand 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??

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:

enter image description here

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 I assume is because they are being imported directly from my environment (as @Bodo mentioned).

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:

enter image description here

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??

correcting mistakes
Source Link

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:

enter image description here

EDIT: I see I didn't include enough info. So So yes .profilebash_profile does source .bashrc which in turn sources .bash_profilebash_aliases (I have no .profile). In In addition I have already tried to create an exit clause in .bash_profilebash_aliases when $SHELL='sh' but it didn't work which I assume is because they are being imported directly from my environment (as @Bodo mentioned).

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:

enter image description here

EDIT: I see I didn't include enough info. So yes .profile does source .bashrc which in turn sources .bash_profile. In addition I have already tried to create an exit clause in .bash_profile when $SHELL='sh' but it didn't work which I assume is because they are being imported directly from my environment (as @Bodo mentioned).

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:

enter image description here

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 I assume is because they are being imported directly from my environment (as @Bodo mentioned).

added 319 characters in body
Source Link
Loading
deleted 6 characters in body
Source Link
Loading
added 22 characters in body
Source Link
jesse_b
  • 41.6k
  • 14
  • 108
  • 163
Loading
Source Link
Loading