I want to check the url given to \href. For that I have rename \href to execute some code. I think something is wrong parsing the arguments, because the code enters a loop and TeX capacity is exceeded.
\documentclass{article}
\usepackage[left=1cm,includemp,right=1.0cm, marginparwidth=6cm]{geometry}
\usepackage{hyperref}
\RequirePackage{xparse}
\RequirePackage[unique=true]{bashful}
\RequirePackage{marginnote}
\let\hrefnormal\href
\DeclareDocumentCommand \href {o m m}{%
\IfNoValueTF{#1}
{\hrefnormal{#2}{#3}}
{\hrefnormal[#1]{#2}{#3}}%
\marginnote{URL: \splice{curl -IsS \detokenize{#2} 2>&1 | head -n 1 | sed \detokenize{'s/HTTP\/1\.1 ... //'}}}
}
\begin{document}
\setlength{\parindent}{0pt}
\begin{center}
{\huge\textbf{URL Validation}}
\end{center}
Hidden URLs:
\href{http://tex.stackexchange.com/test-404/}{This will give a 404 - Page Not Found}
\end{document}

\usepackage{letltxmacro} \LetLtxMacro\hrefnormal\href. See When to use\LetLtxMacro? – Werner Mar 01 '17 at 13:46