The shell script is executed with the help of a shell language interpreter, which is nothing but a regular user-mode application working in the outer
protection ring. Therefor, the question is reduced to understanding of how application programs work and how the kernel-mode code interact with those application programs.
And this question is a bit too big and complex to be explained in a single quick answer. As the protection and isolation of rings is, in some class of CPUs) is
hardware-mediated, specific CPU architectures are involved, and the such architectures are complex enough to require a whole book explaining them, including isolation of modes, different memory models, descriptors and a lot more. Linux architecture really use most of these features to keep the OS kernel-mode software stable. You can start learning, say, from here:
http://en.wikipedia.org/wiki/Protection_ring[
^],
http://en.wikipedia.org/wiki/Protected_mode[
^],
http://en.wikipedia.org/wiki/Complex_instruction_set_computer[
^].
—SA