changeset 525:b0fa9e7cadac

shell: speed things up by golfing out grep
author Augie Fackler <raf@durin42.com>
date Mon, 14 Nov 2022 10:46:11 -0500
parents 24f7a481d284
children 852565046ed0
files .shell.d/00.path_manipulation.sh
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/.shell.d/00.path_manipulation.sh
+++ b/.shell.d/00.path_manipulation.sh
@@ -12,9 +12,9 @@ function insert_element_into_var () {
   eval varcontents=\$"$2"
   eval varname="$2"
   newcomp="$1"
-  if echo "$varcontents" | grep "$newcomp:" >> /dev/null; then
+  if [[ "$varcontents" =~ "${newcomp}:" ]] ; then
     true
-  elif [[ "$varcontents" == "" ]] ; then
+  elif [[ -z "$varcontents" ]] ; then
     export $varname="$newcomp"
   else
     export $varname="$newcomp:$varcontents"