superxcgm / xcShell

Your own shell
1 stars 1 forks source link

Single pipe `|` #42

Closed superxcgm closed 3 years ago

superxcgm commented 3 years ago

Epic

Process

Description

For good user experience, user can add chain commands using pipeline

AC

Given: User type some_command (For example: echo ab) When: User hit Then: Print ab on console.

Given: User type some_command | another_command (For example:ls -l | grep 'hello') When: User hit Then: Should use output of first command as input of second command.

Out of Scope

Support of multi pipe, like command1 | command2 | command3

lq1149622825 commented 3 years ago

Technical knowledge used

  1. fork() multi-process programming
  2. pipe principle
  3. Redirection principle

    tsaking

  4. Split the command to get the set of command_parse_result;
  5. Get the set of command_pase_result, and get the part that needs "|" for processing according to the size
  6. Create two child processes. Colleagues process two commands, and write the output of the first command to the pipeline at the same time, and the second line of commands is processed from the read data
  7. refactor
lq1149622825 commented 3 years ago

9月22日

redirection bug

single Pipe line progress

Unresolved problem

lq1149622825 commented 3 years ago

9月23日

redirection bug

single Pipe line progress

mutil Pipe line progress

superxcgm commented 3 years ago

QA

Given: User type some_command (For example: echo ab) When: User hit Then: ✅Print ab on console.

Given: User type some_command | another_command (For example:ls -l | grep 'hello' ) When: User hit Then: ✅Should use output of first command as input of second command.