Split stdin on new line

Pacman 5.1 changed the stdin seperation from whitespace to newline. To
maintain corectness we should also do this.
This commit is contained in:
morganamilo 2018-07-30 01:16:36 +01:00
parent bd3e1cd3a9
commit b4c102a17a
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E

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) {