{"record":{"id":"deef51fb7cd773ff","repo":"charmbracelet/glow","slug":"unable-to-parse-pager-command-s","errorCode":null,"errorMessage":"unable to parse PAGER command: %s","messagePattern":"unable to parse PAGER command: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"main.go","lineNumber":324,"sourceCode":"\t\tcontent = utils.WrapCodeBlock(string(b), ext)\n\t}\n\n\tout, err := r.Render(content)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to render markdown: %w\", err)\n\t}\n\n\t// display\n\tswitch {\n\tcase pager || cmd.Flags().Changed(\"pager\"):\n\t\tpagerCmd := os.Getenv(\"PAGER\")\n\t\tif pagerCmd == \"\" {\n\t\t\tpagerCmd = \"less -r\"\n\t\t}\n\n\t\tfields, err := shell.Fields(pagerCmd, os.Getenv)\n\t\tif err != nil || len(fields) == 0 {\n\t\t\treturn fmt.Errorf(\"unable to parse PAGER command: %s\", pagerCmd)\n\t\t}\n\t\tc := exec.Command(fields[0], fields[1:]...) //nolint:gosec\n\t\tc.Stdin = strings.NewReader(out)\n\t\tc.Stdout = os.Stdout\n\t\tif err := c.Run(); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to run command: %w\", err)\n\t\t}\n\t\treturn nil\n\tcase tui || cmd.Flags().Changed(\"tui\"):\n\t\tpath := \"\"\n\t\tif !isURL(src.URL) {\n\t\t\tpath = src.URL\n\t\t}\n\t\treturn runTUI(path, content)\n\tdefault:\n\t\tif _, err = fmt.Fprint(w, out); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to write to writer: %w\", err)\n\t\t}","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/charmbracelet/glow/blob/e3970c813d93da1ea84edfca90c289d9afb82242/main.go#L306-L342","documentation":"When output goes through a pager (pager true or --pager changed), glow reads PAGER (defaulting to \"less -r\") and tokenizes it with shell.Fields from mvdan.cc/sh/v3 - a POSIX-style field splitter that honors quotes and variable expansion. This error means tokenization failed or produced no fields: the PAGER value is not a syntactically valid shell command line. The message includes the raw PAGER string so you can see what failed to parse.","triggerScenarios":"Unbalanced quotes in PAGER (PAGER='less -r\"), stray backslashes, or expansion errors inside the PAGER string; a PAGER that expands to an empty command line.","commonSituations":"User shell configs exporting PAGER with quoting mistakes, values copied from tutorials with smart/curly quotes, templates injecting broken quoting into PAGER.","solutions":["Check PAGER for unbalanced quotes or stray characters: echo \"$PAGER\"","Set a simple known-good value: export PAGER='less -r'","Temporarily unset PAGER (unset PAGER) to confirm it is the cause","Use straight ASCII quotes, not typographic ones, in shell configs"],"exampleFix":"# before\nexport PAGER='less -r\"   # unbalanced quote\n\n# after\nexport PAGER='less -r'","handlingStrategy":"validation","validationCode":"func pagerParses(pagerCmd string) bool {\n\tfields, err := shell.Fields(pagerCmd, os.Getenv)\n\treturn err == nil && len(fields) > 0\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate PAGER with shell.Fields before using it","Keep PAGER simple and single-quoted: export PAGER='less -r'","Avoid typographic quotes in shell configs"],"tags":["pager","shell","config","environment"],"backgroundTag":null,"analyzedSha":"e3970c813d93da1ea84edfca90c289d9afb82242","analyzedAt":"2026-08-15T22:50:54.304Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}