I have following scripts
#!/bin/bash
set -o xtrace
gluster_volume="a.example.com:/data/brick1/gv0 b.example.com:/data/brick1/gv0"
gluster volume create gv0 replica 2 ${gluster_volume} force
While executing second line this script throwing error related to gluster_volume that its unable read complete line and just considering a.example.com:/data/brick1/gv0 b.example.com
(so look like gluster command not able parse it).
Then I run this script with trace and found that command is like
gluster volume create gv0 replica 2 'a.example.com:/data/brick1/gv0 b.example.com:/data/brick1/gv0' force
so script is adding single quotes which are creating problem. I was under the impression that it's due to set -o xtrace
the single quotes are not part of the value, just part of the displayed command line. But its not true. if i run above command on command prompt it gives same error and on removing quotes it works.
How i can change my script so it don't add quotes? (I tried to remove quote with sed but not working, something happening at run time).
I need gluster_volume
with dynamic values.
Update1:
workers=`echo "${WORKER_HOST_IP}"|sed "s/,$//"`
IFS=','
for worker in ${workers}; do
IFS='-' read -r -a array <<< "$worker"
gluster_volume+=${array[0]}':/data/brick1/gv0 '
done