Fixed the command list when combining --pinned and --versions

See #32067 for more details.