I tried to write a very simple synchronizing script that uses rsync with some params. I wanted these params to be stored in a variable in my script. Here is a minimal example:
$tree
.
├── a
│ └── aaa_p=1_k=1
│ └── x.txt
├── b
│ └── aaa_p=1_k=1
│ └── x.txt
└── script.sh
$cat script.sh
#!/bin/bash
PARAMS="--exclude '*p=*'"
rsync -av ${PARAMS} ./a/* ./b/
But when I run script.sh, it synchronizes x.txt, although x.txt it resides in a path containing p= that should be excluded. At the same time, when I run from command line:
rsync -av --exclude '*p=*' ./a/* ./b/
then the exclude is respected, and synchronization does not happen.
What do I do badly in the script, so the exclude switch is not taken into account? Is it variable substitution in Bash?