/*
 * 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1987
 * LICENSED MATERIALS - PROPERTY OF IBM
 * REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
 */
/* $Header:onechar.c 12.0$ */
/* $ACIS:onechar.c 12.0$ */
/* $Source: /ibm/acis/usr/sys/dist/etc/RCS/onechar.c,v $ */

#ifndef lint
static char *rcsid = "$Header:onechar.c 12.0$";
#endif

#define isprint(ch)	((ch >= ' ') && (ch <= '~'))
#include <sgtty.h>
struct sgttyb ttyb;

main (argc)
{
	char ch;
	gtty (0, &ttyb);
	ttyb.sg_flags |= CBREAK;
	ttyb.sg_flags &= ~ECHO;
	stty (0, &ttyb);
	read(0,&ch,1);
	write(1,&ch,1);
	if (argc < 2) {
		if (isprint(ch)) write(2,&ch,1);
		write(2,"\n",1);
	}
	ttyb.sg_flags &= ~CBREAK;
	ttyb.sg_flags |= ECHO;
	stty(0, &ttyb);
	exit(0);
}
