#!/bin/bash

# J.Kobus klucz/2017

trap cleanup INT 

function cleanup {
     rm -f zero >& /dev/null
     exit
}

function help {
    echo usage: $0 [-v] [sleep [ bs [ count ]]]
}

verbose=0
while getopts "hv" option; do
    case $option in
	h) help; exit 0;;
	v) verbose=1;;
	*) echo "Blad: nieznana opcja";
	   exit 10;
    esac
done

shift $((OPTIND-1))


sleep=${1:-0.05}
bs=${2:-1M}
count=${3:-10}

i=0
while ((1 >0 )); do
    let i++
    echo -e sleep=$sleep bs=$bs count=$count "\t" $i 
    if [[ $verbose == 0 ]]; then
	dd if=/dev/zero of=zero bs=$bs count=$count >& /dev/null
    else
	dd if=/dev/zero of=zero bs=$bs count=$count
    fi
    sleep $sleep                                                                                            
done                                                  
