Skip to content

Powershell "eval" output style uses "&&" instead of ";" #1413

Open
@salvaom

Description

@salvaom

When formatting powershell code as OutputStyle.eval, rez is using && to chain the commands instead of ;. This causes the code to not be runnable by PowerShell.

from rez.resolved_context import ResolvedContext
from rez.rex import OutputStyle

ctx = ResolvedContext(["platform"])
print(ctx.get_shell_code("powershell", style=OutputStyle.eval))

This PowerShell code does not work:

Set-Item -Path "Env:REZ_USED_TIMESTAMP" -Value "1668893287"&& Set-Item -Path "Env:REZ_USED_VERSION" -Value "2.112.0"

While this one does:

Set-Item -Path "Env:REZ_USED_TIMESTAMP" -Value "1668893287"; Set-Item -Path "Env:REZ_USED_VERSION" -Value "2.112.0"

Environment

  • OS: Windows 19
  • Rez version: 2.112.0
  • Rez python version: 3.9.13

To Reproduce
Execute the python snippet on the top of the issue.

Expected behavior
The string get_shell_code outputs should be executable in PowerShell.

Actual behavior
The string get_shell_code outputs is not executable in PowerShell due to && being used to chain commands instead of ;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugos:windowsWindows-specificshellShell related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions