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

[bug] Weird side effects when using {/} substitution at the edges of args under Windows #3330

Open
webknjaz opened this issue Aug 20, 2024 · 2 comments
Labels
bug:normal affects many people or has quite an impact help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.

Comments

@webknjaz
Copy link
Contributor

Basically, given the following config

[testenv]
commands = some-script.py path{/} {posargs} --more-args

or even

[testenv]
commands = 
  some-script.py \
    path{/} \
    {posargs} \
    --more-args

tox converts {/} into \ early and then treats it as if it's typed into the config by the end-user and is an escaping character.

I was very puzzled to see that the program I'm invoking via tox r -- few more args was getting path few as a single argument (sys.args was getting something like ["path few", "more", "args"]). And only on Windows 🤯! But after staring at it long enough, it occurred to me that it's just an escape character.

P.S. I'm using path{/} because I have a habit of visually separating directory and file path values by that trailing slash. Of course, the workaround is to drop it, but I believe it reveals a deeper issue here. I haven't attempted doing any debugging, but still wanted to document this magical behavior.

@webknjaz
Copy link
Contributor Author

Interestingly, in the place where I got '{toxinidir}{/}requirements{/}', it seems to work. So quotes to the rescue I guess...

@gaborbernat
Copy link
Member

Yeah, because is the trailing \ the issue, so a quote sidesteps the problem. Perhaps the line collapse needs to happen before any substitution and none afterward.

@gaborbernat gaborbernat added bug:normal affects many people or has quite an impact help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted. labels Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:normal affects many people or has quite an impact help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.
Projects
None yet
Development

No branches or pull requests

2 participants