I have this bash script:
#!/bin/bash -xe
set -xe
function build() {
git clone --mirror https://github.com/digi-embedded/u-boot.git
}
time build $@ |& tee /tmp/build.log
When I run it:
./build.sh
it hangs. Adding verbose/trace like this:
GIT_CURL_VERBOSE=1 GIT_TRACE=1 \
git clone --mirror https://github.com/digi-embedded/u-boot.git
shows that it is stuck in the fetch part.
But, running the git clone on its own works fine:
git clone --mirror https://github.com/digi-embedded/u-boot.git
Then I changed my script to remove the tee, and everything just worked!
#!/bin/bash -xe
set -xe
function build() {
git clone --mirror https://github.com/digi-embedded/u-boot.git
}
time build $@ # |& tee /tmp/build.log
Why does the tee cause git clone to fail?
Like many other commands (
lswill toggle between multi column display whilels | catwill show 1 item per line,grepwill color its matches whilegrep | catwill have a plain output ...),git clonechecks whether its output (it looks likegit clonespecifically checks its stderr) is actually a terminal (a tty) and changes the information it outputs based on that.It is the normal behavior to not see the progress meters when redirecting stderr.
You can instruct
git cloneto output its progress on stderr anyway by adding--progress; if you turn it on and still redirect stderr to/tmp/build.log, you will see that the content of yourbuild.logfile is a bit funky.Check if your "git clone doesn't work" impression is real, or just the fact that since you don't have the meter anymore it feels stuck.