Prompting for yes/no in csh
Darin McGrew
mcgrew at ichthous.Eng.Sun.COM
Wed Jan 9 04:24:18 AEST 1991
dkeber at umaxc.weeg.uiowa.edu (Dave Keber) writes:
>What is the easiest way to prompt for a yes/no (or any string/number, etc.)
>from a csh shell script?
The standard way is to use the pseudo-variable "$<" as follows--
#!/bin/csh
echo -n "Really [yn]? "
set answer = "$<"
echo "You answered '$answer'"
>I thought of writing a short C program that asks for input then writing the
>answer to standard output, and then calling that program in my shell script,
>but that seems a rather convoluted way of going about it...or is it?
Well, yes, it's convoluted. But you don't have to write a new
tool to do it this way--
#!/bin/csh
echo -n "Really [yn]? "
set answer = "`head -1`"
echo "You answered '$answer'"
Darin McGrew mcgrew at Eng.Sun.COM
Affiliation stated for identification purposes only.
More information about the Comp.unix.shell
mailing list