Whitespace trim, handle multiline strings
This commit is contained in:
parent
dac32f3ab1
commit
64182e6ef7
1 changed files with 10 additions and 1 deletions
11
neofetch
11
neofetch
|
@ -2788,9 +2788,18 @@ getlinebreak () {
|
|||
|
||||
# Trim whitespace {{{
|
||||
|
||||
# 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 beofre we trim the whitespace.
|
||||
trim() {
|
||||
set -f
|
||||
builtin echo -E $1
|
||||
builtin echo -E ${1//[[:space:]]/ }
|
||||
set +f
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue