Question: Create a microshell, myshell, that adheres to the following requirements. The program will be written in C. myshell will parse the user input. myshell has
Create a microshell, myshell, that adheres to the following requirements. The program will be written in C. myshell will parse the user input. myshell has its own set of built-in commands.
- myshell will read the user input from stdin, one line at a time.
- myshell will parse the user input into a list of arguments. Assume that only whitespace is used to separate the arguments from each other. Assume no quoting or backslash escaping will be used.
- myshell will execute the command. If the input is one of the built-in commands, myshell will execute the built-in command. Otherwise, it will execute the default Unix command.
- myshell will be terminated if the user enters the command exit.
- myshell will parse the line (user input) to separate it into an array of strings.
- The built-in commands are:

//builtin.c
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "builtin.h"
#include
//Prototypes
static void exitProgram(char** args, int argcp);
static void cd(char** args, int argpcp);
static void pwd(char** args, int argcp);
/* builtIn
* built in checks each built in command the given command, if the given command
* matches one of the built in commands, that command is called and builtin returns 1.
* If none of the built in commands match the wanted command, builtin returns 0;
*/
int builtIn(char** args, int argcp) {
//write your code
}
static void exitProgram(char** args, int argcp) {
//write your code
}
static void pwd(char** args, int argpc) {
//write your code
}
static void cd(char** args, int argcp) {
//write your code
}
//builtin.h
#ifndef BUILTIN_H
#define BUILTIN_H
/*BuiltIn
* args args is an array of char*'s that contain a command and the arguements
* that command
* argcp - The count of how many arguments are in args
* returns 1 if it finds a builtin command to run, returns 0 otherwise
*/
int builtIn(char** args, int argcp);
#endif
o exit [value]: exit the shell with the value. If value is not given, exit with value 0. This built-in command should call the exit(3) libra call. Hint: man 3 atoi. pwd: it will print the current working directory. Sample output: % pwd /some/path/to/directory o cd: it will change the current working directory. Consider reading the man page for chdir(2). Sample output: % pwd /some/path/to/directory % cd .. % pwd /some/path/to
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
