wavetermdev/waveterm · error

too many arguments

Error message

too many arguments

What it means

`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.

Source

Thrown at cmd/wsh/cmd/wshcmd-setbg.go:129

	meta := map[string]interface{}{}

	// Handle opacity-only change or clear
	if len(args) == 0 {
		if !cmd.Flags().Changed("opacity") && !setBgClear && !borderColorChanged && !activeBorderColorChanged {
			OutputHelpMessage(cmd)
			return fmt.Errorf("setbg requires an image path or color value")
		}
		if setBgOpacity < 0 || setBgOpacity > 1 {
			return fmt.Errorf("opacity must be between 0.0 and 1.0")
		}
		if setBgClear {
			meta["bg:*"] = true
		} else if cmd.Flags().Changed("opacity") {
			meta["bg:opacity"] = setBgOpacity
		}
	} else if len(args) > 1 {
		OutputHelpMessage(cmd)
		return fmt.Errorf("too many arguments")
	} else {
		// Handle background setting
		meta["bg:*"] = true
		meta["tab:background"] = nil
		if setBgOpacity < 0 || setBgOpacity > 1 {
			return fmt.Errorf("opacity must be between 0.0 and 1.0")
		}
		meta["bg:opacity"] = setBgOpacity

		input := args[0]
		var bgStyle string

		// Check for hex color
		if strings.HasPrefix(input, "#") {
			if err := validateHexColor(input); err != nil {
				return err
			}
			bgStyle = input

View on GitHub (pinned to a4447c1563)

Solutions

  1. Quote paths containing spaces: `wsh setbg "/path/to/my image.png"`
  2. Pass only one positional argument; combine flags instead of extra args
  3. Use `--` before the path to stop flag parsing if the path starts with -

Example fix

// before
wsh setbg /home/user/my images/bg.png
// after
wsh setbg "/home/user/my images/bg.png"
Defensive patterns

Strategy: validation

Validate before calling

# shell-side guard before invoking wsh
args=("$@")
if [ ${#args[@]} -gt 1 ]; then
  echo "wsh setbg accepts at most one argument" >&2; exit 2
fi

Try / catch

try {
  execSync(`wsh setbg "${imgPath}"`, { stdio: "pipe" });
} catch (e) {
  if (String(e.stderr).includes("too many arguments")) {
    console.error("Quote the path or pass only one argument");
  } else throw e;
}

Prevention

When it happens

Trigger: 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).

Common situations: Unquoted file paths containing spaces; users trying to set both an image and a fallback color in one call; scripts appending extra arguments.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/8791cfb733110c71. Report an issue: GitHub.