For my "cygrun.exe" wrapper to work it should be behind shebang scripts in the PATH, so moved ~/usr/bin to the PATH end on Cygwin.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Wed, 02 Jun 2021 21:46:48 +0300
changeset 986 080abbbb7ba7
parent 985 5bcbe7b57749
child 987 e0ffdc132f41
For my "cygrun.exe" wrapper to work it should be behind shebang scripts in the PATH, so moved ~/usr/bin to the PATH end on Cygwin.
.env.bash
--- a/.env.bash	Wed Jun 02 18:25:56 2021 +0300
+++ b/.env.bash	Wed Jun 02 21:46:48 2021 +0300
@@ -22,9 +22,6 @@
 # Easy cd to often used dirs.
 export CDPATH=.:$HOME:$HOME/devel:$HOME/my
 
-if [[ :$PATH: != *:$HOME/usr/bin:* ]]; then
-  export PATH=$PATH:$HOME/usr/bin
-fi
 if [[ :$PATH: != *:/usr/sbin:* ]]; then
   export PATH=/usr/sbin:$PATH
 fi
@@ -38,6 +35,17 @@
 if [[ :$PATH: != *:$HOME/.local/bin:* ]]; then
   export PATH=$PATH:$HOME/.local/bin
 fi
+if [[ :$PATH: =~ (.*):$HOME/usr/bin:(.*) ]]; then
+  # For my "cygrun.exe" wrapper to work it should be behind shebang scripts in the PATH.
+  if [[ $OSTYPE = cygwin ]]; then
+    [[ ${BASH_REMATCH[1]:0:1} = : ]] && _left=${BASH_REMATCH[1]:1}
+    [[ ${BASH_REMATCH[2]: -1} = : ]] && _right=${BASH_REMATCH[2]:0: -1}
+    PATH=$_left:$_right:$HOME/usr/bin
+    unset _left _right
+  fi
+else
+  export PATH=$PATH:$HOME/usr/bin
+fi
 
 
 if [[ -z $LD_LIBRARY_PATH ]]; then