{"record":{"id":"a64d23001ff0ad48","repo":"wavetermdev/waveterm","slug":"pid-flag-is-not-supported-on-windows","errorCode":null,"errorMessage":"--pid flag is not supported on Windows","messagePattern":"--pid flag is not supported on Windows","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-badge.go","lineNumber":51,"sourceCode":"\tbadgePid      int\n)\n\nfunc init() {\n\trootCmd.AddCommand(badgeCmd)\n\tbadgeCmd.Flags().StringVar(&badgeColor, \"color\", \"\", \"badge color\")\n\tbadgeCmd.Flags().Float64Var(&badgePriority, \"priority\", 10, \"badge priority\")\n\tbadgeCmd.Flags().BoolVar(&badgeClear, \"clear\", false, \"clear the badge\")\n\tbadgeCmd.Flags().BoolVar(&badgeBeep, \"beep\", false, \"play system bell sound\")\n\tbadgeCmd.Flags().IntVar(&badgePid, \"pid\", 0, \"watch a pid and automatically clear the badge when it exits (default priority 5)\")\n}\n\nfunc badgeRun(cmd *cobra.Command, args []string) (rtnErr error) {\n\tdefer func() {\n\t\tsendActivity(\"badge\", rtnErr == nil)\n\t}()\n\n\tif badgePid > 0 && runtime.GOOS == \"windows\" {\n\t\treturn fmt.Errorf(\"--pid flag is not supported on Windows\")\n\t}\n\tif badgePid > 0 && !cmd.Flags().Changed(\"priority\") {\n\t\tbadgePriority = 5\n\t}\n\n\toref, err := resolveBlockArg()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"resolving block: %v\", err)\n\t}\n\tif oref.OType != waveobj.OType_Block && oref.OType != waveobj.OType_Tab {\n\t\treturn fmt.Errorf(\"badge oref must be a block or tab (got %q)\", oref.OType)\n\t}\n\n\tvar eventData baseds.BadgeEvent\n\teventData.ORef = oref.String()\n\n\tif badgeClear {\n\t\teventData.Clear = true","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-badge.go#L33-L69","documentation":"The `wsh badge` command's --pid option targets the badge by process id, but this mechanism relies on platform support that is absent on Windows. badgeRun explicitly rejects the combination of badgePid > 0 and runtime.GOOS == \"windows\" with this error.","triggerScenarios":"Running `wsh badge --pid <n> ...` on a Windows machine. Any positive --pid value triggers the check regardless of other flags.","commonSituations":"Cross-platform scripts that pass --pid unconditionally; documentation or shell examples copied from macOS/Linux usage and run on Windows; CI jobs running the same badge command on all platforms.","solutions":["Remove the --pid flag when running on Windows and target a block/tab via the block argument instead.","Gate the flag in scripts: only pass --pid when the OS is not Windows (`if ! windows`).","Use `wsh badge --clear` or resolve the block by other means (resolveBlockArg) on Windows."],"exampleFix":"// before (fails on Windows)\nwsh badge --pid 1234 \"info\"\n\n// after\nif [[ \"$OSTYPE\" != msys* && \"$OSTYPE\" != cygwin* ]]; then\n  wsh badge --pid 1234 \"info\"\nelse\n  wsh badge --block <blockid> \"info\"\nfi","handlingStrategy":"validation","validationCode":"if runtime.GOOS == \"windows\" && badgePid > 0 {\n    // omit --pid; target the block/tab explicitly instead\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"not supported on Windows\") {\n    // rerun without --pid\n}","preventionTips":["Gate --pid behind an OS check in cross-platform scripts.","Prefer block/tab targeting over --pid on Windows.","Document platform-specific flags in shared scripts."],"tags":["cli","windows","unsupported-platform"],"backgroundTag":"unsupported-platform","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}