git-for-windows / git

A fork of Git containing Windows-specific patches.
http://gitforwindows.org/
Other
8.43k stars 2.56k forks source link

Check existance of $HOME/bin before adding to PATH #5294

Open bohni opened 2 days ago

bohni commented 2 days ago

It's just an optimization for a *nix shell script. The behaviour is still present in current main branch.

https://github.com/git-for-windows/build-extra/blob/6735402549b1776f65723e129b9208fa0ee5056b/git-extra/env.sh#L2

export PATH="$HOME/bin:$PATH"

the PATH should only be extended, if the directory exists and is not already included in PATH

if [ -d ${HOME}/bin ]
then
  if [[ ! $PATH = *${HOME}/bin* ]]
  then
    export PATH="$HOME/bin:$PATH"
  fi
fi

Maybe the second test (that PATH already includes the directory) must be omitted because not every shell supports this check.

dscho commented 2 days ago

I would consider this a feature rather than a bug, as non-existing components should be ignored, but you can always create the ~/bin folder later and it would be picked up automatically.

What is the exact problem you are trying to solve?

bohni commented 20 hours ago

Yes, it's a feature request, not a bug. But github only has "new issue"...

The reason is, that I spend quite a while searching my own startup scripts (not only bash, because I'm in this case on windows), looking for the place, why this directory is in my PATH variable and I didn't find it there, because in these scripts that check is used...

I based my bash scripts on the debian .profile (https://sources.debian.org/src/bash/5.2.32-1/debian/skel.profile/) and expanded it with this second check.

dscho commented 19 hours ago

Okay, I understand the intention now.