The eXpOS shell program is designed to repeatedly ask for user commands and execute the command specified by the user. There are two types of commands that the user can input to the shell:
Built in shell commands are 1) Newusr (to create a new user), 2) Remusr (to remove a user), 3) Setpwd (set the password of a user), 4) Getuid (to get the user-id of the currently logged in user), 5) Getuname (to get the username of the currently logged in user), 6) Logout (logout the current user) and 7) Shutdown (to shutdown the system after committing back the memory copies of all disk data structures into the disk). To execute the system call for the corresponding shell command - eg : For the system call Newusr, enter the string "Newusr" (without quotes) from the console.
Upon receipt of one of these commands, the shell directly asks the user for the input arguments for the corresponding system call (for example - setpwd requires the username and the new password to be entered) and invokes the corresponding system call directly to execute the command. In all the above cases except logout and shutdown, the shell continues to ask the user for the next command after execution of the system call. If the executed system call for the input command is not successful, then shell simply prints "BAD COMMAND".
An executable command is essentially the name of an executable file. In such case, shell first spawns a child using the Fork system call and the parent (shell) waits for the child to do an Exit upon completion of command execution. The child runs the input file using the Exec system call. If Exec fails, then child prints “BAD COMMAND” and executes the Exit system call to activate the shell again.
eXpOS specifies that some standard executable programs called (system utilities) are supplied to the user along with the OS implementation. These programs essentially help the user to manipulate files using the shell. They are listed below:
A sample shell implementation is given here. The details of implementation of system utilities are left to the OS programmer. Since eXpOS ABI does not support command line arguments, these programs may need to ask the user for inputs (like filename in the case of the cat command) using the Read system call.
The eXpOS specification stipulates that shell always executes from the context of the currently logged in user. The shell is spawned by the login process.