{"record":{"id":"0fb0918bc8d2f84c","repo":"alibaba/open-code-review","slug":"unsupported-shell-s","errorCode":null,"errorMessage":"unsupported shell: %s","messagePattern":"unsupported shell: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/completion.go","lineNumber":30,"sourceCode":"\nvar completionCmd = &cobra.Command{\n\tUse:       \"completion [bash|zsh|fish|powershell]\",\n\tShort:     \"Generate shell completion scripts\",\n\tLong:      completionLongHelp,\n\tValidArgs: []string{\"bash\", \"zsh\", \"fish\", \"powershell\"},\n\tArgs:      cobra.MatchAll(exactArgs(1), cobra.OnlyValidArgs),\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tswitch args[0] {\n\t\tcase \"bash\":\n\t\t\treturn rootCmd.GenBashCompletionV2(os.Stdout, true)\n\t\tcase \"zsh\":\n\t\t\treturn rootCmd.GenZshCompletion(os.Stdout)\n\t\tcase \"fish\":\n\t\t\treturn rootCmd.GenFishCompletion(os.Stdout, true)\n\t\tcase \"powershell\":\n\t\t\treturn rootCmd.GenPowerShellCompletionWithDesc(os.Stdout)\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unsupported shell: %s\", args[0])\n\t\t}\n\t},\n}\n\nconst completionLongHelp = `Generate shell completion scripts for OCR.\n\nTo load completions:\n\nBash:\n  $ source <(ocr completion bash)\n  # To load completions for each session, execute once:\n  # Linux:\n  $ ocr completion bash > /etc/bash_completion.d/ocr\n  # macOS:\n  $ ocr completion bash > $(brew --prefix)/etc/bash_completion.d/ocr\n\nZsh:\n  # If shell completion is not already enabled in your environment,","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/completion.go#L12-L48","documentation":"The `ocr completion` command generates shell completion scripts for a fixed set of shells (bash, zsh, fish, powershell via cobra generators). Any other first argument reaches the default branch and produces this error. There is no fuzzy matching and no case normalization.","triggerScenarios":"Running `ocr completion <arg>` where arg is not one of the supported shell names — e.g. `ocr completion Bash`, `ocr completion sh`, `ocr completion pwsh`, `ocr completion powershell.exe`.","commonSituations":"Following install docs written for another tool; using `pwsh` (PowerShell Core) expecting it to be recognized separately; capitalizing the shell name in a setup script; passing `zsh` to a tool that only lists it with different casing in docs.","solutions":["Use an exact supported name, lowercase: `ocr completion bash|zsh|fish|powershell`.","For PowerShell Core, `powershell` output also works: `ocr completion powershell > _ocr.ps1`.","For unsupported shells (e.g. sh/dash), fall back to bash completion or rely on cobra's __complete hidden command.","Check the command's long help (`ocr completion --help`) for the supported list."],"exampleFix":"// before\nocr completion Bash >> ~/.bashrc\n// after\nocr completion bash >> ~/.bashrc","handlingStrategy":"validation","validationCode":"// shell: verify the shell argument before invoking ocr completion\ncase \"$shell\" in\n  bash|zsh|fish|powershell) ocr completion \"$shell\" ;;\n  pwsh) ocr completion powershell ;;\n  *) echo \"unsupported shell: $shell\"; exit 1 ;;\nesac","typeGuard":null,"tryCatchPattern":"out, err := exec.Command(\"ocr\", \"completion\", shell).CombinedOutput()\nif err != nil && strings.Contains(string(out), \"unsupported shell\") {\n\treturn fmt.Errorf(\"completion only supports bash, zsh, fish, powershell\")\n}","preventionTips":["Always use lowercase shell names exactly as documented.","Map pwsh -> powershell in install scripts.","Read `ocr completion --help` rather than copying commands from other tools' docs."],"tags":["cli","completion","unsupported-value"],"backgroundTag":"unsupported-shell","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}