Tietze Extension on Real Line and Boundedness Question: Let $F$ be a closed subset of $\mathbb{R}$, and let $f$ be continuous function on $F$. Show that there exists a function $g(x)=f(x)$ on $F$ which is continuous of entire real line. Moreover, show that if $f$ is bounded, then $g$ is bounded as well.
My attempt:
To exclude the trivial case, exclude the case where $F^c= \emptyset $, so, $F^c \neq \emptyset $, $F^c$ can be written as a countable union of open intervals $(a_k, b_k)$, with $a_k < b_k$. Now assume that $(a_k, b_k) \neq (-\infty,\infty) $, then $F^c = \bigcup_{k=1}^{\infty} (a_k,b_k) $
Define
$$
g(x)=\left\{\begin{array}{l}
f(x) , \  x \in F \\
f(b_k)+(x-b_k), \quad x \in\left(-\infty, b_{k}\right) \\
f(a_k)+(x-a_k), \ x \in\left(a_{k},  \infty\right) \\
f(a_k)+\left(\frac{f(b_k)-f(a_k)}{b_{k}-a_k}\right)(x-a_k), \ x \notin F, x \in(a_k, b_k),\ \text{where} \ a_k,b_k < \infty
\end{array}\right.
$$
I have showed that $g$ is continuous since $f$ is continuous of $F$ and so on so forth. However, when it comes to boundedness, I have failed to continue as for the first two cases it seems that $g$ is unbounded. I am open to any help.
 A: Regardless of that formalities in the abouve discussion: One can prove Tietze for the real line by extending the function using linear interpolation.
As in your question, let $F \subset \mathbb{R}$ be non-emptpy closed and $f : F \to \mathbb{R}$ be continuous.
It is crucial to write $F^c$ as union of disjoint open intervalls $(a_k,b_k)$. For $x \in F^c$ let $k(x)$ the unique $k$ s.t. $x \in (a_k,b_k)$. Then define
$
g(x)=\begin{cases}
f(x) & x \in F \\
f(a_k)+\left(\frac{f(b_{k(x)})-f(a_{k(x)})}{b_{k(x)}-a_{k(x)}}\right)(x-a_{k(x)})& x \in F^c,\;\; a_{k(x)}\neq-\infty,\;\; b_{k(x)}\neq \infty\\
f(a_{k(x)}) & x \in F^c,\;\; b_{k(x)}=\infty\\
f(b_{k(x)}) & x \in F^c,\;\; a_{k(x)}=-\infty
\end{cases}
$
Obviously, we have $||g||_\infty = ||f||_\infty$, if $f$ was bounded.
Remarks:

*

*In case that $f$ is bounded: If your construction gave you some $g$ extending $f$ that is unbounded, you could just replace it by
$\widetilde{g}(x):= min(max(g(x),-||f||_\infty),||f||_\infty)$ which is bounded and still continuous and extending $f$. Hence, thats not the "difficult" part here.

*The non-trivial fact that we used here is to compose $F^c$ in disjoint open intervalls. To that end, decompose $F^c$ in its connected compontens. They are open because $F^c$ is open and $\mathbb{R}$ is locally connected. Then use that an open subset of $\mathbb{R}$ is conneted, iff it is convex (and hence an intervall). This argument is much deeper than just saying "the open intervalls are a basis of the standard topology, hence any open set is a union of intervalls..."

