I develop an application with command line parameters and use it in cmd shell and powershell. There it is obvious that the arguments are received differently in main() of my application.
static void Main(string[] args)
{
// In cmd shell: args[0] == "-ipaddress=127.0.0.1"
// In powershell: args[0] == "-ipaddress=127"
// and args[1] == ".0.0.1"
}
Example: myApp.exe -ipaddress=127.0.0.1
In my C# application the arguments are interpreted differently depending on the shell I start the app in.
- In cmd shell: arg[0]=-ipaddress=127.0.0.1
- In powershell: arg[0]=-ipaddress=127 and arg[1]=.0.0.1
What is best practice here?
- Should I join all args[] and parse the arguments in my application?
- Should I rely on the shell's parser?