Reputation: 695
I have a collection of aliases defined in ~/.aliases
which I would like to make available to sh
even when it is run non-interactively. My system has been setup in the typical way so that sh
is a symlink to bash
.
When bash is run non-interactively as bash
, this could by using shopt -s expand_aliases
together with setting $ENV
or $BASH_ENV
to (directly or indirectly) source ~/.aliases
.
But when bash
is invoked non-interactively as sh
, it seems to ignore $ENV
and all startup files, so I can't see a way to do it. Any ideas? Or is this just not possible?
Upvotes: 0
Views: 1685
Reputation: 40414
One way to force the shell to be interactive when running a script is using -i
such as:
$ bash -i <script>
Also, note that if your script has execute permissions, you can replace:
#!/bin/bash
with:
#!/bin/bash -i
Upvotes: 2