Question: I currently have a simple C shell. My lab now requires me add a few more functions. Posting my entire code will be a bit
I currently have a simple C shell. My lab now requires me add a few more functions. Posting my entire code will be a bit too much, so just use placeholder variables and i'll just replace them with what I have (the shell itself is pretty much the same as you would find in most tutorials). Thanks in advance.
Expand filename wildcards (2 marks)
If any of the following characters ('*', '?', '[', '~') appears in one of the tokens, that token should be replaced by all of the tokens matching that token using the glob() library function. This may result in the tokens list becoming longer than initially. If there are no matches, use the token unchanged. This should be done before any of the actions described below. (hint: use GLOB_NOCHECK|GLOB_TILDE as the second parameter of the glob() function)
Redirect command input (2 marks)
If the command line contains the tokens < and a filename as the last two tokens, the command should be executed with its standard input connected to the named file. If the file does not exist, or is not readable, that is an error. Having < as the last token, or elsewhere in the command-line is also an error. (Hint: pipe() and dup2())
Redirect command output (1 mark)
If the command line contains the tokens > and a filename as the last two tokens, the command should be executed with its standard output connected to the named file. If the file does not already exist or exists and is writeable, then it is truncated to zero length and it current contents are overwritten. If the file exists and is not writeable, that is an error. Having > as the last token, or elsewhere in the command-line is also an error. (Hint: pipe() and dup2())
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
