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

Enable Variable Substitutions for Windows #17

Open
Schottkyc137 opened this issue Mar 23, 2024 · 3 comments
Open

Enable Variable Substitutions for Windows #17

Schottkyc137 opened this issue Mar 23, 2024 · 3 comments

Comments

@Schottkyc137
Copy link

Schottkyc137 commented Mar 23, 2024

It would be nice to allow variable substitutions for windows machines as well.
Since the '$' is a valid character in windows paths, and these paths use the backslash (\) character instead of the forward slash, the default substitution cannot be used. Instead, I would propose the %VARIABLE_NAME% syntax.

Note that I am not a windows user, but a user of this library and it would be nice to offer support for windows as well.

I'm happy to discuss any implementation details and can also offer to work towards enabling this feature.

@de-vri-es
Copy link
Contributor

Hey!

We could look at making the substitution and escape character configurable. However, %FOO% is a little problematic, as it wouldn't easily allow for default value substitution and would mean a totally different parser.

For example, we could allow using %{FOO:default} and %FOO (or maybe make it configurable to disable the short form too).

I suppose in this situation it would be nicest if the escape character is also just %: %{FOO} for a substitution and %% for a literal %.

Or.. I could just add another parser that truly works like the normal Windows style, so truly %FOO%.

@de-vri-es
Copy link
Contributor

de-vri-es commented Mar 23, 2024

Note that you can have variable substitution for windows paths already, you just need to be very explicit:

You would have to escape all $ and \ in the path as \$ and \\.

You can use a forward slash on Windows too, to prevent having to escape all the backslashes. Then you only need to escape the $, which is also the case on Unix systems ($ is also legal in Unix paths).

@Schottkyc137
Copy link
Author

Schottkyc137 commented Mar 24, 2024

Thanks a lot for the swift reply!

Hey!

We could look at making the substitution and escape character configurable. However, %FOO% is a little problematic, as it wouldn't easily allow for default value substitution and would mean a totally different parser.

For example, we could allow using %{FOO:default} and %FOO (or maybe make it configurable to disable the short form too).

I suppose in this situation it would be nicest if the escape character is also just %: %{FOO} for a substitution and %% for a literal %.

Or.. I could just add another parser that truly works like the normal Windows style, so truly %FOO%.

I believe that, for the benefit of your repository (which I see as a general-purpose API), both solutions would probably be nice while leaving the default what it is now (i.e., unix-style $FOO or ${FOO} replacements).
Personally, I'm already more than happy if either gets implemented. For the first solution you outlined, I could then just make the escape char also configurable on our side.

Note that you can have variable substitution for windows paths already, you just need to be very explicit:

You would have to escape all $ and \ in the path as \$ and \\.

You can use a forward slash on Windows too, to prevent having to escape all the backslashes. Then you only need to escape the $, which is also the case on Unix systems ($ is also legal in Unix paths).

I see. I always thought the \ character was mandatory on windows. It's still a bit annoying when you're used to writing paths in the 'standard' way and have to escape everything.

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

No branches or pull requests

2 participants