Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In your first assignment for the Operating Systems course, you will develop a simple shell by implementing a basic REPL ( Read , Eval, Print,

In your first assignment for the Operating Systems course, you will develop a simple shell by implementing a basic REPL (Read, Eval, Print, Loop) in C. Your shell should support the following commands:
1. cd - change directory
cd
2. pwd - print working directory
pwd
3. exit - exit the shell
exit
4. help - display help
help
A sample output would be:
myshell> help
cd - change directory
pwd - print working directory
exit - exit the shell
help - display help
mkdir - create a directory
rmdir - remove a directory
ls - list files in a directory
cp - copy a file
mv - move a file
rm - remove a file
5. mkdir - create a directory
mkdir
6. rmdir - remove a directory
rmdir
7. ls - list files in a directory
ls
A sample output would be:
myshell> ls
file1 file2 file3
You can delimit the files with a space, or a tab [\t].
8. cp - copy a file
cp
9. mv - move a file
mv
10. rm - remove a file
rm
Submission Guidelines
1. You should submit a single zip file containing the following:
README.md - a markdown file containing a brief description of your implementation, similar to a manpage
shell.c - the source code for your shell
Makefile - a makefile to build your shell's binary
2. You should be targeting the gcc compiler, with a minimum ISO C11 standard. You can use the following command to ensure that your code compiles with
the correct flags and standards:
gcc -std=c11-pedantic shell.c -o shell
3. Your Makefile should have the following targets:
all - builds the shell
clean - removes the shell binary
run - runs the shell
shell.c
#include
#include
#include
void cd(char *path);
int main(){
char input[1024];
while (1){
printf("myshell>");
fgets(input,1024, stdin);
input[strcspn(input,"
")]=0;
char *command = strtok(input,"");
char *arg1= strtok(NULL,"");
// You can extend this code to support more arguments
if (strcmp(command,"cd")==0){
cd(arg1);
}
// You will need to extend this code to support other commands
else {
printf("Unknown command: %s
", command);
}
}
return 0;
}
void cd(char *path){
// Placeholder for 'cd' implementation
}
// The remaining functions can be implemented here

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

Ai And The Lottery Defying Odds With Intelligent Prediction

Authors: Gary Covella Ph D

1st Edition

B0CND1ZB98, 979-8223302568

More Books

Students also viewed these Databases questions

Question

2. What is the impact of information systems on organizations?

Answered: 1 week ago

Question

Evaluate the impact of technology on HR employee services.

Answered: 1 week ago