TITLE: Prove homotopic attaching maps give homotopy equivalent spaces by attaching a cell
QUESTION [23 upvotes]: Prove: If $f,g:S^{n-1} \to X$ are homotopic maps, then $X\sqcup_fD^n$ and $X\sqcup_gD^n$ are homotopy equivalent. 
I think it can be proved by showing they are both deformation retracts of $X\sqcup_H(D^n\times I)$ where $H$ is the homotopy between $f$ and $g$.
However, I have difficult in proving that the deformation retracts are continuous map. In fact, I have difficulty in representing a map in quotient spaces like $X\sqcup_fD^n$. I think a map from $X\sqcup_fD^n$ to $W$ can be represented by two maps: $m_1: X\to W$, $m_2: D^n\to W$, where for $x\in S^{n-1}$, $m_1\circ f(x)=m_2\circ i(x)$.
Then I construct the deformation retract this way: $m_1: X\to X$. For $x\in H(S^{n-1},t)$, $m_1(x)=H(S^{n-1},0)$, otherwise $m_1(x)=x$.
$m_2: D^n\times I\to D^n\times {0}$: $m_2((D^n,t))=(D^n,0)$.
It is easy to verify that $m_1$ and $m_2$ define a map from $X\sqcup_H(D^n\times I)$ to $X\sqcup_fD^n$. As long as this is a continous map, obvioulsy then we find a deformation retract. But it seems such a map is not continous?

REPLY [3 votes]: This is also proved in Topology and Groupoids (as it was in the 1968 edition, "Elements of Modern Topology"); this has some pictures of the crucial mapping cylinder construction $M(f) \cup X$ which, if $i: A \to X$ is a cofibration, is a useful model of the adjunction space $B \cup _f X$ for $f: A \to B$. Here is a coloured picture of the homotopy as Fig 7.10: