#!/bin/bash
no_pipeline() {
while true; do
if [ $i = 0 ]; then
break
fi
i=$(( i - 1 ))
done
}
first_pipeline_element() {
while true; do
if [ $i = 0 ]; then
break
fi
i=$(( i - 1 ))
done | true
}
second_pipeline_element() {
true | while true; do
if [ $i = 0 ]; then
break
fi
i=$(( i - 1 ))
done | true
}
i=10
echo "[no_pipeline] start: $i"
no_pipeline
echo "[no_pipeline] end: $i"
echo
i=10
echo "[first_pipeline_element] start: $i"
first_pipeline_element
echo "[first_pipeline_element] end: $i"
echo
i=10
echo "[second_pipeline_element] start: $i"
second_pipeline_element
echo "[second_pipeline_element] end: $i"
echo
IyEvYmluL2Jhc2gKCm5vX3BpcGVsaW5lKCkgewoJd2hpbGUgdHJ1ZTsgZG8KCQlpZiBbICRpID0gMCBdOyB0aGVuCgkJCWJyZWFrCgkJZmkKCQlpPSQoKCBpIC0gMSApKQoJZG9uZQp9CiAKZmlyc3RfcGlwZWxpbmVfZWxlbWVudCgpIHsKCXdoaWxlIHRydWU7IGRvCgkJaWYgWyAkaSA9IDAgXTsgdGhlbgoJCQlicmVhawoJCWZpCgkJaT0kKCggaSAtIDEgKSkKCWRvbmUgfCB0cnVlCn0KIApzZWNvbmRfcGlwZWxpbmVfZWxlbWVudCgpIHsKCXRydWUgfCB3aGlsZSB0cnVlOyBkbwoJCWlmIFsgJGkgPSAwIF07IHRoZW4KCQkJYnJlYWsKCQlmaQoJCWk9JCgoIGkgLSAxICkpCglkb25lIHwgdHJ1ZQp9CiAKaT0xMAplY2hvICJbbm9fcGlwZWxpbmVdIHN0YXJ0OiAkaSIKbm9fcGlwZWxpbmUKZWNobyAiW25vX3BpcGVsaW5lXSBlbmQ6ICRpIgplY2hvCiAKaT0xMAplY2hvICJbZmlyc3RfcGlwZWxpbmVfZWxlbWVudF0gc3RhcnQ6ICRpIgpmaXJzdF9waXBlbGluZV9lbGVtZW50CmVjaG8gIltmaXJzdF9waXBlbGluZV9lbGVtZW50XSBlbmQ6ICRpIgplY2hvCiAKaT0xMAplY2hvICJbc2Vjb25kX3BpcGVsaW5lX2VsZW1lbnRdIHN0YXJ0OiAkaSIKc2Vjb25kX3BpcGVsaW5lX2VsZW1lbnQKZWNobyAiW3NlY29uZF9waXBlbGluZV9lbGVtZW50XSBlbmQ6ICRpIgplY2hv