I'm new to C and am doing an assignment far beyond my capabilities (oh unfair teachers ) I have to write my own shell in C. Now I don't have to write my own functions but I could merely use usual bash functions in /bin/. I cannot use system() command.
Now I figured out forking and exec and few things like that but now I want to pass my arguments to the functions. This is where I face my problem. I don't know how!!!
You can give optional tags or you can omit them. Do I always have to pass a fixed number of arguments to the command, giving NULL values to the absent options? If so, how many options one command could hold?(i.e. how many arguments must I pass) I've been searching enough but couldn't find answers. Please can somebody help? Some references, links for me please? My shell must execute ls, ps, pwd, cp, echo, sleep commands with all possible options.
Another thing is I have to cut all options given by the user. I plan to store them in an array. I can break the string from the spaces but I really go wild when trying to store them in an array, especially because I don't know how many options are given before they are given. Another problem is that I understand that string itself is an array of characters. So storing few strings in an array?? Do I have to use a multi-dimensional array? Please help. Thanks