QuestionQuestion

This is to write a C shell which will behave quite similarly to the Linux shell bash and should display a prompt (imcshell>) at start-up. The user should then enter one of the shell commands (with appropriate options and arguments) at the prompt followed by Enter, and the shell should again display the prompt after processing the command. If a command is invalid the shell should display an appropriate error message.

The following command lines must be correctly executed (assume cmd is the name of an executable file, given either with the absolute path or relative):
cmd : create a new process which will execute cmd
cmd & : create a new process which will execute cmd in background
cmd > file : create a new process which will execute cmd with the standard output file descriptor changed by file given
cmd 2> file : idem with the standard error
cmd < file : idem with the standard input
cmd1 | cmd2 : create 2 new process with cmd1 standard output redirect to cmd2 standard input
cmd1 ! cmd2 : create 2 new process with cmd1 standard output redirect to cmd2 standard input and cmd2 standard output redirect to cmd2 standard input (note that this feature does not exist with bash - but exists with other shell languages
var=value : add variable var to a set of internal variables with value value. In following command lines resolution, the string "$var" must be replaced by "value"
export var : add internal variable var to the environment
help : internal command that prints help
cd dir : internal command that prints the current working directory
exit : internal command that terminates the program.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

// number of item in the array
#define MAX_TOKEN 500
// some rturned value
#define over 0 // end
#define con 1 // continue

#define true 1
#define false 0

// these variables are used in export command
int * exported;
char ** var;
char ** value;
int index_;

/* all functions in the program
*/
char * get_input();
char ** split(char * input, int * len, char * delim);

int spawn (char* program, char** arg_list);

char ** isSet(char ** array_cmd);
int one(char ** array_cmd);

void daemon(char ** array_cmd);
char * isVariable(char * cmd);
void two(char ** array_cmd);...
$125.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats