{"record":{"id":"73a8355afdea261a","repo":"wavetermdev/waveterm","slug":"too-many-arguments-wsh-s-requires-exactly-one-a","errorCode":null,"errorMessage":"too many arguments.  wsh %s requires exactly one argument","messagePattern":"too many arguments\\.  wsh (.+?) requires exactly one argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-view.go","lineNumber":54,"sourceCode":"func init() {\n\tviewCmd.Flags().BoolVarP(&viewMagnified, \"magnified\", \"m\", false, \"open view in magnified mode\")\n\trootCmd.AddCommand(viewCmd)\n\teditCmd.Flags().BoolVarP(&viewMagnified, \"magnified\", \"m\", false, \"open view in magnified mode\")\n\trootCmd.AddCommand(editCmd)\n}\n\nfunc viewRun(cmd *cobra.Command, args []string) (rtnErr error) {\n\tcmdName := cmd.Name()\n\tdefer func() {\n\t\tsendActivity(cmdName, rtnErr == nil)\n\t}()\n\tif len(args) == 0 {\n\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"no arguments.  wsh %s requires a file or URL as an argument argument\", cmdName)\n\t}\n\tif len(args) > 1 {\n\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"too many arguments.  wsh %s requires exactly one argument\", cmdName)\n\t}\n\ttabId := getTabIdFromEnv()\n\tif tabId == \"\" {\n\t\treturn fmt.Errorf(\"no WAVETERM_TABID env var set\")\n\t}\n\tfileArg := args[0]\n\tconn := RpcContext.Conn\n\tvar wshCmd *wshrpc.CommandCreateBlockData\n\tif strings.HasPrefix(fileArg, \"http://\") || strings.HasPrefix(fileArg, \"https://\") {\n\t\twshCmd = &wshrpc.CommandCreateBlockData{\n\t\t\tTabId: tabId,\n\t\t\tBlockDef: &waveobj.BlockDef{\n\t\t\t\tMeta: map[string]any{\n\t\t\t\t\twaveobj.MetaKey_View: \"web\",\n\t\t\t\t\twaveobj.MetaKey_Url:  fileArg,\n\t\t\t\t},\n\t\t\t},\n\t\t\tMagnified: viewMagnified,","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-view.go#L36-L72","documentation":"The wsh view command accepts exactly one positional argument: a single file path or URL. viewRun enforces `len(args) > 1` and rejects the invocation, printing help plus this error, because there is no defined behavior for multiple targets in one command call.","triggerScenarios":"Running `wsh view file1 file2` or any invocation with two or more positional arguments, e.g. unquoted paths with spaces (`wsh view my file.txt` expands to two args) or leftover extra args in a script.","commonSituations":"Unquoted paths containing spaces in shell scripts; users trying to open several files at once; accidental extra flags parsed as positional args after `--`.","solutions":["Pass exactly one target; quote paths containing spaces: `wsh view \"my file.txt\"`","Open multiple files with separate invocations: `wsh view a.md && wsh view b.md`","Check `echo $#` or your wrapper's arg count before delegating to wsh"],"exampleFix":"// before\n$ wsh view my file.txt   // two args -> error\n\n// after\n$ wsh view \"my file.txt\"","handlingStrategy":"validation","validationCode":"set -- \"$@\"\nif [ \"$#\" -ne 1 ]; then echo \"wsh view takes exactly one argument\" >&2; exit 2; fi\nwsh view \"$1\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote paths containing spaces","Open multiple targets with separate invocations","Count args in wrapper scripts before delegating"],"tags":["cli","argument-validation","wsh"],"backgroundTag":"too-many-cli-arguments","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}