# HG changeset patch # User Oleksandr Gavenko # Date 1623846293 -10800 # Node ID 582cddcfb6a6119f225f6d20ce67d93fe08c2828 # Parent 5b3759d3d789dc6bba03202cdd21b4f550e30cac Fixed horrible Bash regex performance matching with two placeholders. Instead use fast one and extract remaining part. diff -r 5b3759d3d789 -r 582cddcfb6a6 .env.bash --- 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