Exit code string output You must write a program or function that, when given a nonempty string S of N printable ASCII characters&dagger;, outputs a program that will exit with exit code C, where C is the ASCII codepoint at position 0 in S. This program you write will additionally output a program P, such that, when run, it exits with exit code C&prime;, where C&prime; is the ASCII codepoint at position 1 in S. Program P will output another program P&prime;. This process repeats until there are no characters left in S. After this is done, you must output nothing, followed by an optional newline; and should exit with exit code 0.

&dagger;The characters between 0x20 and 0x7e inclusive.

Some more rules:


Self-modifying programs are not allowed: you must output the source to STDOUT (or, return value initially)
You may not read your own source code.


The shortest such program in bytes will win.

For some rudimentary testing, this ruby script can be used. (The first argument is the way you invoke the script, the second is the program, and the third is the input string.)

Hypothetical Example

Say the program is FOO. When given the string "ABC", it outputs BARA. This program exits with code 65 and outputs BARB. This in turn exits with code 66 and ouputs BARC. This program exits with code 67 and outputs BAR!. This outputs nothing, and exits with code 0.
Python 2, 126 101 94 bytes
In the process of making this, I found that Python code may not contain literal NUL bytes.

lambda i,s='''i=%r;s=%r
try:print s%%(i[1:],s,i[0])
except:0
exit(ord(%r))''':s%(i[1:],s,i[0])

Try it online (shows the exit code in the Debug info)

Note that each of the non-empty programs below has a trailing linefeed.
For input Hello, the above outputs:
i='ello';s='i=%r;s=%r\ntry:print s%%(i[1:],s,i[0])\nexcept:print s%%(0,s,&quot;\\0&quot;)*(i&gt;0)\nexit(ord(%r))'
try:print s%(i[1:],s,i[0])
except:0
exit(ord('H'))

which prints
...
which prints
i='o';s='i=%r;s=%r\ntry:print s%%(i[1:],s,i[0])\nexcept:print s%%(0,s,&quot;\\0&quot;)*(i&gt;0)\nexit(ord(%r))'
try:print s%(i[1:],s,i[0])
except:0
exit(ord('l'))

which prints
i='';s='i=%r;s=%r\ntry:print s%%(i[1:],s,i[0])\nexcept:print s%%(0,s,&quot;\\0&quot;)*(i&gt;0)\nexit(ord(%r))'
try:print s%(i[1:],s,i[0])
except:0
exit(ord('o'))

which prints nothing (the empty program)

which prints nothing and exits with code 0.