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

Allow wslpath to keep trailing slash for directories (possibly via an option e.g. --preserve-trailing-slash or --force-trailing-slash) #8827

Closed
vadimkantorov opened this issue Sep 16, 2022 · 4 comments
Assignees
Labels

Comments

@vadimkantorov
Copy link

vadimkantorov commented Sep 16, 2022

Usecase: from a WSLv1 bash get a Windows absolute dir path, to be passed to a python script to be passed to Chrome headless via selenium.

Succinctly: wslpath -a -w . gets me what I want except that I need this path to have a trailing backslash. Unfortunately, wslpath -a -w ./" still returns the same path. It would be nice to have an option to return a trailing backslash for a directory in an easy way. My current workaround: $(wslpath -a -w .)\\. This is not too bad, just a bit inconvenient, and less clear to the reader as the backslash here may be somehow leaking through the abstraction

Also, it might be nice if wslpath -a -w directly returned path to the current directory - again, not very important.

@benhillis
Copy link
Member

wslpath -a -w . should already do what you want for current directory. Seems like appending a trailing slash should be pretty easy to do in the python script as well?

@vadimkantorov
Copy link
Author

vadimkantorov commented Sep 19, 2022

Python script in WSLv1 thinks it's completely in Linux land, so os.sep is forward slash, and I'd like to keep my Python script as simple+portable as possible. So keeping it at the upper level of wslpath would be good. I agree, it's a minor issue, but it would be a bit nicer if wslpath could produce trailing slash as well (probably via opt-in option is best)

@vadimkantorov vadimkantorov changed the title Allow wslpath to keep trailing slash for directories (possibly via an option) Allow wslpath to keep trailing slash for directories (possibly via an option e.g. --preserve-trailing-slash or --force-trailing-slash) Sep 19, 2022
@benhillis
Copy link
Member

Looks like this got lost in the churn, I've got a fix for this in PR.

@benhillis benhillis self-assigned this Nov 21, 2024
@benhillis
Copy link
Member

Fixed with https://github.com/microsoft/WSL/releases/tag/2.4.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants