summaryrefslogtreecommitdiffstats
path: root/modules/str.inc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/str.inc')
-rw-r--r--modules/str.inc26
1 files changed, 26 insertions, 0 deletions
diff --git a/modules/str.inc b/modules/str.inc
new file mode 100644
index 0000000..6179033
--- /dev/null
+++ b/modules/str.inc
@@ -0,0 +1,26 @@
+#!/bin/ash
+
+str_trim() {
+ if [ $# = 0 ]; then
+ tr '\n' '\r' | sed -r 's/^[[:space:]]+//;s/[[:space:]]+$//' | tr '\r' '\n'
+ else
+ printf "%s" "$*" | tr '\n' '\r' | sed -r 's/^[[:space:]]+//;s/[[:space:]]+$//' | tr '\r' '\n'
+ fi
+}
+
+str_upper() {
+ if [ $# = 0 ]; then
+ tr 'a-z' 'A-Z'
+ else
+ printf "%s" "$*" | tr 'a-z' 'A-Z'
+ fi
+}
+
+str_lower() {
+ if [ $# = 0 ]; then
+ tr 'A-Z' 'a-z'
+ else
+ printf "%s" "$*" | tr 'A-Z' 'a-z'
+ fi
+}
+