X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=sh-lib;h=5d0ac5bb884bd359de8120dc6c7e43cea0fe113c;hb=ca40690faf40a28d31777061d5055e55d7e8b0cd;hp=85d3c567009d11c1453b76734c3fd15fc275a442;hpb=f79a8430d62172984587bc0be525f0b5fc74f4ae;p=grml-shlib.git diff --git a/sh-lib b/sh-lib index 85d3c56..5d0ac5b 100644 --- a/sh-lib +++ b/sh-lib @@ -370,6 +370,26 @@ function relToAbs echo "$abspath_" } + +# Trim off white-space characters +# white-space in the "C" and "POSIX" locales are: +# space +# form-feed ('\f') +# newline ('\n') +# carriage return ('\r') +# horizontal tab ('\t') +# vertical tab ('\v') +function stringTrim +{ + local str_="$1" + local result_="" + + result_="`echo "$str_" | sed -e 's/^\s*//' -e 's/\s*$//'`" || \ + warn "stringTrim(): Problems stripping of blanks" || return 1 + dprint "stringTrim(): \"$str_\" => \"$result_\"" + echo "$result_" +} + # Simple shell grep function stringInFile {