Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a minishell using the template code below * Implement function type_prompt

ID: 3791721 • Letter: W

Question

Write a minishell using the template code below
* Implement function type_prompt( )

* Making read_command( ) work could be a little more involved.

* Note that the command contains the first argument, the file name, while parameters contain all information of input line in any arrays of strings, including the executable file name, same as in the command, as its first string. For example the command ssh -1 joe pluto.hood.edu is stored as

parameter[0]: /usr /bin/ ssh

parameter[1]: -1

parameter[2]: joe

parameter[3]: pluto.hood.edu

parameter[4]: NULL

Donot forget to initialize a dynamic string, before filling it with characters.

Some of the most commonly used commands are built in command handled by shell,for example, exit. You will not be able to test these commands unless you implement within your shell program. Built in commands is processed by the shell program without invoking the fork-exec() loop.

#define TRUE 1
while (TRUE) {                   /* repeat forever */

type prompt( );                 /* display prompt on the screen */

read command(command, parameters); /* read input from terminal */

if (for k() != 0) {                         / * fork off child process */

/* Parent code. */

waitpid(1, &status, 0);              /* wait for child to exit */

}else {

/* Child code. */

execve(command, parameters, 0);     /* execute command */ }

}

Explanation / Answer

#define TRUE 1
while (TRUE) {                   /* repeat forever */

type prompt( );                 /* display prompt on the screen */

read command(command, parameters); /* read input from terminal */

if (for k() != 0) {                         / * fork off child process */

/* Parent code. */

waitpid(1, &status, 0);              /* wait for child to exit */

}else {

/* Child code. */

execve(command, parameters, 0);     /* execute command */ }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote