From 20ab6f936596bcff3a0aa8bd717e359f94dd2569 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 22 Jan 2019 01:46:05 +0300 Subject: cxx.sh: add apport_gdb --- %HOME%/.bash_utils/text.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to '%HOME%/.bash_utils/text.sh') diff --git a/%HOME%/.bash_utils/text.sh b/%HOME%/.bash_utils/text.sh index da21b5c..4bda806 100644 --- a/%HOME%/.bash_utils/text.sh +++ b/%HOME%/.bash_utils/text.sh @@ -65,7 +65,7 @@ _sed_escape_substitution() ( echo "$s" ) -str_replace() ( +file_replace() ( set -o errexit -o nounset -o pipefail if [ "$#" -lt 3 ]; then @@ -83,7 +83,7 @@ str_replace() ( sed --binary --in-place -- "s/$old/$new/g" "$@" ) -str_replace_word() ( +file_replace_word() ( set -o errexit -o nounset -o pipefail if [ "$#" -lt 3 ]; then @@ -101,6 +101,23 @@ str_replace_word() ( sed --binary --in-place -- "s/\\b$old\\b/$new/g" "$@" ) +str_replace() ( + set -o errexit -o nounset -o pipefail + + if [ "$#" -ne 3 ]; then + echo "usage: ${FUNCNAME[0]} STR SUB REP" >&2 + return 1 + fi + + local str="$1" + local sub="$2" + local rep="$3" + + sub="$( _bash_escape_pattern "$sub" )" + + echo "${str//$sub/$rep}" +) + str_tolower() ( set -o errexit -o nounset -o pipefail -- cgit v1.2.3