Make a package manager It's time to make a more advanced program (rather than something simple, like printing some shape). You need a package manager for something, I guess.

First of all, if something wasn't defined, you are allowed to do anything, including destroying the computer (but please, don't, unless this will save your characters). After all, you will be using the package manager 100% correctly, so this won't happen. Who cares about security problems? It just has to be fast, like C programs.

The package manager should use STDIN and STDOUT as storage - that is, the database should be read from STDIN, and result database should be output to STDOUT, in true Unix style. The format of database is anything you want, as long you will be able to read it back.

The package manager shall support four commands. Typing unrecognized command is undefined, and anything can happen.


init - outputs the empty database to be read by other commands. This shouldn't read the database state.
install x y z - installs the programs x y z. If the program already exists, you can do anything
remove x y z - removes the programs x y z. If the program doesn't exist, you can do anything.
list - shows every program (with new line after every program). The list should be in alphabetical order. This mustn't output the database state.


The packages are only allowed to have lowercase ASCII letters (a-z). Anything else is undefined.

There is an example of example program:

$ ./lolmanager init &gt; db
$ ./lolmanager install cat dog &lt; db &gt; db2
$ ./lolmanager remove dog &lt; db2 &gt; db
$ ./lolmanager list &lt; db
cat
$ ./lolmanager install something else &lt; db &gt; db2
$ ./lolmanager list &lt; db2
cat
else
something
$


The shortest code wins.
GolfScript, 59 characters
[{;;[]`}:it{|`}:ll{-`}:ve{;$n*}:st];~&quot;#{ARGV*' '}&quot;' '%(-2&gt;~

Implemented the first idea which came into my mind. The database format is simply a GolfScript array representation. Install/remove also handle the case when a program is already installed.
Explanation
# Define four functions for later use ([...]; simply removes them from the stack):
[
  {;;[]`}:it         # init -&gt; discard arguments, discard db, create empty db
  {|`}:ll            # install -&gt; add arguments to db (if not already there)
  {-`}:ve            # remove -&gt; remove all arguments from db
  {;$n*}:st          # list -&gt; discard arguments, sort, join with newline
];

~                    # Parse db given on STDIN
&quot;#{ARGV*' '}&quot;' '%    # Parse command line arguments into array
(-2&gt;                 # Take first argument (command) and the last two chars from it
~                    # Execute that command (i.e. &quot;it&quot; for &quot;init&quot;, ...)