I have a shell-function that executes a command within a sub-shell, after setting some environment variables, e.g.
$ with-env-overrides git status
It's implemented using eval in a sub-shell
with-env-overrides() {
(
source $HOME/.env-overrides
eval "$@"
)
}
this means I can make use of aliases, and shell-functions, e.g.
$ with-env-overrides gs
but unfortunately, eval gets confused when arguments contain spaces, or shell meta-characters, e.g.
$ with-env-overrides grep "foo bar" /etc/passwd
grep: bar: No such file or directory
How can I achieve this without using eval, but without loosing the ability to use aliases etc?