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 programsx y z
. If the program already exists, you can do anythingremove x y z
- removes the programsx 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 > db
$ ./lolmanager install cat dog < db > db2
$ ./lolmanager remove dog < db2 > db
$ ./lolmanager list < db
cat
$ ./lolmanager install something else < db > db2
$ ./lolmanager list < db2
cat
else
something
$
The shortest code wins.