param_expand_len1.tests 655 B

12345678910111213141516171819202122232425262728293031
  1. # ${#c} for any single char c means "length of $c", including all special vars
  2. false
  3. echo One:${#?}
  4. (exit 10)
  5. echo Two:${#?}
  6. (exit 100)
  7. echo Three:${#?}
  8. echo
  9. echo One:${##}
  10. set -- 1 2 3 4 5 6 7 8 9 0
  11. echo Two:${##}
  12. set -- 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 \
  13. 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 \
  14. 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 \
  15. 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
  16. echo Three:${##}
  17. echo
  18. v=$$
  19. test "${#v}" = "${#$}"
  20. echo 'Ok ${#$}:' $?
  21. echo
  22. sleep 0 &
  23. v=$!
  24. test "${#v}" = "${#!}"
  25. echo 'Ok ${#!}:' $?
  26. # TODO: ${#-} ${#_}