diff --git a/src/rezplugins/shell/_utils/powershell_base.py b/src/rezplugins/shell/_utils/powershell_base.py index 20845c0dc..2957a6de8 100644 --- a/src/rezplugins/shell/_utils/powershell_base.py +++ b/src/rezplugins/shell/_utils/powershell_base.py @@ -279,28 +279,21 @@ def shebang(self): pass def setenv(self, key, value): - is_path = self._is_pathed_key(key) - new_value = self.escape_string(value, is_path=is_path) - - self._addline( - 'Set-Item -Path "Env:{0}" -Value "{1}"'.format(key, new_value) - ) + value = self.escape_string(value, is_path=self._is_pathed_key(key)) + self._addline('Set-Item -Path "Env:{0}" -Value "{1}"'.format(key, value)) def prependenv(self, key, value): - is_path = self._is_pathed_key(key) - new_value = self.escape_string(value, is_path=is_path) + value = self.escape_string(value, is_path=self._is_pathed_key(key)) # Be careful about ambiguous case in pwsh on Linux where pathsep is : # so that the ${ENV:VAR} form has to be used to not collide. self._addline( 'Set-Item -Path "Env:{0}" -Value ("{1}{2}" + (Get-ChildItem -ErrorAction SilentlyContinue "Env:{0}").Value)' - .format(key, new_value, self.pathsep) + .format(key, value, self.pathsep) ) def appendenv(self, key, value): - is_path = self._is_pathed_key(key) - # Doesn't just escape, but can also perform path normalization - modified_value = self.escape_string(value, is_path=is_path) + value = self.escape_string(value, is_path=self._is_pathed_key(key)) # Be careful about ambiguous case in pwsh on Linux where pathsep is : # so that the ${ENV:VAR} form has to be used to not collide. @@ -308,7 +301,7 @@ def appendenv(self, key, value): # an exception of the Environment Variable is not set already self._addline( 'Set-Item -Path "Env:{0}" -Value ((Get-ChildItem -ErrorAction SilentlyContinue "Env:{0}").Value + "{1}{2}")' - .format(key, os.path.pathsep, modified_value)) + .format(key, os.path.pathsep, value)) def unsetenv(self, key): self._addline( diff --git a/src/rezplugins/shell/gitbash.py b/src/rezplugins/shell/gitbash.py index 03ea8fdb7..13225ea3b 100644 --- a/src/rezplugins/shell/gitbash.py +++ b/src/rezplugins/shell/gitbash.py @@ -23,11 +23,11 @@ class GitBash(Bash): """Git Bash shell plugin.""" pathsep = ':' - _drive_regex = re.compile(r'([A-Za-z]):\\') + _drive_regex = re.compile(r"([A-Za-z]):\\") @classmethod def name(cls): - return 'gitbash' + return "gitbash" @classmethod def executable_name(cls): @@ -51,7 +51,6 @@ def find_executable(cls, name, check_syspaths=False): else: return settings.executable_fullpath - # Find the gitbash bash executable using the windows registry. exepath = Bash.find_executable(name, check_syspaths=check_syspaths) if exepath and "system32" in exepath.lower(): @@ -62,9 +61,8 @@ def find_executable(cls, name, check_syspaths=False): "plugins.shell.gitbash.executable_fullpath.", exepath ) - raise ValueError("Gitbash executable is not correct: %s" % exepath) - exepath = exepath.replace('\\', '\\\\') + exepath = exepath.replace("\\", "\\\\") return exepath @@ -92,7 +90,7 @@ def get_syspaths(cls): out_, _ = p.communicate() if p.returncode == 0: lines = out_.split('\n') - line = [x for x in lines if '__PATHS_' in x.split()][0] + line = [x for x in lines if "__PATHS_" in x.split()][0] # note that we're on windows, but pathsep in bash is ':' paths = line.strip().split()[-1].split(':') else: @@ -187,7 +185,7 @@ def lowrepl(match): return normalized_path def shebang(self): - self._addline('#! /usr/bin/env bash') + self._addline("#!/usr/bin/env bash") def register_plugin(): diff --git a/src/rezplugins/shell/sh.py b/src/rezplugins/shell/sh.py index d371afb87..bd1f638cb 100644 --- a/src/rezplugins/shell/sh.py +++ b/src/rezplugins/shell/sh.py @@ -146,7 +146,6 @@ def escape_string( if is_shell_path: txt = self.as_shell_path(txt) elif is_path: - # potentially calls plugin shell's normalize txt = self.normalize_paths(txt) txt = txt.replace('\\', '\\\\')