Commit 99db1e3
Fix FirstArgumentIsRootCommand falsely matching option values (#2789)
Path.GetFileName(args[0]) extracts the last path segment, which falsely
matches command names embedded in option values. For example,
"/p:Key=something/dotnet" yields "dotnet" from GetFileName, matching a
command named "dotnet". This causes the tokenizer to consume args[0] as
the root command instead of parsing it as an option.
Replace the Path.GetFileName heuristic with an exact match against the
command name. The only other case (args[0] == RootCommand.ExecutablePath)
is already handled by a separate check.
Co-authored-by: Jon Sequeira <jonsequeira@gmail.com>1 parent 857b4c3 commit 99db1e3
2 files changed
Lines changed: 35 additions & 11 deletions
File tree
- src
- System.CommandLine.Tests
- System.CommandLine/Parsing
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
104 | 137 | | |
105 | 138 | | |
106 | 139 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
| 278 | + | |
279 | 279 | | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
| 280 | + | |
290 | 281 | | |
291 | 282 | | |
292 | 283 | | |
| |||
0 commit comments