#!/usr/bin/muawk
# rustic pr (by M. Andreoli, public domain)

BEGIN	{
	n=split(arg,opts)	
	opt=opts[1];
	
	if (opt=="-h" )
		{
		print "(rustic) pr -- Format text on many columns" 
		print "Usage: pr [-h] [-columns] (stdin only)"
		exit
		}

	if (n==0) col="1";
        else
                col=-opts[1];

# init
	split ("80 40 26 20 16 13 11 10 8 8",size);
	count=0
	fmt="%-" size[col] "." size[col] "s"
	}

	{ count++
	printf(fmt,$0);
	
	if ( (count % col) ==0 ) printf "\n";
	}

END	{
	printf "\n"
	}
