I'm trying to have a lstlisting inside a longlisting, with some bash code. The bash code however ruins the word count function. The listing code is here:
\begin{longlisting}
\centering
\begin{lstlisting}[language=bash]
sudo apt update && sudo apt install curl gnupg2 lsb-release
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
\end{lstlisting}
\end{longlisting}
The word count function is from this tutorial
If I run it with backslash before the $, then it works, but not without