jovanbulck / jsh

A basic UNIX shell implementation in C
GNU General Public License v3.0
30 stars 10 forks source link

Jsh software design #46

Open jovanbulck opened 9 years ago

jovanbulck commented 9 years ago

Since the jsh code base is growing, we should think more about structuring. Currently the code is far from cohesive. This of course limits readability and makes adding new features harder.

Ideally, the code should be divided into small cohesive 'modules', communicating via C header interfaces. Just like the alias.c & alias.h files now. I therefore drafted out a first idea on paper: jsh_modularisation

Sorry for the crappy quality ;-) Also, don't worry about the arrows to much. Most of them are just #includes for jsh-common.h, containing some helper functions. I marked the important relationships in green. Since all functionality in a shell is related, I think the coupling will never be very satisfying, but at least this way it's more controlled.

As you can see, functionality is divided in different header files. This will make adding new features (e.g. new autocompleters, new built_ins, grammar enhancement, prompt customizing, ...) more local and thus also easier. Separating the command line interface in particular, will allow implementing a alternative simpler 'fall-back' modus for readline. Being more independent from readline can be nice, I think ;-) Especially if we want to port to Android, see issue #23 .

Drop your thoughts! However, since jsh is not a master-thesis, I started a zero-code policy till Thursday so I won't be starting on this yet... ;-)

stefaantruijen commented 9 years ago

Maybe you can try to scan in the diagram in CBA?

jovanbulck commented 9 years ago

I'll assign @KevinMordijck for scanning in the diagram ;-)

jovanbulck commented 9 years ago

Check out the zsh built_ins They basically also have a huge array of built_ins

KevinMordijck commented 9 years ago

the diagram is updated