Is it possible to define a command \foo such that further \newcommand\foo (I do not mean \renewcommand) are ignored and do not return errors?
For example:
\newcommand\foo[1]{\textcolor{red}{#1}}
\newcommand\foo[1]{\textcolor{blue}{#1}} % to be ignored!
\foo{This should print in red.}
The reason why I am asking for this is that I have a document doc.tex of the form
\newcommand\foo[1]{\textcolor{blue}{#1}}
\foo{Some text}
that I want to include in another document using \input{doc.tex}, and I'd like Some text to print in red (of course, in reality my problem is not about text color...).

\AtBeginDocument{\let\foo\relax\newcommand\foo[1]{\textcolor{red}{#1}}}– Steven B. Segletes Oct 31 '17 at 19:50\providecommand\foo? – Oct 31 '17 at 19:52\foo. – Steven B. Segletes Oct 31 '17 at 19:54\newcommand\fooand then\providecommand\foo(as second usage) – Oct 31 '17 at 20:00\newcommandtoprovidecommandwas transparent, so it works fine for me, thank you! Feel free to write an answer, I will also wait a bit to see if there are other more general solutions that avoid touching to the second\newcommand. – anderstood Oct 31 '17 at 20:07\newcommand\fooand\providecommand\foo, you already know that you're trying to define\fooagain, unless you glue a bunch of files together and don't know in which file\foois defined – Oct 31 '17 at 20:09\newcommand,\renewcommand, and\providecommanddo, and how do they differ? – Werner Oct 31 '17 at 20:36