BMDan / tuning-primer.sh

MySQL Tuning-Primer.sh, updated and improved
GNU General Public License v2.0
497 stars 116 forks source link

Recursive call to cecho? #6

Closed gamcall closed 5 years ago

gamcall commented 5 years ago

Hi - I’m wondering if you meant to call cechon() here instead of where you recursively call cecho()?

function cecho()
{
  if [ -z "${1-}" ]; then
    cecho "No message passed.\n" "${2-}"
    return $?
  fi
  cechon "$1"$'\n' "${2-}"
  return $?
}
BMDan commented 5 years ago

This triggers only if $1 is empty or unset. Since the recursive call sets $1 in the recursion (to No message passed.\n), it won't recurse infinitely.

You are right, however, that there's an inexplicable use of a literal \n there. That's confusing; it should either be eliminated, or the line should be changed to cechon and \n replaced with $'\n'. Of those, I chose the option that only requires a single change.