Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding pipe_cin to examples dir #325

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wmarini
Copy link

@wmarini wmarini commented Oct 29, 2023

@flagarde That pull request addresses the use of an unnamed pipe to read input stream in a program that uses the cpp_terminal library, as mentioned in issue #320.
It introduces a new example in the examples directory called cin_pipe. For my initial tests, I executed the following commands:

When the example program is executed without any unnamed pipe:

$ echo -e "Testing std::cin\nTesting stdin" | build/debug/examples/pipe_cin Checking if std::cin is empty
std::cin => "Testing std::cin"
Checking if stdin is empty
stdin    => "Testing stdin"

When the example program is the consumer of a unnamed pipe from a cat command:

$ echo "testing std::cin" | build/debug/examples/pipe_cin 
Checking if std::cin is empty
std::cin => "testing std::cin"
Checking if stdin is empty
stdin    => ""

$ echo -e "Testing std::cin\nTesting stdin" | build/debug/examples/pipe_cin Checking if std::cin is empty
std::cin => "Testing std::cin"
Checking if stdin is empty
stdin    => "Testing stdin"

Please verify the program in Windows and Mac environments, as it has only been tested on Linux Ubuntu 22.04 (xterm). Note that it uses only POSIX and C++11 flavors, so I believe it should work in any environment.

@flagarde
Copy link
Collaborator

@wmarini Thx for the code. unfortunately it seems windows is not totallt POSIX compatible but we can use your code as basis to do one with windows support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants