Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11454

Re: Why does a Bash shell script write prompts followed by reads and do it right?

From Bob Proulx <bob@proulx.com>
Newsgroups gnu.bash.bug
Subject Re: Why does a Bash shell script write prompts followed by reads and do it right?
Date 2015-09-01 14:25 -0600
Message-ID <mailman.356.1441139142.19560.bug-bash@gnu.org> (permalink)
References <CAAykW6m4H2sSshWNfv3mQr9q6ScKzLebqMBgEo96vRUSBY6SAQ@mail.gmail.com>

Show all headers | View raw


Robert Parker wrote:
> Yet when I attempt the same in a C program, the system always writes 2
> prompts, then waits for a read.

This isn't a C list.  But if you don't show us the code then no one
can give good help.

If you write, read, write and then it *must* try the read before the
second write.  If you are seeing the second write then it means that
the read returned after the first write.  What you say, writes two
prompts and then read doesn't make sense.

> Does not matter if I write(1, "..."); read(0, number, buffer); or use
> fputs("...", stdout); fgets(.....
> The result is the same.
> And I have tried using readline without any better result.

This sounds like you simply have some basic problem issue.  You will
need to figure that out first.  If you write(), if you fputs(), and
you are not seeing the output then start there.  Don't move on to
anything else until you understand that part of the problem.

Your problem is really one for discussion on a C programming list.

> I have downloaded the source code for Bash.
> Would someone please let me know where to look to learn to make my code
> work like yours?

That is the wrong direction to go.  It is like saying, I have this
problem building a small bike shed.  I couldn't figure it out.
Therefore I downloaded the plans to the Eiffel Tower in order to
compare the two.  They are not really comparable.  Trying to do so is
just a distraction from solving your real problem.

Bob

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Why does a Bash shell script write prompts followed by reads and do it right? Bob Proulx <bob@proulx.com> - 2015-09-01 14:25 -0600

csiph-web