unset.tests 618 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. (
  2. # check invalid options are rejected
  3. # bash: in posix mode, aborts if non-interactive
  4. unset -
  5. echo $?
  6. unset -m a b c
  7. echo $?
  8. # check funky usage
  9. unset
  10. echo $?
  11. # check normal usage
  12. echo ___
  13. f=f g=g
  14. echo $? $f $g
  15. unset f
  16. echo $? $f $g
  17. unset g
  18. echo $? $f $g
  19. echo ___
  20. f=f g=g
  21. echo $? $f $g
  22. unset f g
  23. echo $? $f $g
  24. f=f g=g
  25. echo $? $f $g
  26. unset -v f g
  27. echo $? $f $g
  28. # check read only vars
  29. echo ___
  30. f=f g=g
  31. VAR_RO=1
  32. readonly VAR_RO
  33. unset VAR_RO
  34. echo $? $f $g
  35. unset f VAR_RO g
  36. echo $? $f $g
  37. ) 2>&1 \
  38. | sed -e 's/ unrecognized option: / invalid option -- /' \
  39. -e 's/ illegal option -- / invalid option -- /' \