{"record":{"id":"5d7e4b5d7ee48a88","repo":"Jguer/yay","slug":"argument-specified-without-input-on-stdin","errorCode":null,"errorMessage":"argument '-' specified without input on stdin","messagePattern":"argument '-' specified without input on stdin","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/settings/parser/parser.go","lineNumber":606,"sourceCode":"\tcase hasParam(arg):\n\t\terr = a.addParam(arg, param)\n\t\tusedNext = true\n\tdefault:\n\t\terr = a.AddArg(arg)\n\t}\n\n\treturn\n}\n\nfunc (a *Arguments) parseStdin() error {\n\tfi, err := os.Stdin.Stat()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Ensure data is piped\n\tif (fi.Mode() & os.ModeCharDevice) != 0 {\n\t\treturn errors.New(gotext.Get(\"argument '-' specified without input on stdin\"))\n\t}\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanLines)\n\n\tfor scanner.Scan() {\n\t\ta.AddTarget(scanner.Text())\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\treturn err\n\t}\n\n\treturn os.Stdin.Close()\n}\n\nfunc (a *Arguments) Parse() error {\n\targs := os.Args[1:]","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/settings/parser/parser.go#L588-L624","documentation":"parseStdin in pkg/settings/parser/parser.go:606 handles the '-' pseudo-argument, which means 'read targets from stdin'. Before reading it checks whether stdin is a character device (an interactive terminal); if so there is no piped input, and it errors with 'argument '-' specified without input on stdin'. It exists so '-' is not silently hung waiting on terminal input.","triggerScenarios":"Parse() is called with the argument '-' while os.Stdin is still attached to the TTY, i.e. no pipe or redirected file is feeding stdin.","commonSituations":"Typing 'pacman -S -' (or yay equivalent) directly in a terminal instead of piping (e.g. 'echo pkg | pacman -S -'); running the command from a script without redirecting stdin; stdin closed/reopened incorrectly in tests or wrappers.","solutions":["Pipe input into the command: echo \"pkgname\" | yay -S - or provide targets directly as arguments.","Remove the '-' argument if you did not intend stdin-based target reading.","In scripts, redirect stdin explicitly (cmd < filelist.txt) when using '-'.","When invoking programmatically, set cmd.Stdin to a buffer/pipe before calling Parse."],"exampleFix":"// before\nyay -S -            # run interactively, nothing on stdin\n// after\necho \"ripgrep\" | yay -S -","handlingStrategy":"validation","validationCode":"// Ensure '-' is only used when stdin is piped\nfi, _ := os.Stdin.Stat()\npiped := fi != nil && (fi.Mode()&os.ModeCharDevice) == 0\nif slices.Contains(args, \"-\") && !piped {\n    return errors.New(\"'-' requires piped stdin: echo pkg | cmd -\")\n}","typeGuard":null,"tryCatchPattern":"if err := args.Parse(); err != nil {\n    if strings.Contains(err.Error(), \"specified without input on stdin\") {\n        return usageError(\"drop '-' or pipe targets into stdin\")\n    }\n    return err\n}","preventionTips":["Only use '-' when a pipe or redirection feeds stdin","In scripts, always redirect stdin explicitly when using '-'","Prefer passing target names as direct arguments in interactive use","When embedding the parser in tests/tools, wire os.Stdin to a real pipe before Parse"],"tags":["cli","stdin","parser","pipelines"],"backgroundTag":"missing-required-argument","analyzedSha":"328f4b4939fb35f38c2f7c7ce3b8638a839bafa5","analyzedAt":"2026-09-07T16:45:12.608Z","contentChangedAt":"2026-09-07T16:45:12.608Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}