Conditional \bye?
One solution might be to define a custom \bye
command, for example \mybye
, in the main document. In the subdocument you can perform a check if this command is defined, if not then you define it to be \bye
. The definition in the main document can be empty.
Checking if a command exists can be done with \ifcsname
(which is an e-TeX macro).
MWE, main document:
Hello from master document\par
\def\mybye{}
\input subdocument
more text in master document
\bye
subdocument:
\ifcsname mybye\endcsname\else\def\mybye{\csname bye\endcsname}\fi
Hello from subdocument\par
\mybye
You can use a macro only defined in the main file.
file dcu.tex
\def\ABCDEFGHIJK{}
\input dcu1
\input dcu2
\bye
File dcu1.tex
This is the first file
\ifx\ABCDEFGHIJK\undefined\csname bye\expandafter\endcsname\fi
File dcu2.tex
This is the second file
\ifx\ABCDEFGHIJK\undefined\csname bye\expandafter\endcsname\fi