Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!