myshell 2.0.0
Loading...
Searching...
No Matches
connection_command Struct Reference

Connection command structure. More...

#include <msh_command.h>

Public Member Functions

int execute (int in=STDIN_FILENO, int out=STDOUT_FILENO, int flags=0)
 Execute the command.
 

Public Attributes

Token connector
 
command lhs
 
command rhs
 

Private Member Functions

int execute_conditional (int in, int out, int flags, TokenType op)
 Executes conditional connections, i.e. && and ||.
 
int execute_background (int in, int out, int flags)
 Executes background connections, i.e. &.
 
int execute_sequence (int in, int out, int flags)
 Executes sequential connections, i.e. ;.
 
int execute_pipeline (int in, int out, int flags)
 Executes pipeline connections, i.e. | and |&.
 

Detailed Description

Connection command structure.

Represents a connection between two commands. Holds a Token specifying the type of connection and two command structures.

On execute() the execution is delegated to the appropriate function depending on the type of connection.

See also
command
Token

Member Function Documentation

◆ execute()

int connection_command::execute ( int in = STDIN_FILENO,
int out = STDOUT_FILENO,
int flags = 0 )
inline

Execute the command.

Parameters
inFile descriptor to use as stdin.
outFile descriptor to use as stdout
flagsFlags to pass to the command.
Returns
Exit code of the command.

Executes the left-hand side command and then the right-hand side command with respect to the type of connection.

◆ execute_background()

int connection_command::execute_background ( int in,
int out,
int flags )
inlineprivate

Executes background connections, i.e. &.

Executes the left-hand side command and then the right-hand side command asynchronously.

Parameters
inFile descriptor to use as stdin.
outFile descriptor to use as stdout
flagsFlags to pass to the command.
Returns
Exit code of the command.

◆ execute_conditional()

int connection_command::execute_conditional ( int in,
int out,
int flags,
TokenType op )
inlineprivate

Executes conditional connections, i.e. && and ||.

If the left-hand side command returns 0 and the connection is && or if the left-hand side command returns non-zero and the connection is ||, the right-hand side command is executed.

Parameters
inFile descriptor to use as stdin.
outFile descriptor to use as stdout
flagsFlags to pass to the command.
opType of the connection.
Returns
Exit code of the command.

◆ execute_pipeline()

int connection_command::execute_pipeline ( int in,
int out,
int flags )
inlineprivate

Executes pipeline connections, i.e. | and |&.

Executes the left-hand side command and then the right-hand side command sequentially with the output of the left-hand side command piped to the input of the right-hand side command. If the connection is |&, the standard error of the left-hand side command is also piped.

Parameters
inFile descriptor to use as stdin.
outFile descriptor to use as stdout
flagsFlags to pass to the command.
Returns
Exit code of the command.

◆ execute_sequence()

int connection_command::execute_sequence ( int in,
int out,
int flags )
inlineprivate

Executes sequential connections, i.e. ;.

Executes the left-hand side command and then the right-hand side command sequentially.

Parameters
inFile descriptor to use as stdin.
outFile descriptor to use as stdout
flagsFlags to pass to the command.
Returns
Exit code of the command.

The documentation for this struct was generated from the following file: