I did notice that some authors puts additional parentheses surrounding a command substitution. Consider the following snippet:

$ var1=$(uname -r)
$ echo $var1

Is there any difference if I write:

$ var1=($(uname -r))
$ echo $var1

To give you more context, I've seen this done here , When he writes:

COMPREPLY=($(compgen -f -X "$xpat" -- "${word}"))

1 Answer 1


The significance of the extra parentheses is that they initialise arrays in Bash. This doesn’t make much difference when processing the output of uname -r, which consists of a single word, but for COMPREPLY it’s important.

You can see this for yourself:

var1=($(uname -a))
echo $var1
echo ${var1[@]}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .