|
From: | John McKown |
Subject: | Re: Why does a Bash shell script write prompts followed by reads and do it right? |
Date: | Mon, 31 Aug 2015 12:34:18 -0500 |
Thanks, BobWould someone please let me know where to look to learn to make my code work like yours?I have downloaded the source code for Bash.The result is the same.Does not matter if I write(1, "..."); read(0, number, buffer); or use fputs("...", stdout); fgets(.....A trivial script example that just works:Yet when I attempt the same in a C program, the system always writes 2 prompts, then waits for a read.
#!/bin/bash
# echo a prompt and write the user's response to a file.
echo "Enter variable name: "
read ans
echo "$ans" > tmpfil
echo "Enter variable type: "
read ans
echo "$ans" >> tmpfil
echo "Enter variable default value: "
read ans
echo "$ans" >> tmpfil
echo "Beginning with an assignmment operator"
echo "Enter C code for this option:"
read ans
echo "$ans" >> tmpfil
And I have tried using readline without any better result.
--The Bundys, Cliven, Ted and Al. Great guys to look up to.
[Prev in Thread] | Current Thread | [Next in Thread] |