Lab #6/Prog #4 CIS343 Ð Extensions to MiniShell

Getting Started

In Lab #2 you implemented a basic shell called ms. This lab will extend this shell to support aliases.

 

1. Goto to your cis343 directory and create a lab6 directory.

 

2. Copy your MiniShell files from lab #2 to your lab6 directory. If you prefer, you may copy solutions for lab #2 from ~hardnett/pub/cis343/lab6.

Specification

This assignment requires you to implement aliases:

  1. Aliases are customized names that can be given to commands by the user, and then these names are treated as commands:

% alias myls ls Ða

or

% alias myls Òls ÐaÓ

% myls

 

myls will now do the same as if you had typed in Òls ÐaÓ

 

  1. If a unix command and an alias have the same name, then the alias should be executed:

 

% alias ls Òls ÐFÓ

% ls

 

after having the alias created, the ÒlsÓ will actually execute Òls ÐFÓ.

 

  1. The alias command is not a unix command, itÕs a shell builtin command like exit.
  2. If the user types in just ÒaliasÓ and one argument. The one argument is treated as a command name, then if an alias exist it will be printed on the screen:

 

% alias myls

myls is alias for ls Ða

 

  1. If the user types in just ÒaliasÓ and no other arguments, then all of the aliases should be shown: (the order does not matter)

 

% alias

myls               ls Ða

ls                     ls ÐF

 

  1. There should be a way to load aliases from any file. The ÒloadaliasesÓ command is a builtin command and should be used as below:

 

% loadaliases myfile.txt

 

This command has one argument, which can be any filename. The alias definitions in the file should be added to the current list of aliases. The file being loaded should be formatted as below:

 

myls   ls Ða

ls         ls ÐF

 

  1. There should also be an unalias builtin command to remove an alias:

 

% unalias myls

% myls

            myls: command not found

 

The command not found message should be the same message that is printed when any command is not found.

Deliverables

You will be submitting your updated ms.cpp and ms.h files.

Submission

You need to submit this assignment by midnight April 28th.

 

% cd ~cis343/lab6

 

% turnin cis343 prog4

 

NOTE: view the output of the turnin to verify that all of the necessary files have been submitted.