Subject: Re: small hack
To: None <perry@piermont.com, tech-userlevel@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-userlevel
Date: 09/23/1998 05:28:07
On Sep 22,  6:24pm, perry@piermont.com ("Perry E. Metzger") wrote:
-- Subject: small hack

I would like to see some more functionality of this:
	- if no arguments are given, it reads lines from stdin
	  and prints the lines in random order.
	- if the -p <n> is given, <n> random items are printed.
	  p stands for pick


And fix the following:
	- assign copyright to TNF.
	- make it use conditional prototypes.
	- use strtol instead of atoi to identify erroneous input from
	  negative numbers.
	- add return 0 in the end of main.
	- don't use errx in usage it would print the program name in usage
	  twice; use fprintf("Usage: %s ...\n", __progname); I think at
	  this point we should add a usage() function in libc that is
	  printf like, since so many programs do this:

#include <stdio.h>
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include <stdlib.h>
#include <util.h>

void
#ifdef __STDC__
usage(int eval, const char *fmt, ...)
#else
usage(va_alist)
	va_dcl
#endif
{
	va_list ap;
#ifndef __STDC__
	int eval;
	const char *fmt;

	va_start(ap);
	eval = va_arg(ap, int);
	fmt = va_arg(ap, const char *);
#else
	va_start(ap, fmt);
#endif
	(void)fprintf(stderr, "Usage: %s ", __progname);
	(void)vfprintf(strderr, fmt, ap);
	va_end(ap);
	exit(eval);
}