Skip to content

Commit 8e728e4

Browse files
butler54claude
andauthored
fix: handle empty arrays with set -u in pattern.sh (#91)
On macOS with podman machine, PKI_HOST_MOUNT_ARGS and EXTRA_ARGS_ARRAY can be empty arrays. When using set -u (nounset), bash throws "unbound variable" errors when expanding empty arrays with [@]. Use conditional expansion "${array[@]+"${array[@]}"}" which expands to nothing if the array is empty, avoiding the unbound variable error. This fixes: ./pattern.sh: line 93: PKI_HOST_MOUNT_ARGS[@]: unbound variable Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 5fb705e commit 8e728e4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

pattern.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ podman run -it --rm --pull=newer \
114114
-e TOKEN_SECRET \
115115
-e UUID_FILE \
116116
-e VALUES_SECRET \
117-
"${PKI_HOST_MOUNT_ARGS[@]}" \
117+
"${PKI_HOST_MOUNT_ARGS[@]+"${PKI_HOST_MOUNT_ARGS[@]}"}" \
118118
-v "$(pwd -P)":"$(pwd -P)" \
119119
-v "${HOME}":"${HOME}" \
120120
-v "${HOME}":/pattern-home \
121121
"${PODMAN_ARGS[@]}" \
122-
"${EXTRA_ARGS_ARRAY[@]}" \
122+
"${EXTRA_ARGS_ARRAY[@]+"${EXTRA_ARGS_ARRAY[@]}"}" \
123123
-w "$(pwd -P)" \
124124
"$PATTERN_UTILITY_CONTAINER" \
125125
"$@"

0 commit comments

Comments
 (0)