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

Pipes and Redirection #15

Open
1 of 4 tasks
jorinvo opened this issue Jul 27, 2016 · 5 comments
Open
1 of 4 tasks

Pipes and Redirection #15

jorinvo opened this issue Jul 27, 2016 · 5 comments

Comments

@jorinvo
Copy link
Member

jorinvo commented Jul 27, 2016

We already have some chapters prepared for our game to teach about pipes | and redirection< / >.

This can be implemented in a generic way in the .run() system method.

The command interface is already designed in a way to allow streaming of input and output.

  • |
  • <
  • >
  • >>
This was referenced Jul 27, 2016
@LordRatte
Copy link

Hi. Is there documentation on how to implement piping?

@jorinvo
Copy link
Member Author

jorinvo commented Nov 2, 2017

Hi @LordRatte! Thanks for your interest. Would you like to help adding pipes to bash-emulator?

To implement pipes, the run() method needs to be modified to detect the | pipes in the input string and it would need to initialize multiple commands, chaining their output and input together.

Input is described here but currently not implemented in any of the commands.

The only existing command that can use input is cat. To add input support to cat, it would need to detect if there are no arguments passed and in that case return the input and close callbacks.

To summarize, only run and cat need to be modified. After pipes are implemented you should be able to run a command like cat myfile.txt | cat | cat.

Please let me know if you have any questions!

@LordRatte
Copy link

Hi, jorinvo. Sorry, I misunderstood. I thought you were saying that it was already available to be used. I would love to help out but I wouldn't even know how to start.

jorinvo added a commit that referenced this issue Nov 4, 2017
Shell supports pipes | now. For now cat is the only command that
actually uses stdin though. Also fixed some other consistency issues and
a few missing tests.

See #15.
jorinvo added a commit that referenced this issue Nov 4, 2017
Shell supports pipes | now. For now cat is the only command that
actually uses stdin though. Also fixed some other consistency issues and
a few missing tests.

See #15.
@jorinvo
Copy link
Member Author

jorinvo commented Nov 4, 2017

Good news! I added the pipes functionality.
@LordRatte you can try it at https://trybash.github.io/bash-emulator/
with some command like ls -l | cat -n.

@LordRatte
Copy link

Hey, that's pretty cool @jorinvo . Thanks, man.

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

No branches or pull requests

2 participants