LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   designing a SHELL (https://www.linuxquestions.org/questions/programming-9/designing-a-shell-533272/)

linux_geek 02-28-2007 09:19 AM

designing a SHELL
 
hi guys.....i have an assignment to develope a SHELL. i just don't have any knowledge about it. Please help me design it or please give some links where i can find it..........

matthewg42 02-28-2007 09:38 AM

What specifically do you want to know?

A good place to start would be with the source to an existing shell.

theNbomr 02-28-2007 09:51 AM

You will want to concentrate on two primary functions:
1. Launching child processes.
2. Interpretting command lines.

Judging by your question, anything further will be a significant challenge.

You haven't said even what language you are planning to use (curious omission in a Programming forum), but I will hazard a guess that you will do it in C or C++. In either case, you should look at the man pages for system calls such as fork(), exec() (in its many flavors), and wait(). This mostly covers the launching of child processes, but you may also want to look at the likes of dup(), dup2(), and freopen() for management of standard IO. The C language covers a lot of commandline parsing with the standard string processing functions declared in string.h. You will want to use these.
For more exotic commandline parsing and advanced shell functionality such as script execution, you may want to look at the likes of lex & yacc (flex and bison in linux-speak).
Come back here with more specific questions once you have done this and have have idientified more specifc obstacles.
--- rod.

makyo 02-28-2007 01:03 PM

Hi.
Quote:

Originally Posted by nidupgels
i have an assignment to develope a SHELL. i just don't have any knowledge about it. Please help me design it or please give some links where i can find it

The article at http://en.wikipedia.org/wiki/Shell_%28computing%29 has a good overview and has a number of pointers.

If I were doing this I would probably do a prototype in perl or python before doing much in a compiled language.

It looks like a homework assignment, but even if not, you'll learn a lot by doing it.

Best wishes ... cheers, makyo


All times are GMT -5. The time now is 08:16 AM.