fork download
  1. #!/bin/bash
  2.  
  3. no_pipeline() {
  4. while true; do
  5. if [ $i = 0 ]; then
  6. break
  7. fi
  8. i=$(( i - 1 ))
  9. done
  10. }
  11.  
  12. first_pipeline_element() {
  13. while true; do
  14. if [ $i = 0 ]; then
  15. break
  16. fi
  17. i=$(( i - 1 ))
  18. done | true
  19. }
  20.  
  21. second_pipeline_element() {
  22. true | while true; do
  23. if [ $i = 0 ]; then
  24. break
  25. fi
  26. i=$(( i - 1 ))
  27. done | true
  28. }
  29.  
  30. i=10
  31. echo "[no_pipeline] start: $i"
  32. no_pipeline
  33. echo "[no_pipeline] end: $i"
  34. echo
  35.  
  36. i=10
  37. echo "[first_pipeline_element] start: $i"
  38. first_pipeline_element
  39. echo "[first_pipeline_element] end: $i"
  40. echo
  41.  
  42. i=10
  43. echo "[second_pipeline_element] start: $i"
  44. second_pipeline_element
  45. echo "[second_pipeline_element] end: $i"
  46. echo
Success #stdin #stdout 0.01s 5408KB
stdin
Standard input is empty
stdout
[no_pipeline] start: 10
[no_pipeline] end: 0

[first_pipeline_element] start: 10
[first_pipeline_element] end: 10

[second_pipeline_element] start: 10
[second_pipeline_element] end: 10