Skip to content

Commit

Permalink
Use relative path in launcher only if shorter than absolute path
Browse files Browse the repository at this point in the history
We opted for relative paths to make paths and command-lines more
readable, and avoid some non-ascii encoding risks, when Jython is
installed locally to a user. The choice was counter-productive when
Jython was installed in a shared location.

--HG--
extra : amend_source : 8fd01b075f3387495b79d9b9ee5844638ff3f068
  • Loading branch information
jeff5 committed Mar 28, 2018
1 parent 0b46ab9 commit 7c6f862
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/shell/jython.py
Expand Up @@ -202,9 +202,9 @@ def executable(self):
# Python 2 thinks in bytes. Carefully normalise in Unicode.
path = os.path.realpath(bytes_path.decode(ENCODING))
try:
# If possible, make this relative to the CWD.
# This helps manage multi-byte names in installation location.
path = os.path.relpath(path, os.getcwdu())
# If shorter, make this relative to the CWD.
relpath = os.path.relpath(path, os.getcwdu())
if len(relpath) < len(path): path = relpath
except ValueError:
# Many reasons why this might be impossible: use an absolute path.
path = os.path.abspath(path)
Expand Down

0 comments on commit 7c6f862

Please sign in to comment.