Skip to content
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

Cygpath is only required for the PATH variable when using cygwin #42

Merged
merged 1 commit into from
Apr 25, 2023

Conversation

MHendricks
Copy link
Member

Addresses #41 by only calling cygpath when processing the PATH env var.

Checklist

  • I have read the CONTRIBUTING.md document
  • I formatted my changes with black
  • I linted my changes with flake8
  • I have added documentation regarding my changes where necessary
  • Any pre-existing tests continue to pass
  • Additional tests were made covering my changes

Types of Changes

  • Bugfix (change that fixes an issue)
  • New Feature (change that adds functionality)
  • Documentation Update (if none of the other choices apply)

Proposed Changes

After some more testing I've figured out that we only need to convert to cygpath and use : when modifying the PATH env variable, not any of the other environment variables. https://cygwin.com/cygwin-ug-net/setup-env.html.

If you run this in cygwin

export AB="\\\\example\a\path;c:\temp"
export AB="$AB;c:\other;\\\\server\share"
py -c "import os;print(os.environ['AB'])"

It outputs \\example\a\path;c:\temp;c:\other;\\server\share which is expected.

If you try to do the same for PATH, it does not work as expected

export PATH="$PATH;c:\other;\\\\server\share"
py -c "import os;from pprint import pprint;pprint(os.environ['PATH'].split(';'))"

Outputs:

[...,
 'C:\\Program Files\\Git\\usr\\bin\\core_perl',
 'c',
 'C:\\other',
 '\\server\\share']

'c', is incorrect and could cause issues. If you reset your bash and run this instead, it works as expected:

export PATH="$PATH:/c/other;//server/share"
py -c "import os;from pprint import pprint;pprint(os.environ['PATH'].split(';'))"
[...,
 'C:\\Program Files\\Git\\usr\\bin\\core_perl',
 'C:\\other',
 '\\server\\share']

The previous cygpath commit was applying that fix to all environment variables, but it turns out we only need to apply it to PATH. This MR changes hab to only apply cygpath changes for the PATH environment variable.

@MHendricks MHendricks merged commit 8a5d1c3 into blurstudio:main Apr 25, 2023
@MHendricks MHendricks deleted the cygpath_fix2 branch April 25, 2023 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant