Data Structures | Functions

shellutils.h File Reference

Helper functions for shell implementations. More...

#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  ShCommand

Functions

void shPrompt (void)
 Prints a prompt symbol including the working directory.
ShCommandshParseCmdLine (char cmdLine[])
 Parses a command line.
void shPrintStatus (const char cmdLine[], int status)
 Prints the status of a terminated or stopped child process.

Detailed Description

Helper functions for shell implementations.


Function Documentation

ShCommand* shParseCmdLine ( char  cmdLine[]  ) 

Parses a command line.

This function parses a command-line string that may contain '&' (for background execution) as well as '<' and '>' for stdin and stdout redirection, respectively. shParseCmdLine() will generate the argv array for the given command line and return an ShCommand structure containing the result. The ShCommand structure is dynamically allocated and needs to be free'd by the caller.

Parameters:
cmdLine The command line to be parsed. cmdLine is tokenized during parseCommandLine.
Returns:
Pointer to the parsed ShCommand or NULL on error, with errno set appropriately. In case a custom error message is supplied, the function returns a ShCommand structure that has the parseError field set to a custom error message. If the parseError field is set to a value other than NULL, parsing the command line has failed and the remaining fields of the ShCommand structure must not be interpreted.
Note:
This function is not reentrant.
void shPrintStatus ( const char  cmdLine[],
int  status 
)

Prints the status of a terminated or stopped child process.

Parameters:
cmdLine Command line of the child process.
status Process status as returned by waitpid().
Note:
This function is reentrant.
void shPrompt ( void   ) 

Prints a prompt symbol including the working directory.

Note:
This function is reentrant.
 All Data Structures Files Functions Variables