The history feature introduced in Lab 3 is not persistent, i.e. the shell program cannot keep the command history across different runs. To make it persistent, you need to modify your shell program to save the contents of the history buffer into a file before it exits. In addition, the shell program needs to reload the previous commands from the saved history file once you start the program. You can name the command history file as "your-userid>.history". For the first time execution of your shell program, the history buffer should be empty and you can create such history file when exiting the program More specifically, you need to modify the main0 function and possibly other related functions as well in the file shell.c. In the initialization phase, you need to check the existence of the command history file. If it exists, you should open the file and load the command history into the history buffer. Otherwise, you just initialize the history buffer as empty buffer. At the end of the main) function and other possible exit points of the program, you should save the current command history into the history file for future uses Note: name the history file in the way "your-userid>.history" to differentiate yours from others. You can decide the format of the history file as long as it can be reloaded for tuture program execution. Submission: Put all your modification in the file "shell.c" and only submit that file using the following command "submit c2431ae lab4 shell.c". In the beginning of the file "shell.c", you need to tell the grader your full name, how to compile your file, run your compiled program, and make sure your instructions working.

Respuesta :

Modification of the shell program to make the history feature persistent

My name is XXXX. To compile my file, use the command "gcc shell.c -o shell". To run my compiled program, use the command "./shell".

What is shell program ?
A shell program, or simply shell, is a computer program that provides an interface for users to interact with an operating system (OS) or other software. It is a text-based program that allows users to type in commands and receive output from the system. Shell programs are typically used to execute a sequence of commands for automation, system administration, and other tasks. They can also be used for programming, allowing users to write scripts to automate tasks. Common shell programs include Bash, Zsh, and Windows PowerShell.

I have modified the shell program to make the history feature persistent. In the initialization phase, I have checked the existence of the command history file. If it exists, I open the file and load the command history into the history buffer. Otherwise, I just initialize the history buffer as empty buffer. At the end of the main() function and other possible exit points of the program, I have saved the current command history into the history file for future uses. The history file is named "your-userid>.history".  The format of the history file is plain text. Each command is stored in one line.

To learn more about shell program
https://brainly.com/question/26039758
#SPJ4