{"record":{"id":"0fb4147537ed53af","repo":"junegunn/fzf","slug":"number-of-items-to-keep-must-be-a-positive-integer","errorCode":null,"errorMessage":"number of items to keep must be a positive integer","messagePattern":"number of items to keep must be a positive integer","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/options.go","lineNumber":2881,"sourceCode":"\t\t\tstr, err := nextString(\"nth expression required\")\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif opts.IdNth, err = splitNth(str); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase \"--no-id-nth\":\n\t\t\topts.IdNth = nil\n\t\tcase \"--tac\":\n\t\t\topts.Tac = true\n\t\tcase \"--no-tac\":\n\t\t\topts.Tac = false\n\t\tcase \"--tail\":\n\t\t\tif opts.Tail, err = nextInt(\"number of items to keep required\"); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif opts.Tail <= 0 {\n\t\t\t\treturn errors.New(\"number of items to keep must be a positive integer\")\n\t\t\t}\n\t\tcase \"--no-tail\":\n\t\t\topts.Tail = 0\n\t\tcase \"--smart-case\":\n\t\t\topts.Case = CaseSmart\n\t\tcase \"-i\", \"--ignore-case\":\n\t\t\topts.Case = CaseIgnore\n\t\tcase \"+i\", \"--no-ignore-case\":\n\t\t\topts.Case = CaseRespect\n\t\tcase \"-m\", \"--multi\":\n\t\t\tif opts.Multi, err = optionalNumeric(maxMulti); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase \"+m\", \"--no-multi\":\n\t\t\topts.Multi = 0\n\t\tcase \"--ansi\":\n\t\t\topts.Ansi = true\n\t\tcase \"--no-ansi\":","sourceCodeStart":2863,"sourceCodeEnd":2899,"githubUrl":"https://github.com/junegunn/fzf/blob/bd4efa277b49ef34ca4025bff9b1a288e1980eff/src/options.go#L2863-L2899","documentation":"Thrown when --tail receives a value <= 0. --tail keeps only the last N items of the input for a fast initial listing; 0 or negative values are meaningless (use --no-tail to disable tailing) and are rejected after the integer itself parsed successfully.","triggerScenarios":"`--tail 0`, `--tail -5`, or `--tail \"$(($LINES-100))\"` computing to <= 0 on small inputs/terminals.","commonSituations":"Dynamic tail sizing from terminal height or input length (wc -l) that underflows; users writing --tail 0 expecting to mean 'no tail' instead of --no-tail.","solutions":["Use --no-tail to disable tailing instead of --tail 0","Clamp computed values: N=$((LINES)); [ \"$N\" -lt 1 ] && N=1","Pass a positive count: `--tail 1000`"],"exampleFix":"# before\nfzf --tail \"$((LINES-100))\"\n# after\nN=$((LINES-100)); [ \"$N\" -lt 1 ] && N=1\nfzf --tail \"$N\"","handlingStrategy":"validation","validationCode":"# bash\nTAIL_N=\"${TAIL_N:-0}\"\nif [ \"$TAIL_N\" -gt 0 ] 2>/dev/null; then TAIL=(--tail \"$TAIL_N\"); else TAIL=(--no-tail); fi\nfzf \"${TAIL[@]}\"","typeGuard":"tail_ok() { [[ \"$1\" =~ ^[1-9][0-9]*$ ]]; }","tryCatchPattern":null,"preventionTips":["Use --no-tail to disable tailing, never --tail 0","Clamp computed tail counts to at least 1"],"tags":["fzf","go","cli","performance","validation"],"backgroundTag":null,"analyzedSha":"bd4efa277b49ef34ca4025bff9b1a288e1980eff","analyzedAt":"2026-08-15T06:11:46.983Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}