Powershell: implement return-parsing symbol

Created on 19 Feb 2020  路  2Comments  路  Source: PowerShell/PowerShell

steps to reproduce

icacls X:\VMS --% /grant Dom\HVAdmin:(CI)(OI)F ---% ; write-host hello

return-parsing symbol _---%_ directs PowerShell to return interpreting input as PowerShell commands or expressions.

Issue-Enhancement

Most helpful comment

@vexx32, the potential benefit is in overcoming the following limitations of current --% syntax (I'm not advocating for the change, just providing background information; to me, the only truly problematic limitation is the redirection case).

  • You cannot use redirections such as > out.txt - they are passed as _literal arguments_ to the target program (if the target program happens to be a shell, _it_ would interpret it).
  • You cannot enclose the command line in (...) - because the closing ) is interpreted as a literal part of the command line.
  • (As implied in the OP) You cannot follow the command line with ; and another statement - because the ; is interpreted as a literal part of the command line.
  • You cannot use --% inside a _single-line_ script block - because the closing } is interpreted as a literal part of the command line.

All 2 comments

What benefit does this provide? 馃

I can't say I've ever needed to worry about what I'm putting after a stop-parsing symbol other than a line break.

@vexx32, the potential benefit is in overcoming the following limitations of current --% syntax (I'm not advocating for the change, just providing background information; to me, the only truly problematic limitation is the redirection case).

  • You cannot use redirections such as > out.txt - they are passed as _literal arguments_ to the target program (if the target program happens to be a shell, _it_ would interpret it).
  • You cannot enclose the command line in (...) - because the closing ) is interpreted as a literal part of the command line.
  • (As implied in the OP) You cannot follow the command line with ; and another statement - because the ; is interpreted as a literal part of the command line.
  • You cannot use --% inside a _single-line_ script block - because the closing } is interpreted as a literal part of the command line.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

garegin16 picture garegin16  路  3Comments

andschwa picture andschwa  路  3Comments

pcgeek86 picture pcgeek86  路  3Comments

rkeithhill picture rkeithhill  路  3Comments

manofspirit picture manofspirit  路  3Comments