From 6296bf3f8baab76a2a8a126e07a5a31249df28a7 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 12 Nov 2015 21:19:37 +0100 Subject: [PATCH] tests: fix path_without to handle /bin properly I was seeing /bin being left. This patch fixes it by anchoring the search pattern with ':' on both sides. --- test/test_helper.bash | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test_helper.bash b/test/test_helper.bash index 0c21dea7..b62cdc15 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -111,7 +111,7 @@ assert() { # but in which system utils necessary for rbenv operation are still available. path_without() { local exe="$1" - local path="${PATH}:" + local path=":${PATH}:" local found alt util for found in $(which -a "$exe"); do found="${found%/*}" @@ -123,8 +123,9 @@ path_without() { ln -s "${found}/$util" "${alt}/$util" fi done - path="${path/${found}:/${alt}:}" + path="${path/:${found}:/:${alt}:}" fi done + path="${path#:}" echo "${path%:}" }