Jump to content

Writing a Shell, need help.

Bluuz

I'm writing a simple shell on Linux and one of the requirements is that the user should be able to enter in something such as "gedit ./readme.txt" And the .txt file will open. However, I am not allowed to use the function "system" to do this. Would someone mind explaining how to do this?

Link to comment
Share on other sites

Link to post
Share on other sites

The way the actual shell does it: fork a new process and replace the child's process image with gedit's image, passing the rest of the arguments.

Link to comment
Share on other sites

Link to post
Share on other sites

The way the actual shell does it: fork a new process and replace the child's process image with gedit's image, passing the rest of the arguments.

How do you do that?

Link to comment
Share on other sites

Link to post
Share on other sites

Ls should be the same gedit, unless you want to create your own way of displaying the files.

To determine the path to pass to ls and to implement cd I would keep a shell variable with the complete path and when the command is cd, verify if the destination folder exists and update the var.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×