I've got a work environment in which I frequently build binaries and then kick off long-running processes using that binary. While these are running, I would like to switch to another git branch and do some work there, and potentially build some new binaries that wouldn't overwrite the ones currently running.
Right now, the build and run scripts use a $OUT_DIR
env variable to determine the output dir for binaries. Ideally, I would like to have $OUT_DIR
be branch-specific to avoid the above mentioned problem of builds overwriting each other.
At first, this seemed like a simple job for the post-checkout hook -- set OUT_DIR
to be OUT_DIR_BASE + "/" + current branch
... except post-checkout hook runs in a child shell so it can't set parent env variables.
Are there any clever ways to get around this?
Some ideas I've considered:
- I could output the "
export OUT_DIR...
" command to a file and make the user source it -- that's annoying and people will forget to do it. - I could write the new
OUT_DIR
into an .rc file and have build/run scripts pick it up from there, but that requires changes to the build environment, and user experience gets a bit worse (i.e. you can't do "cd $OUT_DIR
" to get into the output directory... - I could write a wrapper for '
git checkout
' that would open a new shell withOUT_DIR
set appropriately... but that's "leaking" shells where over time I'd have quite a large number running.
None of these seem very nice for what feels like should be an easy solution.