#!/bin/bash
#
# Michal 'GiM' Spadlinski
# 99-bottles-of-beer in bash
# 4pc0h f0rc3

unset k;
unset l;
bot=bottles;
i=99;

while :;
do
	echo "${i/no/No} ${bot:0:${k:-10}} of beer on the wall, $i ${bot:0:${k:-10}} of beer.";

	[ "$i" != "no more" ] || break;

	i=$((i-1));
	[ $i -eq 1 ] && k=$((${#bot}-1)) && ! : ||  [ $i -eq 0 ] && { i="no more"; unset k; };

	echo -e "Take one down and pass it around, ${i} ${bot:0:${k:-10}} of beer on the wall.\n\n"
done
echo "Go to the store and buy some more, 99 bottles of beer on the wall."
