var_bash1b.tests 616 B

123456789101112131415161718192021222324
  1. set -- 0123456
  2. echo "all |"$1
  3. echo "4: |"${1:4}
  4. echo "4:2 |"${1:4:2}
  5. echo "4:-1 |"${1:4:-1}
  6. echo "4:-2 |"${1:4:-2}
  7. echo "4:-3 |"${1:4:-3}
  8. echo "-4: |"${1: -4}
  9. echo "-4:2 |"${1: -4:2}
  10. echo "-4:-1 |"${1: -4:-1}
  11. echo "-4:-2 |"${1: -4:-2}
  12. echo "-4:-3 |"${1: -4:-3}
  13. echo "-4:-4 |"${1: -4:-4}
  14. i=2; echo "-4:i=2 |"${1: -4:i}
  15. i=-2; echo "-4:i=-2|"${1: -4:i}
  16. i=-3; echo "-4:i=-3|"${1: -4:i}
  17. i=-4; echo "-4:i=-4|"${1: -4:i}
  18. echo "-5: |"${1: -5}
  19. echo "-6: |"${1: -6}
  20. echo "-7: |"${1: -7}
  21. echo "-8: |"${1: -8}
  22. echo "-9: |"${1: -9}
  23. echo "-9:-99 |"${1: -9:-99}
  24. echo Ok:$?