Pash-Project / Pash

An Open Source reimplementation of Windows PowerShell, for Mono.
https://groups.google.com/group/pash-project
BSD 3-Clause "New" or "Revised" License
514 stars 54 forks source link

Command line switches #406

Open ForNeVeR opened 8 years ago

ForNeVeR commented 8 years ago

With PowerShell (or even bash) I can execute commands as powershell -Command "2 + 2" or powershell -c 2 + 2.

Pash introduces another convention without that -c option: just pash "2 + 2". Although pash 2 + 2 will not work:

$ pash 2 + 2
Parse error at (0:4): Syntax error, expected: (, $(, @(, {, @{, decimal_integer_literal, ...
> 2; +; 2;
      ^
  +CategoryInfo: ParserError, Reason: ParseException
  +FullyQualifiedErrorId: Parse

What command line argument scheme should we use? Both PowerShell and bash have other useful switches aside -c, and the "default" mode for them is to treat the parameter as a filename.

Maybe Pash should follow the same convention? E.g. pash file.ps1 will execute a file (and nothing else), but pash -c "2 + 2" or even pash -c 2 + 2 should execute an inline command.

JayBazuzi commented 8 years ago

IMO, we should try to mimic PowerShell, as much as it makes sense.

For reference, these work in PowerShell:

C:\>powershell 2 + 2
4

C:\>powershell "2 + 2"
4