general: Swap echo to printf

This commit is contained in:
Dylan Araps 2018-04-01 14:30:06 +10:00
parent 81db772a5d
commit a1044d728f
1 changed files with 3 additions and 12 deletions

View File

@ -3263,19 +3263,10 @@ get_bold() {
}
trim() {
# When a string is passed to "echo" all trailing and leading
# whitespace is removed and inside the string multiple spaces are
# condensed into single spaces.
#
# The "set -f/+f" is here so that "echo" doesn't cause any expansion
# of special characters.
#
# The whitespace trim doesn't work with multiline strings so we use
# "${1//[[:space:]]/ }" to remove newlines before we trim the whitespace.
set -f
# shellcheck disable=2086
builtin echo -E ${1//[[:space:]]/ }
# shellcheck disable=2048,2086
set -- $*
printf "%s\\n" "${*//[[:space:]]/ }"
set +f
}