#!/bin/sh
VERSION=1.3.2
NAME=`basename $0`
NV="$NAME $VERSION:"
LICENSE="Copyright (C) 2006, 2007, 2009 Dimitar Ivanov

License: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law."

sep=`echo |awk '{printf( "%080s", 0 )}' |tr 0 -`
[ x$1 = x--help ] && set -- "-h" && NV="$NAME" && sep=""

case $1 in
     -h|"")
         cat << EOH && exit
$sep
$NV produces a series of equally-separated integers or floats
$sep

Usage: $NAME <begin> <end> [<step>] [<print_fmt>] or: $NAME <number>

EOH
         ;;
     --version)
         cat << !ver && exit
$NAME $VERSION
$LICENSE
!ver
         ;;
esac

ofmt="%.6g"

case $# in
     1) b=0;  e=$1; d=1;
     ;;
     2) b=$1; e=$2; d=1;
     ;;
     3) b=$1; e=$2; d=$3;
     ;;
     4) b=$1; e=$2; d=$3; ofmt=$4;
     ;;
     *) exit 1
     ;;
esac


              # Use e1 because of round-off errors at floating number addition
echo |awk "BEGIN { OFMT = \"$ofmt\"; e1 = $e + ($d/10); }
           {
             i = $b;
             while( i <= e1 )
             {
               print i;
               i = i + ($d);
             }
           }"
