diff -r b5c31b623dec -r 5b3759d3d789 .env.bash --- a/.env.bash Wed Jun 16 13:39:23 2021 +0300 +++ b/.env.bash Wed Jun 16 14:48:32 2021 +0300 @@ -22,26 +22,27 @@ # Easy cd to often used dirs. export CDPATH=.:$HOME:$HOME/devel:$HOME/my -function my_path_prune() { +my_path_prune() { if [[ :$1: =~ (.*):$2:(.*) ]]; then local left=${BASH_REMATCH[1]} local right=${BASH_REMATCH[2]} [[ ${left:0:1} = : ]] && left=${left:1} [[ ${right: -1} = : ]] && right=${right:0: -1} if [[ -z $left ]]; then - echo "$right" + my_path_prune=$right elif [[ -z $right ]]; then - echo "$left" + my_path_prune=$left else - echo "$left:$right" + my_path_prune=$left:$right fi else - echo "$1" + my_path_prune=$1 fi } -function my_path_preappend() { - PATH=$1:$(my_prune_path "$PATH" $1) +my_path_preappend() { + my_path_prune "$PATH" "$1" + PATH=$1:$my_path_prune } # For my "cygrun.exe" wrapper to work it should be behind shebang scripts in the PATH. @@ -54,6 +55,9 @@ my_path_preappend /usr/sbin my_path_preappend /sbin export PATH +unset -f my_path_preappend +unset -f my_path_prune +unset -v my_path_prune if [[ -z $LD_LIBRARY_PATH ]]; then LD_LIBRARY_PATH=$HOME/usr/lib