Subject: Re: small hack
To: None <,>
From: Christos Zoulas <>
List: tech-userlevel
Date: 09/23/1998 05:28:07
On Sep 22,  6:24pm, ("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>
#include <varargs.h>
#include <stdlib.h>
#include <util.h>

#ifdef __STDC__
usage(int eval, const char *fmt, ...)
	va_list ap;
#ifndef __STDC__
	int eval;
	const char *fmt;

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