Rudin's chain rule theorem goes like this:
Suppose $f$ is continuous on ${[a,b]}$, $f'(x)$ exists at some point $x\in [a,b], g$ is defined on an interval $I$ which contains the range of $f$, and $g$ is differentiable at the point $f(x)$. If $$h(t)=g(f(t)) \quad (a\le t \le b)$$ then $h$ is differentiable at $x$, and $$h'(x)=g'(f(x))f'(x)$$
First note that the interval $I$ is closed by Rudin's definition (he calls an open interval $(a,b)$ a segment). Also, Rudin defines differentiability to be in closed intervals, taking the left/right derivative at endpoints.
Since the interval $I$ taken affects the derivative $g'$ (for example, let $g(x) = |x|$, then the derivative can be $1$ or $-1$), I'm wondering if it's true that taking any interval $I$ containing the range of $f$ in which $g$ is (perhaps only left/right) differentiable at $f(x)$ is ok. And in case $g$ is only left-differentiable at $f(x)$ in $I$, we just take the left derivative to be $g'$. Will $h'(x)$ always be the same regardless of which interval $I$ we pick?
Lastly, aside to the question, I wonder if it is a good idea to define differentiability on closed intervals like Rudin does. It does seem to make theorems like this one more complicated. I've found many online sources like Wikipedia defining it on open sets only, but Rudin's book is considered a classic and Terence Tao also defines it the same way. There seems to be no consensus on this issue, so is there a "best practice"?
For functions of a single real variable, it is very easy to deal with endpoints: just define the derivative as one-side limits. For functions of several real variables, everything get more difficult, since boundary points cannot always be described in a single way. It is possible to defined derivatives on closed subsets, but we need a less intuitive definition.
As an instructor I do not overrate derivatives on closed intervals, since enndpoint derivatives do not have exactly the same interpretation as derivatives at inner points: think of Fermat's theorem, for example.
Rudin's statement is perfectly correct in one dimension, and since two functions that agree on a neighborhood of a point must have the same derivative at that point, the role of $I$ is weak.