arith2.sub 948 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # ++ and -- are not inc/dec operators on non-variables, they are + + and - - sequences
  2. ( echo $(( --7 )) )
  3. ( echo $(( ++7 )) )
  4. ( echo $(( -- 7 )) )
  5. ( echo $(( ++ 7 )) )
  6. #ash# ((++array[0] ))
  7. #ash# echo 1 $array
  8. #ash# (( ++ array[0] ))
  9. #ash# echo 2 $array
  10. #ash# (( ++a ))
  11. #ash# echo 1 $a
  12. #ash# (( ++ a ))
  13. #ash# echo 2 $a
  14. #ash# (( --a ))
  15. #ash# echo 1 $a
  16. #ash# (( -- a ))
  17. #ash# echo 0 $a
  18. a=0
  19. echo 5 $(( 4 + ++a ))
  20. echo 1 $a
  21. # this is treated as 4 + ++a
  22. echo 6 $(( 4+++a ))
  23. echo 2 $a
  24. a=2
  25. # this is treated as 4 - --a
  26. echo 3 $(( 4---a ))
  27. echo 1 $a
  28. a=1
  29. echo 4 $(( 4 - -- a ))
  30. echo 0 $a
  31. #ash# (( -- ))
  32. # -- is not a dec operator on non-variable, it is the - - sequence
  33. echo $(( ---7 ))
  34. ( echo $(( -- - 7 )) )
  35. #ash# (( ++ ))
  36. # ++ is not a inc operator on non-variable, it is the + + sequence
  37. echo $(( ++7 ))
  38. ( echo $(( ++ + 7 )) )
  39. echo -7 $(( ++-7 ))
  40. echo -7 $(( ++ - 7 ))
  41. echo 7 $(( +--7 ))
  42. echo 7 $(( -- + 7 ))