From 8f151d797b015b7d1070151e75d56587a7f3652f Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 22 Mar 2013 22:33:40 +0100 Subject: Work-in patch from Jan Engehardt for working around different improper bash implementations of string-in-string replacing. (Fixes: #145). --- debian/Makefile.replace.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 debian/Makefile.replace.sh (limited to 'debian/Makefile.replace.sh') diff --git a/debian/Makefile.replace.sh b/debian/Makefile.replace.sh new file mode 100644 index 000000000..d47d92bf4 --- /dev/null +++ b/debian/Makefile.replace.sh @@ -0,0 +1,27 @@ +# from http://mywiki.wooledge.org/BashFAQ/021 + +string_rep() +{ + # initialize vars + in=$1 + unset out + + # SEARCH must not be empty + test -n "$2" || return + + while true; do + # break loop if SEARCH is no longer in "$in" + case "$in" in + *"$2"*) : ;; + *) break;; + esac + + # append everything in "$in", up to the first instance of SEARCH, and REP, to "$out" + out=$out${in%%"$2"*}$3 + # remove everything up to and including the first instance of SEARCH from "$in" + in=${in#*"$2"} + done + + # append whatever is left in "$in" after the last instance of SEARCH to out, and print + printf '%s%s\n' "$out" "$in" +} -- cgit v1.2.3