Skip to content

Stop globbing of quoted arguments to native commands - #5188

Merged
Jason Shirk (lzybkr) merged 2 commits into
PowerShell:masterfrom
lzybkr:glob_fix
Nov 1, 2017
Merged

Jason Shirk (lzybkr) merged 2 commits into
PowerShell:masterfrom
lzybkr:glob_fix

Conversation

@lzybkr

@lzybkr Jason Shirk (lzybkr) commented Oct 21, 2017 •

Copy link
Copy Markdown
Contributor

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 or null instead of the IScriptExtent when constructing the parameters and arguments that are used by the parameter binder.

Fix #3931,#4971

@lzybkr Jason Shirk (lzybkr) self-assigned this Oct 21, 2017
@lzybkr Jason Shirk (lzybkr) changed the title Use Ast for context in parameter binding [testing - do not merge] Stop globbing of quoted arguments to native commands Oct 22, 2017
@lzybkr

Copy link
Copy Markdown
Contributor Author

Dongbo Wang (@daxian-dbw) - I think this is ready for review.

@rkeithhill

Copy link
Copy Markdown
Collaborator

Must ... have ... this ... fix. :-)

@daxian-dbw

Copy link
Copy Markdown
Member

Jason Shirk (@lzybkr) I was out in training last Friday. Will get this done today.

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying #Closed.

@daxian-dbw Dongbo Wang (daxian-dbw) left a comment

Copy link
Copy Markdown
Member

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 ~.

Copy link
Copy Markdown
Member

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?

@daxian-dbw Dongbo Wang (daxian-dbw) Oct 31, 2017 •

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dongbo Wang (@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.

@daxian-dbw
Dongbo Wang (daxian-dbw) dismissed their stale review October 31, 2017 21:32

Question was answered.

@daxian-dbw Dongbo Wang (daxian-dbw) left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Jason Shirk (@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: #3931 #4971
@vors

Copy link
Copy Markdown
Collaborator

🎉

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

Successfully merging this pull request may close these issues.

4 participants