I want to invoke shell function in string. Here is my use case:
function envfoo() {
env ENV_FOO=foo $@
}
function envbar() {
env ENV_BAR=bar $@
}
$ envfoo env |egrep ENV_
ENV_FOO=foo
$ envbar env |egrep ENV_
ENV_BAR=bar
$ envfoo envbar env |egrep ENV_
env: envbar: No such file or directory
# expected result: ENV_FOO=foo and ENV_BAR=bar lines
Here I want envfoo
to execute envbar
shell function.
How can I do it?
Say that is opposite of command
which ignores shell function and finds real command.
Maybe I gave a wrong example. I want to combine multiple shell functions like actual executables. A real case goes like this:
function be() {
bundle exec $@
}
function envstg() {
env RAILS_ENV=staging $@
}
$ be rails server
# launches Rails server
$ envstg be rails server
env: be: No such file or directory
Here be
isn't expanded into bundle exec. How can I expand them?
(envbar && envfoo) | grep ENV_
? – cuonglm Sep 22 '14 at 3:52