Skip to content

Commit

Permalink
fix(strace): fix the test for an associative array
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akinomyoga committed Apr 8, 2023
1 parent a02a7bc commit 60e9049
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion completions/strace
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ _strace()
$syscall =~ ^__NR_(.+) ]] &&
syscalls[${BASH_REMATCH[1]}]=1
done 2>/dev/null </usr/include/asm/unistd.h
if [[ ! $syscalls ]]; then
if ((${#syscalls[@]} == 0)); then
local unistd arch=$(command uname -m)
if [[ $arch == *86 ]]; then
unistd=/usr/include/asm/unistd_32.h
Expand Down

0 comments on commit 60e9049

Please sign in to comment.