Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to add a history feature that allows a user to execute the most recent command by entering !!. For example, if a user

I need to add a history feature that allows a user to execute the most recent command by entering !!. For example, if a user enters the command ls -l, she can then execute that command again by entering !! at the prompt. Any command executed in this fashion should be echoed on the users screen, and the command should also be placed in the history buffer as the next command. Your program should also manage basic error handling. If there is no recent command in the history, entering !! should result in a message No commands in history. This is my code below. How do I add a history feature so that it is well incorporated with my code? Please help me. Thanks.

image text in transcribed

image text in transcribed

#include #include #include #include #include #include #define MAX_LINE 80 /* the maximum length command */ + == = void parse(char *line, char **argv) { while ("line != '\0') { while (*line || *line == '\t' || *line == ' ') *line++ TO'; *argv++ line; while (*line != '\0' && Sline ! *line != '\t' && "line != ' ') line++; } *argy 10'; } void execute(char **arg) { pid_t pid; int status; if ((pid = fork) "); fflush(stdout); fgets(line, sizeof line, stdin); printf(" "); parse(line, argv); if (strcmp(argv[@], "exit") ) exit(0); execute(argv); == After reading user input, the steps are; (1) fork a child process using fork) (2) the child process will invoke execup() (3) if command included &, paren will invoke wait() * **/ } return; } #include #include #include #include #include #include #define MAX_LINE 80 /* the maximum length command */ + == = void parse(char *line, char **argv) { while ("line != '\0') { while (*line || *line == '\t' || *line == ' ') *line++ TO'; *argv++ line; while (*line != '\0' && Sline ! *line != '\t' && "line != ' ') line++; } *argy 10'; } void execute(char **arg) { pid_t pid; int status; if ((pid = fork) "); fflush(stdout); fgets(line, sizeof line, stdin); printf(" "); parse(line, argv); if (strcmp(argv[@], "exit") ) exit(0); execute(argv); == After reading user input, the steps are; (1) fork a child process using fork) (2) the child process will invoke execup() (3) if command included &, paren will invoke wait() * **/ } return; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions

Question

=+ Have they changed the way employers view IP?

Answered: 1 week ago