print · source · login   

Shell Assignment


Text & project (to be used in the VirtualBox environment of first assignment, by opening the CMakeLists.txt in Qt Creator).

VirtualBox image for the assignment
Deadline October 1.


Compiler warnings

Turning on compiler warnings may help with keeping your code clean. To do this in Qt Creator, switch to the "Projects" pane through the menu on the left-hand side. In the CMake section you should see a bunch of settings like CMAKE_BUILD_TYPE. Check the 'advanced' checkbox on the right and look up CMAKE_CXX_FLAGS. Put the value as -Wall (case sensitive). Then click build in the lower left corner. This will trigger some issues about signed and unsigned integer comparisons, which should be easily solvable by changing the relevant variables to have type unsigned int (or size_t) instead of int.

End of input

For the unit tests to run properly, please check regularly if the input is still valid (= not closed). This can be done by cin.good(). If it is closed, please exit your shell.

Always exit(-1) after execvp()

It is important to exit (with exit(-1);) the current process after a failed execvp(). If the execvp() fails, the current process will continue execution the shell code (together with the parent process). If the execvp() succeeds, the current process is replaced by another, so the call to exit is never executed.