You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot parse empty string as argument of option #1551
and run the program with arguments --exec-prefix "", then I expect it to override the default value "/usr/local" with an empty string, but it instead reports an error:
Required argument missing for option: '--exec-prefix'.
--exec-prefix="" has the same result.
The #1533 fix in 260a559 looks related, but I don't know whether this has worked in earlier versions, either.
but I don't know whether this has worked in earlier versions, either.
Both --exec-prefix "" as well as --exec-prefix="" still worked in 2.0.0-beta1.21524.1.
2.0.0-beta1.21525.1 changed the behavior of --exec-prefix="" but left --exec-prefix "" still intact.
It is also broken in some way, currently (2.0.0-beta2.21623.1). If one wants to define an Argument<string> additionally to the Option<string> from the code in the report above, System.CommandLine gets confused when a commandline like
In my subjective and cheap opinion, changing the behavior of --exec-prefix="" and then later also of --exec-prefix "" was the wrong call.
I see no good reason to prohibit a user from providing an empty commandline argument like --exec-prefix "".
Since --exec-prefix="" as well as --exec-prefix:"" are supposed to be synonymous with --exec-prefix "", for consistency reasons both --exec-prefix="" and --exec-prefix:"" should be allowed as well.
Which in the end means, due to how commandline arguments are processed and fed into the args parameter of the Main method (at least on Windows), that --exec-prefix= and --exec-prefix: should be allowed too, representing the option with an implied empty value. I would find this the lesser evil than just outright prohibiting empty option arguments. (Just my two cents, of course...)
The --exec-prefix="" half of this report is still reproducible on 3.0.0-rc.3.26522.148. 55d6172 fixed the separate-argv form (--exec-prefix "") by removing the arg.Length > 0 guard, but TrySplitIntoSubtokens still discards an empty remainder, so --exec-prefix= yields Required argument missing. Filed as #2872 with a repro, since this issue is closed.
Activity
elgonzo commentedon Dec 27, 2021
Both
--exec-prefix ""as well as--exec-prefix=""still worked in 2.0.0-beta1.21524.1.2.0.0-beta1.21525.1 changed the behavior of
--exec-prefix=""but left--exec-prefix ""still intact.It is also broken in some way, currently (2.0.0-beta2.21623.1). If one wants to define an
Argument<string>additionally to theOption<string>from the code in the report above, System.CommandLine gets confused when a commandline likeor
is provided. In these situations, System.CommandLine will mistake the value abc as the --exec-prefix option argument.
Dotnetfiddle: https://dotnetfiddle.net/ORb4sz
In my subjective and cheap opinion, changing the behavior of
--exec-prefix=""and then later also of--exec-prefix ""was the wrong call.I see no good reason to prohibit a user from providing an empty commandline argument like
--exec-prefix "".Since
--exec-prefix=""as well as--exec-prefix:""are supposed to be synonymous with--exec-prefix "", for consistency reasons both--exec-prefix=""and--exec-prefix:""should be allowed as well.Which in the end means, due to how commandline arguments are processed and fed into the args parameter of the Main method (at least on Windows), that
--exec-prefix=and--exec-prefix:should be allowed too, representing the option with an implied empty value. I would find this the lesser evil than just outright prohibiting empty option arguments. (Just my two cents, of course...)fix dotnet#1551
ilyapalkin commentedon Jul 7, 2023
I face the similar error on
2.0.0-beta4.22272.1when provide--exec-prefix=""My code:
How to handle empty srtring as a parameter valu?
fix dotnet#1551
ViktorHofer commentedon Oct 30, 2026
The
--exec-prefix=""half of this report is still reproducible on3.0.0-rc.3.26522.148. 55d6172 fixed the separate-argv form (--exec-prefix "") by removing thearg.Length > 0guard, butTrySplitIntoSubtokensstill discards an empty remainder, so--exec-prefix=yieldsRequired argument missing. Filed as #2872 with a repro, since this issue is closed.