It would appear that \input reads its input as complete lines (even when there's no linefeed at the end of the file). So in your case, it's as if you had written:
Code: Select all
Where does the space at the end of ``this quote
'' come from?
One way to see this is to to add a percent sign at the end of temp.tex. In other words, if temp.tex looks like this:
Then
Code: Select all
Where does the space at the end of ``\input{temp.tex}'' come from?
Is processed as if you had written:
Code: Select all
Where does the space at the end of ``this quote%
'' come from?
which actually produces the desired look, since the line ending is commented out.
Unfortunately, it's not obvious to me how to write a percent sign to an external file using \write18 in LaTeX. Maybe someone else reading this will know how to do it. Neither:
Code: Select all
\immediate\write18{echo -n "this quote%" > temp.tex}
nor
Code: Select all
\immediate\write18{echo -n "this quote\%" > temp.tex}
work. (The former is treated as commenting out the rest of the line, and the latter puts the slash into temp.tex as well.)
My temporary kludge has been to write a simple bash script
addpercent.sh which does nothing put echo a '%':
And then:
Code: Select all
\documentclass[12pt]{book}
\begin{document}
\immediate\write18{echo -n "this quote" > temp.tex}
\immediate\write18{addpercent.sh >> temp.tex}
There is now no space at the end of ``\input{temp}''. Good.
\end{document}
Gives:

- input.png (3.15 KiB) Viewed 2260 times
This, however, is an ugly hack all around, and it would be great if someone knew a more elegant solution. I think in your case, however, there are probably more elegant ways to achieve what you want, but without knowing more about how you're using \input{}, and why, it's hard to know.