Fix `Invoke-History` to detect recursive call of the same history entry by daxian-dbw · Pull Request #13197 · PowerShell/PowerShell

PR Summary

Fix #13183

Fix Invoke-History to detect recursive invocation of history entries.
The old loop detection seems depend on the history invocation runs in the same pipeline, but that's not the case any more (maybe changed in v5).

The fix is to move the loop-detection logic to the History class. A Runspace holds a History instance, it's like a singleton in the Runspace scope. not really a singleton because a new instance will be used if you reset the Runspace, but there is only one instance per Runspace at a given time.

PR Checklist