1. Engineering
  2. Computer Science
  3. instructions the code mshc should do the following...

Question: instructions the code mshc should do the following...

Question details


The code ( msh.c ) should do the following:

  • prompt for input with “msh> “ (‘msh’ stands for “my shell”) - (Note the space after ‘>’.)
  • read the user input
  • if the user input is ‘exit’ or ctrl-d, terminate.
  • Use 'fgets' to determine if ctrl-d was entered
  • DO NOT USE 'scanf'
  • otherwise, simply echo the user input
  • (In the second test, a space character was entered. - '123 abc') Your program should respond sensibly on other inputs

You should be able to handle user input of at least 120 characters. You should print the error message "error: input too long" and re-prompt if this happens.


Here is an example of what your msh code should do: ($ is the bash prompt)

$ ./msh

msh> abc



msh> 123


msh> 123 abc

123 abc

msh> ***


msh> exit



Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution