On Mon, 22 Mar 1999, Shawn Craver wrote:
> Bogdan Taru wrote:
> >
> > I wanna make a shell (very simple - 4 commands only) and I want to
> > avoid the old programming problem of reading a string instead of a
> > character at a time (used for buffering overflow attacks). Could
What do you mean by shell here? Do you want a shell script or a C
program?
> > somebody point to me such a C function which reads only one character at
> > a time, without buffering the whole line before? I tried using getch()
> > from ncurses library, but realized it's not very useful in my program...
--skip--
> You might want to try getc().
If you want a C program, fgetc() does some checking.
According to the man page section (3), fgetc() returns EOF at the end of a
file. You might want to experiment with what it does with 'stdin', if
that's your intent.
If you want to do it in a shell script, I don't know any of the details of
how bash or tcsh handle this problem.
Good Luck,
Gordon A. Gallup Dept. of Physics and Astronomy
University of Nebraska-Lincoln Lincoln, NE 68588-0111
Voice: (402)472-1230 FAX: (402)472-2879
http://www.unl.edu/physics/