Skip to main content
2 of 4
fix the command used in zsh to be compatible with bash

variable assignment doesn't create one same object at least for grep

The problem is as follows:

$ FILES=(foo/**/*.suffix bar/**/*.suffix2)
$ grep baz "${FILES[@]}" # works
# I use this to create one local var with local in one function
$ SUBFILES="${FILES[@]}"
$ grep baz "${SUBFILES[@]}" # doesn't work

I used od to check them but they are same at least both contain "\n" (I didn't check character by character. But at a glance they are same).

Why does the variable assignment not create one object still work for grep?