This is part of a larger script but I distilled the problem down to this:
cm_safe(){
git push | while read line; do
echo "cm safe push: $line"
done;
}
I want to prepend git output, so it would look like:
cm safe push: Everything up-to-date
but instead I just get:
Everything up-to-date
Is git writing to the tty or something directly? I dunno what's going on.
git push
writes to stderr so you would have to redirect that to stdout in order for it to be sent over the pipeline:
cm_safe(){
git push 2>&1 | while IFS= read -r line; do
echo "cm safe push: $line"
done
}
Alternatively you could do:
git push |& while IFS= read -r line; do
I recommend reading What are the shell's control and redirection operators? for more information.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments