Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back 2.0 #13

Closed
mottosso opened this issue Jan 20, 2017 · 2 comments
Closed

Back 2.0 #13

mottosso opened this issue Jan 20, 2017 · 2 comments
Labels

Comments

@mottosso
Copy link
Contributor

Goal

Make moving backwards in mb.bat more predictable and stable.

Motivation

At the moment, back.bat performs the action of erasing previous changes - such as entering an asset - and taking you back to where you were before. It does so by erasing environment variables, but it couldn't erase those that were appended to e.g. PYTHONPATH without risking erasing more or less than it is supposed to.

:: Enter a project
set PYTHONPATH=/asset/scripts;%PYTHONPATH%

:: Back
:: How to erase an inserted path? Was there more than one inserted path? Who knows?
set PYTHONPATH=???;%PYTHONPATH%

Implementation

When typing cmd from an existing terminal, your current environment is duplicated and put into a new terminal session. At this point, you are in a shell within a shell. Basically like Inception. And like Inception, you can exit one session which would take you back to the previous session.

$ echo %MYVAR%
%MYVAR%
$ cmd
$ set MYVAR=Hello
$ echo %MYVAR%
Hello
$ exit
$ echo %MYVAR%
%MYVAR%

The above session illustrates this in action. A new session is entered, where we attempt to echo a variable we haven't yet created. We then enter a new session, create it and echo it successfully.

We then type exit which closes this session, restoring the environment to how it was before entering it. In this case, %MYVAR% is removed.

The same applies to appending to variables, such as PATH and PYTHONPATH. Modifying these in a session within a session enabled the user to exit and restore the previous environment.

@LegacyID1991
Copy link
Contributor

awesome explanation.
will look into this.

@mottosso
Copy link
Contributor Author

mottosso commented Mar 9, 2017

With Launcher on the horizon, this will no longer be necessary.

@mottosso mottosso closed this as completed Mar 9, 2017
aardschok added a commit to aardschok/core that referenced this issue Mar 13, 2018
tokejepsen pushed a commit to tokejepsen/core that referenced this issue Jun 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants