{"record":{"id":"8791cfb733110c71","repo":"wavetermdev/waveterm","slug":"too-many-arguments","errorCode":null,"errorMessage":"too many arguments","messagePattern":"too many arguments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-setbg.go","lineNumber":129,"sourceCode":"\tmeta := map[string]interface{}{}\n\n\t// Handle opacity-only change or clear\n\tif len(args) == 0 {\n\t\tif !cmd.Flags().Changed(\"opacity\") && !setBgClear && !borderColorChanged && !activeBorderColorChanged {\n\t\t\tOutputHelpMessage(cmd)\n\t\t\treturn fmt.Errorf(\"setbg requires an image path or color value\")\n\t\t}\n\t\tif setBgOpacity < 0 || setBgOpacity > 1 {\n\t\t\treturn fmt.Errorf(\"opacity must be between 0.0 and 1.0\")\n\t\t}\n\t\tif setBgClear {\n\t\t\tmeta[\"bg:*\"] = true\n\t\t} else if cmd.Flags().Changed(\"opacity\") {\n\t\t\tmeta[\"bg:opacity\"] = setBgOpacity\n\t\t}\n\t} else if len(args) > 1 {\n\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"too many arguments\")\n\t} else {\n\t\t// Handle background setting\n\t\tmeta[\"bg:*\"] = true\n\t\tmeta[\"tab:background\"] = nil\n\t\tif setBgOpacity < 0 || setBgOpacity > 1 {\n\t\t\treturn fmt.Errorf(\"opacity must be between 0.0 and 1.0\")\n\t\t}\n\t\tmeta[\"bg:opacity\"] = setBgOpacity\n\n\t\tinput := args[0]\n\t\tvar bgStyle string\n\n\t\t// Check for hex color\n\t\tif strings.HasPrefix(input, \"#\") {\n\t\t\tif err := validateHexColor(input); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tbgStyle = input","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-setbg.go#L111-L147","documentation":"`wsh setbg` accepts at most one positional argument (the image path or color value). When more than one positional argument is supplied, the command prints help text and returns this error rather than guessing which value to use.","triggerScenarios":"Running `wsh setbg image.png #ff0000`, or a color name containing a space that was not quoted/escaped so the shell split it into multiple args (e.g. `wsh setbg light blue` instead of `wsh setbg \"light blue\"`... note CSS names with spaces are not supported anyway, but unquoted args like `wsh setbg /path/with spaces/img.png` split into several arguments).","commonSituations":"Unquoted file paths containing spaces; users trying to set both an image and a fallback color in one call; scripts appending extra arguments.","solutions":["Quote paths containing spaces: `wsh setbg \"/path/to/my image.png\"`","Pass only one positional argument; combine flags instead of extra args","Use `--` before the path to stop flag parsing if the path starts with -"],"exampleFix":"// before\nwsh setbg /home/user/my images/bg.png\n// after\nwsh setbg \"/home/user/my images/bg.png\"","handlingStrategy":"validation","validationCode":"# shell-side guard before invoking wsh\nargs=(\"$@\")\nif [ ${#args[@]} -gt 1 ]; then\n  echo \"wsh setbg accepts at most one argument\" >&2; exit 2\nfi","typeGuard":null,"tryCatchPattern":"try {\n  execSync(`wsh setbg \"${imgPath}\"`, { stdio: \"pipe\" });\n} catch (e) {\n  if (String(e.stderr).includes(\"too many arguments\")) {\n    console.error(\"Quote the path or pass only one argument\");\n  } else throw e;\n}","preventionTips":["Always quote paths with spaces","Never concatenate an image path and a color in one invocation","Use shellcheck on scripts that build wsh command lines"],"tags":["cli","arguments","shell-quoting"],"backgroundTag":"too-many-arguments","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}