Skip to content

Commit

Permalink
Add Execution Policy setting to Powershell based shell plugins (#1505)
Browse files Browse the repository at this point in the history
Signed-off-by: Erwan Leroy <herronelou@gmail.com>
  • Loading branch information
herronelou authored Feb 4, 2024
1 parent 99809d1 commit aff89bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/rezplugins/shell/_utils/powershell_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ def _record_shell(ex, files, bind_rez=True, print_msg=False):
# Suppresses copyright message of PowerShell and pwsh
cmd += ["-NoLogo"]

# Powershell execution policy overrides
# Prevent injections/mistakes by ensuring policy value only contains letters.
execution_policy = self.settings.execution_policy
if execution_policy and execution_policy.isalpha():
cmd += ["-ExecutionPolicy", execution_policy]

# Generic form of sourcing that works in powershell and pwsh
cmd += ["-File", target_file]

Expand Down
2 changes: 2 additions & 0 deletions src/rezplugins/shell/rezconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ powershell:
prompt: '> $ '
additional_pathext: ['.PY']
executable_fullpath: null
execution_policy: null

pwsh:
prompt: '> $ '
additional_pathext: ['.PY']
executable_fullpath: null
execution_policy: null

gitbash:
prompt: '>'
Expand Down

0 comments on commit aff89bd

Please sign in to comment.