arith-for.testsx 863 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. fx()
  2. {
  3. i=0
  4. for (( ; i < 3; i++ ))
  5. do
  6. echo $i
  7. done
  8. for (( i=0; ; i++ ))
  9. do
  10. if (( i >= 3 )); then
  11. break;
  12. fi
  13. echo $i
  14. done
  15. for (( i=0; i<3; ))
  16. do
  17. echo $i
  18. (( i++ ))
  19. done
  20. i=0
  21. for (( ; ; ))
  22. do
  23. if (( i > 2 )); then
  24. break;
  25. fi
  26. echo $i;
  27. (( i++ ))
  28. done
  29. i=0
  30. for ((;;))
  31. do
  32. if (( i > 2 )); then
  33. break;
  34. fi
  35. echo $i;
  36. (( i++ ))
  37. done
  38. }
  39. for (( i=0; "i < 3" ; i++ ))
  40. do
  41. echo $i
  42. done
  43. i=0
  44. for (( ; "i < 3"; i++ ))
  45. do
  46. echo $i
  47. done
  48. for (( i=0; ; i++ ))
  49. do
  50. if (( i >= 3 )); then
  51. break;
  52. fi
  53. echo $i
  54. done
  55. for ((i = 0; ;i++ ))
  56. do
  57. echo $i
  58. if (( i < 3 )); then
  59. (( i++ ))
  60. continue;
  61. fi
  62. break
  63. done
  64. type fx
  65. fx
  66. # errors
  67. for (( i=0; "i < 3" ))
  68. do
  69. echo $i
  70. done
  71. echo $?
  72. for (( i=0; i < 3; i++; 7 ))
  73. do
  74. echo $i
  75. done
  76. echo $?
  77. # one-liners added in post-bash-2.04
  78. for ((i=0; i < 20; i++)) do : ; done
  79. echo $i
  80. for ((i=0; i < 20; i++)) { : ; }
  81. echo $i