This repository has been archived by the owner on Jan 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 248
Handle platform-specific list delimiters #80
Labels
Comments
Thanks for bringing this up @DanReyLop! What if we made the escaping required on the variable side of things? So you'd have to do:
Would that work? |
Well it would work, and it would be more backwards-compatible, but I feel like the other way is more natural. Just like in a RegExp, you use the "reserved" characters for their intended meaning, and if you want to use them literally, you have to escape them (not the other way around). In implementing this feature, we are basically acknowledging that Anyway, this feels like a lot of bikeshedding for a single-char feature, just pick one syntax and I'll make a PR :) |
Ok, I'm convinced. Let's go with your suggestion 👍 Thanks! |
DanReyLop
pushed a commit
to Automattic/cross-env
that referenced
this issue
Mar 22, 2017
In Windows, env variables that represent a list (such as PATH or NODE_PATH) separate their elements using a semicolon(;), but in UNIX they're separated using a colon (:). This commit adds a conversion layer, so regardless of how the delimiter is written when calling cross-env, it will be converted to the correct platform delimiter at runtime. To interpret a colon/semicolon literally instead, preced it with a backslash, like this: "cross-env VAR=semi\\;colon\\:" BREAKING CHANGE: If an env variable has : or ; in its value, it will be converted to : on UNIX systems or ; on Windows systems. To keep the old functionality, you will need to escape those characters with a backslash. kentcdodds#80
DanReyLop
pushed a commit
to Automattic/cross-env
that referenced
this issue
Mar 23, 2017
In Windows, env variables that represent a list (such as PATH or NODE_PATH) separate their elements using a semicolon(;), but in UNIX they're separated using a colon (:). This commit adds a conversion layer, so regardless of how the delimiter is written when calling cross-env, it will be converted to the correct platform delimiter at runtime. To interpret a colon/semicolon literally instead, preced it with a backslash, like this: "cross-env VAR=semi\\;colon\\:" BREAKING CHANGE: If an env variable has : or ; in its value, it will be converted to : on UNIX systems or ; on Windows systems. To keep the old functionality, you will need to escape those characters with a backslash. kentcdodds#80
kentcdodds
pushed a commit
that referenced
this issue
Mar 23, 2017
* feat: Convert list delimiters for PATH-style env variables In Windows, env variables that represent a list (such as PATH or NODE_PATH) separate their elements using a semicolon(;), but in UNIX they're separated using a colon (:). This commit adds a conversion layer, so regardless of how the delimiter is written when calling cross-env, it will be converted to the correct platform delimiter at runtime. To interpret a colon/semicolon literally instead, preced it with a backslash, like this: "cross-env VAR=semi\\;colon\\:" BREAKING CHANGE: If an env variable has : or ; in its value, it will be converted to : on UNIX systems or ; on Windows systems. To keep the old functionality, you will need to escape those characters with a backslash. #80 * chore: Add myself (DanReyLop) to the contributors list * Simplified logic. Now only : (UNIX-style) are converted to ; (Windows-style), not the other way around BREAKING CHANGE: You now must escape `:` to use it in a value of you don't want it to be swapped with `;` on Windows
Fixed in #93 |
kentcdodds
pushed a commit
that referenced
this issue
Mar 31, 2017
* feat: Convert list delimiters for PATH-style env variables In Windows, env variables that represent a list (such as PATH or NODE_PATH) separate their elements using a semicolon(;), but in UNIX they're separated using a colon (:). This commit adds a conversion layer, so regardless of how the delimiter is written when calling cross-env, it will be converted to the correct platform delimiter at runtime. To interpret a colon/semicolon literally instead, preced it with a backslash, like this: "cross-env VAR=semi\\;colon\\:" BREAKING CHANGE: If an env variable has : or ; in its value, it will be converted to : on UNIX systems or ; on Windows systems. To keep the old functionality, you will need to escape those characters with a backslash. #80 * chore: Add myself (DanReyLop) to the contributors list * Simplified logic. Now only : (UNIX-style) are converted to ; (Windows-style), not the other way around BREAKING CHANGE: You now must escape `:` to use it in a value of you don't want it to be swapped with `;` on Windows
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
For more context: elijahmanor/cross-var#3
Variables like
$PATH
or$NODE_PATH
contain lists of items that are separated by;
in Windows and:
in Unix. If would be good ifcross-env
handled this transparently.Previous proposed solution:
$:
is converted to:
on Unix,;
on Windows.Example:
PATH=$PATH$:lib npm start
PATH=%PATH%;lib npm start
PATH=$PATH:lib npm start
The drawback is that syntax is a bit confusing, it looks like the variable is
$PATH$
.Alternate solution:
:
in the value of a variable is converted to;
on Windows,;
is converted to:
on Unix. To put the literal:
or;
values, escape with a backslash (\:
,\;
).Example:
PATH=$PATH:lib GREET=Hello\:you npm start
PATH=%PATH%;lib GREET=Hello:you npm start
PATH=$PATH:lib GREET=Hello:you npm start
Note that this would technically be a breaking change, and such a
semver
major release.The text was updated successfully, but these errors were encountered: