dotar/zsh/0001_core.zsh

15 lines
280 B
Bash

trim() {
local var
if (( $# == 0 )) ; then
var=$(</dev/stdin)
else
var="$*"
fi
# remove leading whitespace characters
var="${var#"${var%%[![:space:]]*}"}"
# remove trailing whitespace characters
var="${var%"${var##*[![:space:]]}"}"
printf '%s' "$var"
}