G-Node / gin-cli

Command line client for GIN
https://gin.g-node.org
Other
12 stars 6 forks source link

Return to original directory when Chdir is used #225

Open achilleas-k opened 5 years ago

achilleas-k commented 5 years ago

Some functions require changing the working directory. In older versions, we would use the Dir (working directory) field of exec.Command, but at some point it was changed to do os.Chdir() when needed.

This isn't a a problem when performing actions on the command line, since the runtime doesn't affect the working directory of the shell that called it. It does cause an issue when gin-cli functions are used by other projects, since they may call a function like CloneRepo() to clone a repository and on return the working directory of the calling program has changed.

This should be fixed for all functions that can be used externally, either by going back to setting the Dir of external commands and adjusting paths, or by deferring a os.Chdir() that restores the original working directory.