-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Not expanding unquoted variables correctly #1
Comments
interesting - this makes sense, that the presence of quotes should matter. Are there existing tests that would break with this change? |
I have no idea. I was planning to use this library but it seems that at the moment it will not be a good fit due to this particular bug. |
I'd love to review a PR that fixes it and adds tests :-) |
I've pushed up a branch with failing tests, and found the place where the unquoted env var is retrieved. The difficulty is essentially that the current approach inlines env vars amidst parsing - however, an unquoted env var needs to be treated as part of the parse, and at this point in the implementation, we've already tokenized the input - and it's tricky to insert more tokens into the list. |
Isn't this a matter of porting an existing shell's grammar parser to js? Here are the interesting bits from bash: https://git.savannah.gnu.org/cgit/bash.git/tree/parse.y (Yacc grammar for bash) These two files account for probably 60% of what bash is. Supporting Are there practical applications to handling shell variable expansion in a javascript program? Can we really take shell variables out of the shell? |
There are many more shells than bash, and porting a parser would be extremely brittle since that can change drastically across even a single shell's major versions. |
I whole heartedly agree, and I think it's more sensible to remove variable expansion from the library, rather than attempt to fix it. I'm leaning towards removing this feature from my fork. |
We won’t ever be removing any features; breaking changes are toxic to the ecosystem. |
Consider the following example:
You get the following result:
The variable T is expanded in possitional args c and d. If we quote the variable then we get a different result:
However, in the shell-quote library the situation is different. Consider the following example:
We get the following result:
Notice that the behaviour is different as in the variable T does not get expanded. In other words, the behaviour is similar to variable T beign quoted, i.e:
If shell-quote is used to parse string which are used to spown a process with environment variable that are not quoted, it will result in a completely different behaviour than the one expected from the standard shell.
The text was updated successfully, but these errors were encountered: