fix panic (#12)

* c.Args().Len() - 1 might be negative value

* fix getStdinLinesOrFirstArgument

* fix getStdinLinesOrFirstArgument
This commit is contained in:
mattn
2024-02-03 22:03:32 +09:00
committed by GitHub
parent 0b9e861f90
commit 01e1f52a70
5 changed files with 35 additions and 18 deletions

View File

@@ -47,12 +47,11 @@ func getStdinLinesOrBlank() chan string {
}
}
func getStdinLinesOrFirstArgument(c *cli.Context) chan string {
func getStdinLinesOrFirstArgument(arg string) chan string {
// try the first argument
target := c.Args().First()
if target != "" {
if arg != "" {
single := make(chan string, 1)
single <- target
single <- arg
close(single)
return single
}