I’m sure this is an easy question, but in creating a mock shell in C++, there is one aspect of the project that I don’t quite understand.
Basically, we’re creating a program called myShell, invoked with the command “./myShell”. That will open up the custom shell, but what I want to be able to do, is call external functions right from the command with the token “-c”.
For example, the command: “./myShell -c ls -l” will call the linux ls function. I can do this once the program is actually invoked, but not before (i.e. opening ./myShell, then typing ls -l”.
I’m new to processes, and any help would be appreciated.
You have code that waits for user input, interprets the commands that it reads from the user, runs them, and goes back to waiting for user input in a loop, like this pseudocode:
Modify your function to concatenate
argvs and run them before entering the loop: