X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=status.go;h=03f4ce0ffa520fec522af908da176d1f472b9721;hb=HEAD;hp=b918c65671dfbe5ebedb32dfadc9a43a5adcac7b;hpb=a3d6bbf97e90bf923142d061bc68b28cc1dec2a8;p=goredo.git diff --git a/status.go b/status.go index b918c65..03f4ce0 100644 --- a/status.go +++ b/status.go @@ -1,25 +1,24 @@ -/* -goredo -- redo implementation on pure Go -Copyright (C) 2020 Sergey Matveev - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ +// goredo -- djb's redo implementation on pure Go +// Copyright (C) 2020-2024 Sergey Matveev +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . package main import ( "flag" "fmt" + "log" "os" ) @@ -36,9 +35,17 @@ const ( var ( FdStatus *os.File - flagNoStatus = flag.Bool("no-status", false, "disable statusline (REDO_NO_STATUS=1)") + flagNoStatus *bool ) +func init() { + cmdName := CmdName() + if !(cmdName == CmdNameRedo || cmdName == CmdNameRedoIfchange) { + return + } + flagNoStatus = flag.Bool("no-status", false, "disable statusline (REDO_NO_STATUS=1)") +} + func statusInit() { if NoProgress || *flagNoStatus { return @@ -57,7 +64,7 @@ func statusInit() { var err error r, FdStatus, err = os.Pipe() if err != nil { - panic(err) + log.Fatal(err) } go func() { running := 0 @@ -95,8 +102,9 @@ func statusInit() { CJS, done, CReset, ) } + out = erasedStatus(out, "\r") LogMutex.Lock() - os.Stderr.WriteString(fillUpToTermSize(out, "\r")) + os.Stderr.WriteString(out) LogMutex.Unlock() } }()