param_expand_assign.tests 1021 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # First try some invalid patterns. Do in subshell due to parsing error.
  2. # (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages)
  3. "$THIS_SH" -c 'echo ${=}' SHELL
  4. "$THIS_SH" -c 'echo ${:=}' SHELL
  5. # now some funky ones
  6. "$THIS_SH" -c 'echo ${#=}' SHELL
  7. "$THIS_SH" -c 'echo ${#:=}' SHELL
  8. # should error out
  9. "$THIS_SH" -c 'set --; echo _${1=}' SHELL
  10. "$THIS_SH" -c 'set --; echo _${1:=}' SHELL
  11. "$THIS_SH" -c 'set --; echo _${1=word}' SHELL
  12. "$THIS_SH" -c 'set --; echo _${1:=word}' SHELL
  13. # should not error
  14. "$THIS_SH" -c 'set aa; echo _${1=}' SHELL
  15. "$THIS_SH" -c 'set aa; echo _${1:=}' SHELL
  16. "$THIS_SH" -c 'set aa; echo _${1=word}' SHELL
  17. "$THIS_SH" -c 'set aa; echo _${1:=word}' SHELL
  18. # should work fine
  19. unset f; echo _$f
  20. unset f; echo _${f=}
  21. unset f; echo _${f:=}
  22. unset f; echo _${f=word}
  23. unset f; echo _${f:=word}
  24. f=; echo _$f
  25. f=; echo _${f=}
  26. f=; echo _${f:=}
  27. f=; echo _${f=word}
  28. f=; echo _${f:=word}
  29. f=fff; echo _$f
  30. f=fff; echo _${f=}
  31. f=fff; echo _${f:=}
  32. f=fff; echo _${f=word}
  33. f=fff; echo _${f:=word}