param_expand_indicate_error.tests 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # do all of these in subshells since it's supposed to error out
  2. # first try some invalid patterns
  3. #"$THIS_SH" -c 'echo ${?}' -- this is valid as it's the same as $?
  4. "$THIS_SH" -c 'echo ${:?}'
  5. # then some funky ones
  6. "$THIS_SH" -c 'echo ${#?}'
  7. "$THIS_SH" -c 'echo ${#:?}'
  8. # now some valid ones
  9. "$THIS_SH" -c 'set --; echo _$1'
  10. "$THIS_SH" -c 'set --; echo _${1?}'
  11. "$THIS_SH" -c 'set --; echo _${1:?}'
  12. "$THIS_SH" -c 'set --; echo _${1?message1}'
  13. "$THIS_SH" -c 'set --; echo _${1:?message1}'
  14. "$THIS_SH" -c 'set -- aaaa; echo _$1'
  15. "$THIS_SH" -c 'set -- aaaa; echo _${1?}'
  16. "$THIS_SH" -c 'set -- aaaa; echo _${1:?}'
  17. "$THIS_SH" -c 'set -- aaaa; echo _${1?word}'
  18. "$THIS_SH" -c 'set -- aaaa; echo _${1:?word}'
  19. "$THIS_SH" -c 'unset f; echo _$f'
  20. "$THIS_SH" -c 'unset f; echo _${f?}'
  21. "$THIS_SH" -c 'unset f; echo _${f:?}'
  22. "$THIS_SH" -c 'unset f; echo _${f?message3}'
  23. "$THIS_SH" -c 'unset f; echo _${f:?message3}'
  24. "$THIS_SH" -c 'f=; echo _$f'
  25. "$THIS_SH" -c 'f=; echo _${f?}'
  26. "$THIS_SH" -c 'f=; echo _${f:?}'
  27. "$THIS_SH" -c 'f=; echo _${f?word}'
  28. "$THIS_SH" -c 'f=; echo _${f:?message4}'
  29. "$THIS_SH" -c 'f=fff; echo _$f'
  30. "$THIS_SH" -c 'f=fff; echo _${f?}'
  31. "$THIS_SH" -c 'f=fff; echo _${f:?}'
  32. "$THIS_SH" -c 'f=fff; echo _${f?word}'
  33. "$THIS_SH" -c 'f=fff; echo _${f:?word}'