-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix shebang and executable paths in gitbash #1364
Changes from 1 commit
253702f
666d55f
3d2e429
7fd92e7
cfafdbe
9c7caa0
6bf148b
956ecb3
ab0bdab
d1b071d
4376a38
24dbc7c
9c00baf
3677b00
57123b1
8aae074
250338f
de91e23
6c9c2ec
4bb599a
abe10f6
b633dc7
024708b
2dae12b
314efe7
0ac5820
55c52e8
fefa176
21f3184
7559fc3
420ba83
3b9a0c5
e50404b
ef4a427
b56f64d
9e5226a
8c7c3d2
78abeab
2883f73
c3caada
8dfde24
e81756c
efc95f4
8844f69
6a4edb1
ecdb3cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
import re | ||
import subprocess | ||
from rez.utils.execution import Popen | ||
|
||
from rez.utils.logging_ import print_debug | ||
|
||
_drive_start_regex = re.compile(r"^([A-Za-z]):\\") | ||
_drive_regex_mixed = re.compile(r"([a-z]):/") | ||
|
@@ -38,20 +38,23 @@ def _repl(m): | |
|
||
# Convert the path based on mode. | ||
if mode == 'mixed': | ||
path = to_mixed_path(path) | ||
new_path = to_mixed_path(path) | ||
elif mode == 'windows': | ||
path = to_windows_path(path) | ||
new_path = to_windows_path(path) | ||
else: | ||
path = to_posix_path(path) | ||
new_path = to_posix_path(path) | ||
|
||
# NOTE: This would be normal cygpath behavior, but the broader | ||
# implications of enabling it need extensive testing. | ||
# Leaving it up to the user for now. | ||
if force_fwdslash: | ||
# Backslash -> fwdslash | ||
path = path.replace('\\', '/') | ||
new_path = new_path.replace('\\', '/') | ||
|
||
return path | ||
if path != new_path: | ||
print_debug('Path converted: {} -> {}'.format(path, new_path)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't this cause duplicate logs? Should the responsibility to log be of the caller or the callee? In general the responsibility is delegated to the caller, but we could say that in this case it's the callee. |
||
|
||
return new_path | ||
|
||
|
||
def to_posix_path(path): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
""" | ||
Windows Command Prompt (DOS) shell. | ||
""" | ||
from lib2to3.pytree import convert | ||
from rez.config import config | ||
from rez.rex import RexExecutor, expandable, OutputStyle, EscapedString | ||
from rez.shells import Shell | ||
|
@@ -296,24 +295,35 @@ def normalize_path(self, path): | |
Returns: | ||
(str): Normalized file path. | ||
""" | ||
return convert_path(path, 'windows') | ||
# Prevent path conversion if normalization is disabled in the config. | ||
if config.disable_normalization: | ||
return path | ||
|
||
converted_path = convert_path(path, 'windows') | ||
|
||
if path != converted_path: | ||
self._addline( | ||
'REM Path converted: {} -> {}'.format( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, converted vs changed. |
||
path, converted_path | ||
) | ||
) | ||
|
||
return converted_path | ||
|
||
def _saferefenv(self, key): | ||
pass | ||
|
||
def shebang(self): | ||
pass | ||
|
||
def setenv(self, key, value): | ||
value = self.escape_string( | ||
new_value = self.escape_string( | ||
value, | ||
is_path=self._is_pathed_key(key), | ||
is_shell_path=self._is_shell_pathed_key(key), | ||
) | ||
self._addline('set %s=%s' % (key, value)) | ||
|
||
self._addline('set %s=%s' % (key, new_value)) | ||
|
||
def unsetenv(self, key): | ||
self._addline("set %s=" % key) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
from rez.util import shlex_join | ||
from rez.utils.execution import Popen | ||
from rez.utils.platform_ import platform_ | ||
from rez.utils.logging_ import print_debug | ||
from rez.shells import UnixShell | ||
from rez.rex import EscapedString | ||
|
||
|
@@ -159,8 +160,18 @@ def _saferefenv(self, key): | |
self._addline("if (!($?%s)) setenv %s" % (key, key)) | ||
|
||
def setenv(self, key, value): | ||
value = self.escape_string(value, is_path=self._is_pathed_key(key)) | ||
self._addline('setenv %s %s' % (key, value)) | ||
is_path = self._is_pathed_key(key) or self._is_shell_pathed_key(key) | ||
new_value = self.escape_string(value, is_path=self._is_pathed_key(key)) | ||
|
||
if is_path and value != new_value: | ||
print_debug( | ||
'Path changed: {} -> {}'.format(value, new_value) | ||
) | ||
self._addline( | ||
'# Path value changed: {} -> {}'.format(value, new_value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistency in message. |
||
) | ||
|
||
self._addline('setenv %s %s' % (key, new_value)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also normalize the |
||
|
||
def unsetenv(self, key): | ||
self._addline("unsetenv %s" % key) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
from rez.config import config | ||
from rez.utils.execution import Popen | ||
from rez.utils.platform_ import platform_ | ||
from rez.utils.logging_ import print_debug | ||
from rez.shells import UnixShell | ||
from rez.rex import EscapedString | ||
|
||
|
@@ -105,15 +106,24 @@ def _bind_interactive_rez(self): | |
|
||
def setenv(self, key, value): | ||
is_implicit = key == 'REZ_USED_IMPLICIT_PACKAGES' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm struggling to understand why this is needed... |
||
is_path = self._is_pathed_key(key) or self._is_shell_pathed_key(key) | ||
|
||
value = self.escape_string( | ||
new_value = self.escape_string( | ||
value, | ||
is_path=self._is_pathed_key(key), | ||
is_shell_path=self._is_shell_pathed_key(key), | ||
is_implicit=is_implicit, | ||
) | ||
|
||
self._addline('export %s=%s' % (key, value)) | ||
if is_path and value != new_value: | ||
print_debug( | ||
'Path value changed: {} -> {}'.format(value, new_value) | ||
) | ||
self._addline( | ||
'# Path value changed: {} -> {}'.format(value, new_value) | ||
) | ||
|
||
self._addline('export %s=%s' % (key, new_value)) | ||
|
||
def unsetenv(self, key): | ||
self._addline("unset %s" % key) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
Path normalized
? Also, bothconverted
andchanged
are used. I think we should make sure the message is consistent. Lastly, I'd use{!r}
to automatically quote the paths. This usually helps with debugging whitespace issues, etc.