#!/usr/bin/env bash

if [ "$#" -eq 0 ]; then
  echo
  exit 0
fi

if [ "$1" = '-h' ] || [ "$1" = '--help' ]; then
  echo "Usage: $(basename "$0") [N]      print N blank lines (default: 1)"
  exit 0
fi

NB_BLANK_LINES="${1:-1}"

# shellcheck disable=SC2249
case "${NB_BLANK_LINES}" in
  -*) ;;
  *[!0-9]*)
    >&2 echo "ERROR: '${NB_BLANK_LINES}' is not a valid number of lines"
    exit 1
    ;;
esac

# if ! [[ "${NB_BLANK_LINES}" =~ ^-?[0-9]+$ ]]; then
#   >&2 echo "ERROR: '${NB_BLANK_LINES}' is not a valid number of lines"
#   exit 1
# fi

# negative number of lines means 0
if [ "${NB_BLANK_LINES}" -lt 0 ]; then
  exit 0
fi

# print the blank lines!
for i in $(seq "${NB_BLANK_LINES}"); do
  echo
done
