-
I'm trying to define a recipe that needs to source a file @cs-change-java:
cs java --jvm $(cs java --installed | fzf | cut -d ' ' -f1) --setup # this command modifies .zprofile, which sets JAVA_HOME
source ~/.zprofile the last line of the code does not work, I'd have to restart the terminal for changes in previously, before using JUST, i'd just define a function #changes java version
function changeJava() {
cs java --jvm $(cs java --installed | fzf) --setup
source ~/.zprofile
} and that would work fine, but it seems like JUST is running the command in a sub-shell and it does not export JAVA_HOME in a parent shell, can you confirm if that is what is happening? and can you maybe suggest a workaround? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
That's correct. Each line of a recipe is, by default, executed in a new subshell. You can make just execute the whole recipe as a script, using a shebang, but that doesn't solve your problem. Just is a child process of your interactive shell, and it has no way of forcing the parent shell to reload its configuration. It isn't pretty, but one workaround would be to execute your shell recursively: @cs-change-java:
cs java --jvm $(cs java --installed | fzf | cut -d ' ' -f1) --setup # this command modifies .zprofile, which sets JAVA_HOME
zsh Or run it on the command line like this:
|
Beta Was this translation helpful? Give feedback.
That's correct. Each line of a recipe is, by default, executed in a new subshell. You can make just execute the whole recipe as a script, using a shebang, but that doesn't solve your problem.
Just is a child process of your interactive shell, and it has no way of forcing the parent shell to reload its configuration.
It isn't pretty, but one workaround would be to execute your shell recursively:
Or run it on the command line like this: