#!/usr/bin/env sh
# Split a string on a common delimiter
#
# Usage:
#
#   printf 'foo, bar, baz\n' | split-strings
#   printf '%s\n' foo bar baz | join-strings '-' | split-strings '-'

while getopts h opt; do
    case $opt in
    h) awk 'NR == 1 { next } /^$/ { exit } { print substr($0, 3) }' "$0"
       exit ;;
    esac
done
shift $(( OPTIND - 1 ))

awk -v delim="${1:-, }" '
    BEGIN { FS=delim }
    { for (i = 1; i <= NF; i += 1) print $i }
'
