Skip to content

Commit 7b6fb48

Browse files
committed
fix(strace): fix the test for an associative array
The original test seems to try to check whether the array `syscalls` is non-empty, but this does not work for associative arrays. The expansion ${array_name} references ${array_name[0]}, but ${array_name[0]} does not necessarily exist even when the array is non-empty when the array is an associative array or a sparse array. We can explicitly check the number of elements.
1 parent b1d163e commit 7b6fb48

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

completions/strace

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ _strace()
4242
$syscall =~ ^__NR_(.+) ]] &&
4343
syscalls[${BASH_REMATCH[1]}]=1
4444
done 2>/dev/null </usr/include/asm/unistd.h
45-
if [[ ! $syscalls ]]; then
45+
if ((${#syscalls[@]} == 0)); then
4646
local unistd arch=$(command uname -m)
4747
if [[ $arch == *86 ]]; then
4848
unistd=/usr/include/asm/unistd_32.h

0 commit comments

Comments
 (0)