My urfave/cli version is
3.6.x (works in 3.5.0)
Checklist
Dependency Management
- My project is using go modules.
- My project is downloading the latest version when go get -u is ran
Describe the bug
We have:
- a command with SliceFlagSeparator set to space (
" ") instead of the default comma
- a stringsliceflag named "a" (for example) in that command that uses some environment variable (A) as alternate source
Working as expected, meaning slice returned by cmd.StringSlice is [ "0", "1" ]:
- using
--a 0 --a 1 command-line options
- using
--a "0 1 " command-line
No longer working since 3.6.0, meaning slice returned by cmd.StringSlice is [ "0 1" ]:
- using environment variable
A="0 1"
Note that A="0,1" environment variable returns [ "0", "1" ] although this is unexpected since slice separator was set to a spec.
To reproduce
Build a main.go file with the following content and run passing command-line options or environment variable
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/urfave/cli/v3"
)
func main() {
cmd := &cli.Command{
Flags: []cli.Flag{
&cli.StringSliceFlag{
Name: "a",
Sources: cli.EnvVars("A"),
},
},
// Ignored by Sources: will use , instead for environment variables
SliceFlagSeparator: " ",
Action: func(ctx context.Context, cmd *cli.Command) error {
for i, v := range cmd.StringSlice("a") {
fmt.Printf("#%02d: %+v\n", i, v)
}
return nil
},
}
if err := cmd.Run(context.Background(), os.Args); err != nil {
log.Fatal(err)
}
}
Observed behavior
go run main.go --a 0 --a 1
#00: 0
#01: 1
go run main.go --a "0 1"
#00: 0
#01: 1
A="0 1" go run main.go
#00: 0 1
A="0,1" go run main.go
#00: 0
#01: 1
Expected behavior
go run main.go --a 0 --a 1
#00: 0
#01: 1
go run main.go --a "0 1"
#00: 0
#01: 1
A="0 1" go run main.go
#00: 0
#01: 1
A="0,1" go run main.go
#00: 0,1
Additional context
N/A
Run go version and paste its output here
go version go1.25.6 linux/amd64
Run go env and paste its output here
AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='0'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/xxx/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/xxx/.config/go/env'
GOEXE=''
GOEXPERIMENT='jsonv2'
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1788838360=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/xxx/go.mod'
GOMODCACHE='/home/xxx/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/xxx/go'
GOPRIVATE=''
GOROOT='/usr/lib/go'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/xxx/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.25.6'
GOWORK=''
My urfave/cli version is
3.6.x (works in 3.5.0)
Checklist
Dependency Management
Describe the bug
We have:
" ") instead of the default commaWorking as expected, meaning slice returned by cmd.StringSlice is
[ "0", "1" ]:--a 0 --a 1command-line options--a "0 1 "command-lineNo longer working since 3.6.0, meaning slice returned by cmd.StringSlice is
[ "0 1" ]:A="0 1"To reproduce
Build a
main.gofile with the following content and run passing command-line options or environment variableObserved behavior
Expected behavior
Additional context
N/A
Run
go versionand paste its output hereRun
go envand paste its output here