You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Quotes in external command string parameter being escaped when they shouldn't be #1957
Using string command parameters (--thing="value") is escaping the quotes in the value.
To Reproduce
> git --git-dir=.git rev-parse --show-toplevel
/my/project
> git --git-dir=".git" rev-parse --show-toplevel
fatal: not a git repository: '".git"'
Note the double quotes surrounding the --git-dir parameter in the second example.
Expected behavior
Both examples are functionally the same - I should be able to surround the string with quotes, and they should not be escaped (included as part of the value itself).
Configuration (please complete the following information):
When processing a command, it looks like the remove_quotes function is used to remove quotes from arguments, but it only strips them from the outside. From testing, most other shells (testing PowerShell, sh, bash, csh, and zsh) allow quotes in any part of the argument to be stripped (so even something like --git-di"r=.gi"t would be transformed to --git-dir=.git.)
In fact, all of those shells allow and strip quotes anywhere; e"cho" h"el"lo is equivalent to echo hello. It seems like to cover all these cases, the change should be made in either lite_parse or parse (or both,) but I'm not sure which one (or if nushell even wants to be consistent in this way.)
Activity
kstrohbeck commentedon Jun 18, 2020
When processing a command, it looks like the remove_quotes function is used to remove quotes from arguments, but it only strips them from the outside. From testing, most other shells (testing PowerShell, sh, bash, csh, and zsh) allow quotes in any part of the argument to be stripped (so even something like
--git-di"r=.gi"twould be transformed to--git-dir=.git.)In fact, all of those shells allow and strip quotes anywhere;
e"cho" h"el"lois equivalent toecho hello. It seems like to cover all these cases, the change should be made in eitherlite_parseorparse(or both,) but I'm not sure which one (or if nushell even wants to be consistent in this way.)