#!/usr/bin/env bash

inputs=("$@")
length=${#inputs[@]}
last_index=$((length - 1))

# Loop through the 'inputs' array, excluding the last element
for ((i=0; i<last_index; i++)); do
  current=${inputs[i]}
  next=${inputs[i+1]}

  # Check if the current element is empty
  if [[ -z $current ]]; then
    echo "And all for the want of a $next."
  else
    echo "For want of a $current the $next was lost."
  fi
done

# Check if the first element is empty
if [[ -z ${inputs[0]} ]]; then
  echo ""
else
  echo "And all for the want of a ${inputs[0]}."
fi