Repository navigation
shell: allow declared empty arrays under nounset - #783
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ee191f6b0b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| switch subscriptLit(pe.Index) { | ||
| case "@", "*": | ||
| return true |
There was a problem hiding this comment.
Preserve nounset failure for
${#arr[@]} on unset arrays
nounsetAllowsDeclaredEmptyArray now returns true for any [@]/[*] subscript on an unset declared array, which also suppresses the nounset check for length expansion. That changes set -u; declare -a arr; echo ${#arr[@]} from an unbound-variable error (bash behavior, and what the previous code path produced) to 0, so scripts that rely on nounset to catch unset-array length probes will silently continue. Please restrict this exemption to value/key expansions and keep ${#...[@]}/${#...[*]} as nounset errors.
Useful? React with 👍 / 👎.
Summary
Testing