S
Steven Woody
i wrote the following bash script:
,----[ test-eof.sh ]
| #!/bin/bash
|
| cat - | ./test-eof << EOF
| hello
| world
| EOF
|
`----
and hope it will end and exit when encount the EOF. but it did _not_ until i
pressed an extra newlin.
the test-eof program is a simple c code:
,----[ test-eof.c ]
|
| int main(int argc, char *argv[])
| {
| char buf[1024];
| while (fgets(buf, 1024, stdin) != NULL)
| ;
| return 0;
| }
`----
would anyone please tell me why and how to fix it? thanks.
--
steven woody (id: narke)
Jesse: I heard this story once about when the Germans were occupying
Paris and they had to retreat back. They wired Notre Dame to blow,
but they had to leave one guy in charge of hitting the switch. And
the guy, the soldier, he couldn't do it. You know, he just sat
there, knocked out by how beautiful the place was. And then when
the allied troops came in, they found all the explosives just
lying there and the switch unturned, and they found the same thing
at Sacre Couer, Eiffel Tower. Couple other places I think...
Celine: Is that true?
Jesse: I don't know. I always liked the story, though.
- Before Sunset (2004)
,----[ test-eof.sh ]
| #!/bin/bash
|
| cat - | ./test-eof << EOF
| hello
| world
| EOF
|
`----
and hope it will end and exit when encount the EOF. but it did _not_ until i
pressed an extra newlin.
the test-eof program is a simple c code:
,----[ test-eof.c ]
|
| int main(int argc, char *argv[])
| {
| char buf[1024];
| while (fgets(buf, 1024, stdin) != NULL)
| ;
| return 0;
| }
`----
would anyone please tell me why and how to fix it? thanks.
--
steven woody (id: narke)
Jesse: I heard this story once about when the Germans were occupying
Paris and they had to retreat back. They wired Notre Dame to blow,
but they had to leave one guy in charge of hitting the switch. And
the guy, the soldier, he couldn't do it. You know, he just sat
there, knocked out by how beautiful the place was. And then when
the allied troops came in, they found all the explosives just
lying there and the switch unturned, and they found the same thing
at Sacre Couer, Eiffel Tower. Couple other places I think...
Celine: Is that true?
Jesse: I don't know. I always liked the story, though.
- Before Sunset (2004)