Fixed horrible Bash regex performance matching with two placeholders. Instead use fast one and extract remaining part.
--- a/.env.bash Wed Jun 16 14:48:32 2021 +0300
+++ b/.env.bash Wed Jun 16 15:24:53 2021 +0300
@@ -23,9 +23,9 @@
export CDPATH=.:$HOME:$HOME/devel:$HOME/my
my_path_prune() {
- if [[ :$1: =~ (.*):$2:(.*) ]]; then
+ if [[ :$1: =~ (.*):$2: ]]; then
local left=${BASH_REMATCH[1]}
- local right=${BASH_REMATCH[2]}
+ local right=${1:$((${#left} + ${#2} + 1))}
[[ ${left:0:1} = : ]] && left=${left:1}
[[ ${right: -1} = : ]] && right=${right:0: -1}
if [[ -z $left ]]; then