unset.tests 609 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # check invalid options are rejected
  2. # bash: in posix mode, aborts if non-interactive; using subshell to avoid that
  3. (unset -)
  4. echo $?
  5. (unset -m a b c)
  6. echo $?
  7. # check funky usage
  8. unset
  9. echo $?
  10. # check normal usage
  11. echo ___
  12. f=f g=g
  13. echo $? $f $g
  14. unset f
  15. echo $? $f $g
  16. unset g
  17. echo $? $f $g
  18. echo ___
  19. f=f g=g
  20. echo $? $f $g
  21. unset f g
  22. echo $? $f $g
  23. f=f g=g
  24. echo $? $f $g
  25. unset -v f g
  26. echo $? $f $g
  27. # check read only vars
  28. echo ___
  29. f=f g=g
  30. VAR_RO=1
  31. readonly VAR_RO
  32. (unset VAR_RO)
  33. echo $? $f $g
  34. # not testing "do variables survive error halfway through unset" since unset aborts
  35. # unset f VAR_RO g
  36. #echo $? $f $g