Reputation: 16186
I'm using dotnet-script
for the first time, I'm getting some undesirable behavior I don't know how to fix.
My script expects a "-v" argument, but instead of that getting passed through, dotnet-script swallows it and prints out its own version number. This happens for the most basic of scripts:
#!/usr/bin/env dotnet-script
Console.WriteLine($"Hello World:\n{string.Join('\n', Args)}");
Example input/output:
> ./script.csx "hi again"
Hello World:
hi again
> ./script.csx "hi again" -v
1.4.0
How can I avoid dotnet-script
swallowing arguments?
I know I could avoid using the -v argument in my script, but I'd like to avoid this behavior entirely so I don't come across other swallowed arguments.
Upvotes: 0
Views: 70
Reputation: 37070
I've never used dotnet-script
before, but after a quick search I found this source which states:
"All arguments before
--
are processed by dotnet script and all arguments after--
are passed to the script"
So it sounds to me like perhaps you just need to add --
before the arguments that you want passed to your script:
> ./script.csx -- "hi again" -v
Upvotes: 2