summaryrefslogtreecommitdiffstats
path: root/helper/string.inc
diff options
context:
space:
mode:
authorSimon Rettberg2013-06-06 18:10:24 +0200
committerSimon Rettberg2013-06-06 18:10:24 +0200
commit43529b374c7da943cfab5773e70cb174c943afe7 (patch)
treec76d40bf0fa7130a5a9f264207a81ff6fb76badb /helper/string.inc
parentMerge branch 'master' of simonslx:openslx-ng/tm-scripts (diff)
downloadtm-scripts-43529b374c7da943cfab5773e70cb174c943afe7.tar.gz
tm-scripts-43529b374c7da943cfab5773e70cb174c943afe7.tar.xz
tm-scripts-43529b374c7da943cfab5773e70cb174c943afe7.zip
[helper] Add key-value util
Can be used to add simple key-value-pairs to files. It will error if the given key already exists and has a different value. If it does not exist in the target file, it will be appended/created. Otherwise, nothing will be done.
Diffstat (limited to 'helper/string.inc')
-rw-r--r--helper/string.inc5
1 files changed, 5 insertions, 0 deletions
diff --git a/helper/string.inc b/helper/string.inc
index 9f18e4e0..04809a93 100644
--- a/helper/string.inc
+++ b/helper/string.inc
@@ -7,6 +7,11 @@ trim() {
echo -n "$var"
}
+# Inline version of trim, use when piping
+itrim () {
+ sed -r 's/^\s+//g;s/\s+$//g'
+}
+
# usage: CANONICALIZED_STRING=$(canonalize <path>)
# usage with relative path requires you to be in the correct directory.
canonicalize() {