split() {
  # disable globbing.
  # this ensures that the word-splitting is safe.
  set -f
  # store the current value of 'IFS' so we can restore it later.
  old_ifs=${IFS}
  # change the field separator to what we're splitting on.
  IFS=$2
  # create an argument list splitting at each occurance of '$2'.
  #
  # we do want word splitting, so we won't put double quotes around it
  # shellcheck disable=SC2086
  set -- $1
  # print each list value on its own line.
  printf '%s\n' "$@"
  # restore the value of 'IFS'.
  IFS=${old_ifs}
  # re-enable globbing.
  set +f
}

# split "1, 2, 3, 4, 5" ", "
# 1
# 2
# 3
# 4
# 5
