04abbd8436
Following on from the changes in PR #4781, we can make additional message strings translatable using the tr.Tr.Get() method. Because this method performs printf(3)-style format string parsing and interpolation, we can simplify some of the surrounding calls, e.g., from fmt.Errorf() to errors.New(), and from fmt.Fprintf() to fmt.Fprintln(). This ensures that if either the translated text or any interpolated arguments happen to contain character sequences that would be interpreted as Go format specifiers (e.g., "%s" or "%d"), these will not result in warnings such as "%!s(MISSING)" in the output text. Note also that we try to remove newlines from the message strings were possible and change the surrounding calls to append them instead, e.g., with fmt.Fprintln().
38 lines
605 B
Go
38 lines
605 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
"sync"
|
|
"syscall"
|
|
|
|
"github.com/git-lfs/git-lfs/v3/commands"
|
|
"github.com/git-lfs/git-lfs/v3/tr"
|
|
)
|
|
|
|
func main() {
|
|
c := make(chan os.Signal)
|
|
signal.Notify(c, os.Interrupt, os.Kill)
|
|
|
|
var once sync.Once
|
|
|
|
go func() {
|
|
for {
|
|
sig := <-c
|
|
once.Do(commands.Cleanup)
|
|
fmt.Fprintf(os.Stderr, "\n%s\n", tr.Tr.Get("Exiting because of %q signal.", sig))
|
|
|
|
exitCode := 1
|
|
if sysSig, ok := sig.(syscall.Signal); ok {
|
|
exitCode = int(sysSig)
|
|
}
|
|
os.Exit(exitCode + 128)
|
|
}
|
|
}()
|
|
|
|
code := commands.Run()
|
|
once.Do(commands.Cleanup)
|
|
os.Exit(code)
|
|
}
|