Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing expression after unary operator '--'

This is my first post so apologies for any mistakes.

I ran the dotnet command in the Windows Powershell and It gave me a description of how to use it:

Usage: dotnet [host-options] [command] [arguments] [common-options]

Common options:  
  -v|--verbose          Enable verbose output  
  -h|--help             Show help

When I ran the command

dotnet run -h|--help

It gave me the following error:

At line:1 char:17
+ dotnet run -h|--help
+                 ~
Missing expression after unary operator '--'.
At line:1 char:15
+ dotnet run -h|--help
+               ~~
Expressions are only allowed as the first element of a pipeline.
At line:1 char:17
+ dotnet run -h|--help
+                 ~~~~
Unexpected token 'help' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingExpressionAfterOperator

Any ideas why this is happening? Why is the command not showing help as intended? Having searched everywhere, I haven't been able to get a conclusive answer.

like image 847
SaintNerevar Avatar asked Dec 18 '22 06:12

SaintNerevar


1 Answers

-v|--verbose means you can use either -v or --verbose ; the | in this context is BNF's 'or' symbol.

Many options come in short form with a single (or few) letters mnemonic, or in long form which is more descriptive of the option. The short form will start with a single dash, while the long form starts with two dashes.

| in the context of powershell is a pipe, which separates commands, and the errors you see is the interpreter trying to make sense of --help as a command : it understands -- as the unary minus, but can't make sense of help in that context.

You probably want to use dotnet run -h.

like image 184
Aaron Avatar answered Jan 05 '23 10:01

Aaron