mirror of
https://github.com/rclone/rclone.git
synced 2025-08-18 01:20:16 +02:00
cmd: Make --progress work in git bash on Windows - fixes #3531
This detects the presence of a VT100 terminal by using the TERM environment variable and switches to using VT100 codes directly under windows if it is found. This makes --progress work correctly with git bash.
This commit is contained in:
@@ -23,10 +23,29 @@ const (
|
||||
logTimeFormat = "2006-01-02 15:04:05"
|
||||
)
|
||||
|
||||
var (
|
||||
initTerminal func() error
|
||||
writeToTerminal func([]byte)
|
||||
)
|
||||
|
||||
// Initialise the VT100 terminal
|
||||
func initTerminalVT100() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Write to the VT100 terminal
|
||||
func writeToTerminalVT100(b []byte) {
|
||||
_, _ = os.Stdout.Write(b)
|
||||
}
|
||||
|
||||
// startProgress starts the progress bar printing
|
||||
//
|
||||
// It returns a func which should be called to stop the stats.
|
||||
func startProgress() func() {
|
||||
if os.Getenv("TERM") != "" {
|
||||
initTerminal = initTerminalVT100
|
||||
writeToTerminal = writeToTerminalVT100
|
||||
}
|
||||
err := initTerminal()
|
||||
if err != nil {
|
||||
fs.Errorf(nil, "Failed to start progress: %v", err)
|
||||
|
Reference in New Issue
Block a user