How to avoid duplicate shader code?

Hey.

I’m using 3 shaders in a application currently. They all are affecting 3d Objects in my world,
but on different ways (actually the vertex shader is always the same, only the fragment shader changes).
Now i wanted to implement a light shader.

But how can i apply the light calculations to any texels, without copying the light code in every of the 3 shaders?
I mean, What an ugly code:


shader1
light....
.....
.....
....
....
light end
specific calculations


shader2
light....
.....
.....
....
....
light end
specific calculations

and so on.
So, how could i avoid this, and which approaches are there maybe to reuse parts of shaders or something like that?..

Another example: If you have one shader supporting textures, and one without them. U need both of them in the scene, but both
need lighning code…

Thank you for ideas or suggestions!