-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Stop globbing of quoted arguments to native commands #5188
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
Conversation
28e326e
to
1534378
Compare
a3613a5
to
ad12184
Compare
@daxian-dbw - I think this is ready for review. |
Must ... have ... this ... fix. :-) |
@lzybkr I was out in training last Friday. Will get this done today. |
foreach (var path in paths) | ||
{ | ||
_arguments.Append(sep); | ||
sep = " "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is sep = " "
really needed here? It seems we just need var sep = " "
right before the foreach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's more tidy - it avoids putting 2 spaces between the previous token - either the command name or an argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying #Closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but have one more comment about expanding ~
.
} | ||
} | ||
} | ||
} while (list != null); | ||
} | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we will expand ~
even if arg
is not a bare word. Do we want to expand ~
unconditionally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another question: it seems to me that after this change we don't glob for variables. Is it intentional?
For example, before the change
PS> $var = '*.txt'
PS> /bin/echo $var
a.txt b.txt c.txt
with the change
PS> /bin/echo $var
*.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching, I missed this when reviewing Bruce's changes, but you're right, we don't want to expand ~
unconditionally. I'll fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I see bash also expands variables unless quoted, so we should probably match that behavior too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daxian-dbw - updated. If you sign off, I'll merge - I want to squash the last 2 commits and rebase 2 commits instead squashing the 3 commits.
dd4d8ad
to
8871dd5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @lzybkr please feel free to merge the PR.
Previously we used IScriptPosition for context (e.g. error reporting) during parameter binding, but in some cases we want more information, so we'll use the Ast instead. This change just adds the Ast, it doesn't make explicit use of it.
Also fix some minor issues with exceptions being raised when resolving the path - falling back to no glob. Fix: PowerShell#3931 PowerShell#4971
🎉 |
Fix globbing so that quoted args are not expanded.
Also Fix some minor issues with exceptions being raised when resolving
the path - falling back to no glob.
The bulk of the change is in the first commit, which passes the
Ast
ornull
instead of theIScriptExtent
when constructing the parameters and arguments that are used by the parameter binder.Fix #3931,#4971