Toy UNIX shell with support for interactive/batch modes, aliasing & redirection. Once you enter a command, the shell forks a new child process, exec()'s the command while the parent wait()'s for its completion before continuing to the next iteration.
Running in interactive mode:
./myshThen wait for the shell to start before typing your commands.
mysh>Running in batch mode:
./mysh batch_fileYour batch file should contain a list of commands, each on their own line, to be executed.
You can also redirect output to a file instead of stdout.
./mysh ls -la > output(This runs the ls -la command and writes the output to the file output.)
To create an alias, run alias <command> <alias-name>. If alias-name was previously used, it is replaced.
mysh> alias ll /bin/ls -l -aTo see all aliases:
mysh> aliasTo view a single alias:
mysh> alias <alias-name>If alias-name exists, the shell will display its replacement value.
To unalias:
mysh> unalias <alias-name>- Aliasing was implemented using a doubly-linked list to support arbitrary deletion.
- Most of the shell implementation is in
mysh.cwhile aliasing functionality is defined inmyalias.c.