rez icon indicating copy to clipboard operation
rez copied to clipboard

Error with powershell and `$F` variables

Open dbr opened this issue 2 years ago • 0 comments

Describe the bug here.

Environment

  • OS: Windows 10
  • Rez version: 2.112
  • Rez python version: 3.9.13

To Reproduce

In currently default cmd shell, running command with $F or something works okay:

>>> subprocess.Popen(['rez', 'env', '--shell', 'cmd', 'python', '--', 'python', '-c', 'print("hello.$F4")']).communicate()
hello.$F4
(None, None)

However if using powershell, the string gets modified:

>>> subprocess.Popen(['rez', 'env', '--shell', 'powershell', 'python', '--', 'python', '-c', 'print("hello.$F4")']).communicate()
  File "<string>", line 1
    print(hello.)
                ^
SyntaxError: invalid syntax
(None, None)

Same thing happens if the ' and " are switched:

>>> subprocess.Popen(['rez', 'env', '--shell', 'cmd', 'python', '--', 'python', '-c', 'print("hello.$F4")']).communicate()
hello.$F4
(None, None)
>>> subprocess.Popen(['rez', 'env', '--shell', 'powershell', 'python', '--', 'python', '-c', 'print("hello.$F4")']).communicate()
  File "<string>", line 1
    print(hello.)
                ^
SyntaxError: invalid syntax
(None, None)

Expected behavior The two shells should act the same - passing through the string untouched by variable substitution

Related Issues/PRs

  • Maybe related to #1496
  • Also tangentially related to #1559

dbr avatar Nov 02 '23 00:11 dbr