Prevent recursion in environment variable expansion
Ensure that we don't get stuck in an endless recursion while expanding variables. Handle both the simple case of `VAR=$VAR` but also more complex scenarios such as `VAR1=$VAR2; VAR2=$VAR2`. Based on the patch by David Redondo and input from Igor Kushnir, see https://invent.kde.org/kde/kdevelop/-/merge_requests/125