Skip to content

Commit 391d2e0

Browse files
authored
Merge pull request docker#9592 from nicksieger/fix-panic-empty-string-arg
fix: panic caused by empty string argument
2 parents cc2dc86 + fd5e8b8 commit 391d2e0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

cmd/compatibility/convert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func Convert(args []string) []string {
5050
l := len(args)
5151
for i := 0; i < l; i++ {
5252
arg := args[i]
53-
if arg[0] != '-' {
53+
if len(arg) > 0 && arg[0] != '-' {
5454
// not a top-level flag anymore, keep the rest of the command unmodified
5555
if arg == compose.PluginName {
5656
i++

cmd/compatibility/convert_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ func Test_convert(t *testing.T) {
6868
args: []string{"--log-level", "INFO", "up"},
6969
want: []string{"--log-level", "INFO", "compose", "up"},
7070
},
71+
{
72+
name: "empty string argument",
73+
args: []string{"--project-directory", "", "ps"},
74+
want: []string{"compose", "--project-directory", "", "ps"},
75+
},
7176
}
7277
for _, tt := range tests {
7378
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)