shellutils.h File Reference
Helper functions for shell implementations.
More...
Go to the source code of this file.
|
Data Structures |
struct | COMMAND |
| The COMMAND structure contains a parsed command. More...
|
Functions |
COMMAND * | parseCommandLine (char *cmdLine) |
| Parses a command line of possibly multiple subcommands.
|
void | printStat (const char *cmdLine, int status) |
| Prints the status of a terminated or stopped child process.
|
void | prompt () |
| Prints a prompt symbol including the working directory.
|
Detailed Description
Helper functions for shell implementations.
Function Documentation
COMMAND* parseCommandLine |
( |
char * |
cmdLine |
) |
|
Parses a command line of possibly multiple subcommands.
This function parses a command line string that may contain multiple subcommands separated by | operators. parseCommand will generate the argv arrays for all these subcommands and return a COMMAND structure containing the result. The COMMAND structure is dynamically allocated and needs to be free'd by the caller (i.e., YOU).
- Parameters:
-
| cmdLine | the cmdLine to be parsed. |
- Returns:
- pointer to the parsed COMMAND or NULL on error, with errno set appropriately. In case a custom error message is supplied, the function returns a COMMAND 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 COMMAND structure must not be interpreted.
void printStat |
( |
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 wait(2) |