Q:

Setting an environment variable from within the sbt shell

I would like to be able to set an environment variable from within the interactive sbt shell, and I can't seem to find a way to do that. (I have looked on the official sbt docs as well as on stackoverflow without success).
I want to make it clear that I don't want to have to set this environment variable in the build.sbt file, but rather be able to change it on the fly on my interactive sbt shell session, so that the environment variable is used for the next sbt commands I run.
For example, I would like to be able to do something like (from within the sbt shell):
> set_environment_variable("foo", "foo_value")
> `mymodule`/run
> (... program runs and completes)
> set_environment_variable("foo", "another_foo_value")
> `mymodule`/run

Is this possible? And if it is, how can I do it?

A:

Using sbt 0.13.15 the only thing I've found which has worked for me is to use eval.
> eval System.setProperty("foo", "foo_value")
> `mymodule`/run
> ...
> eval System.setProperty("foo", "another_foo_value")
> `mymodule`/run

