drewdeponte / git-ps

Patch Stack workflow CLI extension for Git
MIT License
50 stars 4 forks source link

If users have echos in their `~/.bash_profile` it makes git-ps fail to find git #7

Closed drewdeponte closed 4 years ago

drewdeponte commented 4 years ago

This is because the way we find the path to git is by doing the following:

/bin/bash -l -c "which git"

The above creates a login shell (-l) and then has it execute the command which git (-c "which git"). So, when it loads a login shell which we want in case the user has different environment setup for their login shells that impact the location of git, it loads the ~/.bash_profile among other files.

I looked and it doesn't seem like there is any bash command line option to tell it to ignore any output from the configuration scripts for bash and just include the output of the command being run. So, the thinking now is just to do some smarter parsing. In this case all the output comes before the commands output so would could try and grab the last line in the output.

If the command doesn't actually provide any output but configuration scripts do it will think the output from the configuration script is the path to git and then will fail to execute it later on down the execution path. I am not sure this is ideal. But, it is probably better than the way it works currently.

drewdeponte commented 4 years ago

This is complete and in mainline.