exit noms as soon as less quits, not when stdout closes (#2068)

This commit is contained in:
Ben Kalman
2016-07-15 10:10:57 -07:00
committed by GitHub
parent be463555f6
commit 534faa6b6d
4 changed files with 13 additions and 13 deletions
+7 -7
View File
@@ -51,16 +51,16 @@ func runDiff(args []string) int {
}
defer db2.Close()
waitChan := outputpager.PageOutput(!outputpager.NoPager)
waitChan := outputpager.PageOutput()
w := bufio.NewWriter(os.Stdout)
diff.Diff(w, value1, value2)
fmt.Fprintf(w, "\n")
w.Flush()
if waitChan != nil {
os.Stdout.Close()
<-waitChan
go func() {
<-waitChan
os.Exit(0)
}()
}
diff.Diff(w, value1, value2)
return 0
}
+1 -1
View File
@@ -70,7 +70,7 @@ func runLog(args []string) int {
d.CheckErrorNoUsage(fmt.Errorf("Object not found: %s", args[0]))
}
waitChan := outputpager.PageOutput(!outputpager.NoPager)
waitChan := outputpager.PageOutput()
origCommit, ok := value.(types.Struct)
if !ok || !origCommit.Type().Equals(datas.CommitType()) {
+1 -1
View File
@@ -40,7 +40,7 @@ func runShow(args []string) int {
return 0
}
waitChan := outputpager.PageOutput(!outputpager.NoPager)
waitChan := outputpager.PageOutput()
w := bufio.NewWriter(os.Stdout)
types.WriteEncodedValueWithTags(w, value)
+4 -4
View File
@@ -14,19 +14,19 @@ import (
)
var (
NoPager bool
noPager bool
flagsRegistered = false
)
func RegisterOutputpagerFlags(flags *flag.FlagSet) {
if !flagsRegistered {
flagsRegistered = true
flags.BoolVar(&NoPager, "no-pager", false, "suppress paging functionality")
flags.BoolVar(&noPager, "no-pager", false, "suppress paging functionality")
}
}
func PageOutput(usePager bool) <-chan struct{} {
if !usePager || !IsStdoutTty() {
func PageOutput() <-chan struct{} {
if noPager || !IsStdoutTty() {
return nil
}