Pure Bash Bible – A collection of pure bash alternatives to external processes
I’m sorry, but I almost spit my drink out at how unreadable the very first example is.  trim_string() {
      # Usage: trim_string "   example   string    "
      : "${1#"${1%%[![:space:]]*}"}"
      : "${_%"${_##*[![:space:]]}"}"
      printf '%s\n' "$_"
  }