diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2013-03-22 22:33:40 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2013-03-22 22:33:40 +0100 |
commit | 8f151d797b015b7d1070151e75d56587a7f3652f (patch) | |
tree | 2f16206b5d203ed56cf5ddd24fc9603cfdec7d0e /debian/Makefile.replace.sh | |
parent | 258902bec76cc4828ab7453df7406957ce93048a (diff) | |
download | nx-libs-8f151d797b015b7d1070151e75d56587a7f3652f.tar.gz nx-libs-8f151d797b015b7d1070151e75d56587a7f3652f.tar.bz2 nx-libs-8f151d797b015b7d1070151e75d56587a7f3652f.zip |
Work-in patch from Jan Engehardt for working around different improper bash implementations of string-in-string replacing. (Fixes: #145).
Diffstat (limited to 'debian/Makefile.replace.sh')
-rw-r--r-- | debian/Makefile.replace.sh | 27 |
1 files changed, 27 insertions, 0 deletions
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" +} |