Skip to content

Commit 57c4c43

Browse files
fix(cli): correct environment variable parsing for comma-separated values
1 parent f1c1f29 commit 57c4c43

File tree

1 file changed

+6
-4
lines changed
  • components/gitpod-cli/cmd

1 file changed

+6
-4
lines changed

components/gitpod-cli/cmd/env.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,16 +292,18 @@ func printVar(name string, value string, export bool) {
292292
func parseArgs(args []string, pattern string) ([]*serverapi.UserEnvVarValue, error) {
293293
vars := make([]*serverapi.UserEnvVarValue, len(args))
294294
for i, arg := range args {
295-
kv := strings.SplitN(arg, "=", 1)
296-
if len(kv) != 1 || kv[0] == "" {
295+
if arg == "" {
297296
return nil, GpError{Err: xerrors.Errorf("empty string (correct format is key=value)"), OutCome: utils.Outcome_UserErr, ErrorCode: utils.UserErrorCode_InvalidArguments}
298297
}
299298

300-
if !strings.Contains(kv[0], "=") {
299+
if !strings.Contains(arg, "=") {
301300
return nil, GpError{Err: xerrors.Errorf("%s has no equal character (correct format is %s=some_value)", arg, arg), OutCome: utils.Outcome_UserErr, ErrorCode: utils.UserErrorCode_InvalidArguments}
302301
}
303302

304-
parts := strings.SplitN(kv[0], "=", 2)
303+
parts := strings.SplitN(arg, "=", 2)
304+
if len(parts) != 2 {
305+
return nil, GpError{Err: xerrors.Errorf("invalid format: %s (correct format is key=value)", arg), OutCome: utils.Outcome_UserErr, ErrorCode: utils.UserErrorCode_InvalidArguments}
306+
}
305307

306308
key := strings.TrimSpace(parts[0])
307309
if key == "" {

0 commit comments

Comments
 (0)