Skip to main content
Commonmark migration
Source Link

#TeX, by A Gold Man

TeX, by A Gold Man

Original source:

\read16to\x\message{Hello, World!}\bye

This already prints Hello, World!, but the newline is missing. The input is just placed in \x which is never used. In order to be able to modify the output, I guess we need to do some preparations (like, "lay a trap") before calling this code, so \x is actually expanded. It can be done when invoked like this (assuming the original source is in x.tex in the current directory):

tex '\def\vfill{\x}\input./x'

This first redefines \vfill (which is part of the expansion of \bye) to expand to our \x, so now we can provide some input printing the missing newline:

\newlinechar=`@\message{@}

This sets the character used for newlines in \message to @ and immediately uses it.


This whole thing modifies the environment the original program will run in, so if there are any objections to this method, I'll retract it.

#TeX, by A Gold Man

Original source:

\read16to\x\message{Hello, World!}\bye

This already prints Hello, World!, but the newline is missing. The input is just placed in \x which is never used. In order to be able to modify the output, I guess we need to do some preparations (like, "lay a trap") before calling this code, so \x is actually expanded. It can be done when invoked like this (assuming the original source is in x.tex in the current directory):

tex '\def\vfill{\x}\input./x'

This first redefines \vfill (which is part of the expansion of \bye) to expand to our \x, so now we can provide some input printing the missing newline:

\newlinechar=`@\message{@}

This sets the character used for newlines in \message to @ and immediately uses it.


This whole thing modifies the environment the original program will run in, so if there are any objections to this method, I'll retract it.

TeX, by A Gold Man

Original source:

\read16to\x\message{Hello, World!}\bye

This already prints Hello, World!, but the newline is missing. The input is just placed in \x which is never used. In order to be able to modify the output, I guess we need to do some preparations (like, "lay a trap") before calling this code, so \x is actually expanded. It can be done when invoked like this (assuming the original source is in x.tex in the current directory):

tex '\def\vfill{\x}\input./x'

This first redefines \vfill (which is part of the expansion of \bye) to expand to our \x, so now we can provide some input printing the missing newline:

\newlinechar=`@\message{@}

This sets the character used for newlines in \message to @ and immediately uses it.


This whole thing modifies the environment the original program will run in, so if there are any objections to this method, I'll retract it.

Source Link
Felix Palmen
  • 4.3k
  • 13
  • 29

#TeX, by A Gold Man

Original source:

\read16to\x\message{Hello, World!}\bye

This already prints Hello, World!, but the newline is missing. The input is just placed in \x which is never used. In order to be able to modify the output, I guess we need to do some preparations (like, "lay a trap") before calling this code, so \x is actually expanded. It can be done when invoked like this (assuming the original source is in x.tex in the current directory):

tex '\def\vfill{\x}\input./x'

This first redefines \vfill (which is part of the expansion of \bye) to expand to our \x, so now we can provide some input printing the missing newline:

\newlinechar=`@\message{@}

This sets the character used for newlines in \message to @ and immediately uses it.


This whole thing modifies the environment the original program will run in, so if there are any objections to this method, I'll retract it.