Merge pull request #598 from Morganamilo/newline

Split stdin on new line
This commit is contained in:
Anna 2018-07-30 05:03:24 +01:00 committed by GitHub
commit 158e44cb1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,10 +1,10 @@
package main
import (
"bufio"
"bytes"
"fmt"
"html"
"io"
"os"
"strconv"
"strings"
@ -537,21 +537,15 @@ func (parser *arguments) parseLongOption(arg string, param string) (usedNext boo
return
}
func (parser *arguments) parseStdin() (err error) {
for {
var target string
_, err = fmt.Scan(&target)
func (parser *arguments) parseStdin() error {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanLines)
if err != nil {
if err == io.EOF {
err = nil
}
return
}
parser.addTarget(target)
for scanner.Scan() {
parser.addTarget(scanner.Text())
}
return os.Stdin.Close()
}
func (parser *arguments) parseCommandLine() (err error) {