I am reading in a file inside my bash script where each line consists of multiple columns like this:
ANSIBLE 'first run' '--diff --extra-vars "client=yes fast=no"'
As you can see, the line consists of three columns, the ones with whitespaces in apostrophes. The third column contain options for a binary to call. As I read in the file, I stored those options to a variable:
custom_options=${columns[2]}
This evaluates to
custom_options='--diff --extra-vars "client=yes fast=no"'
Now I want to execute my binary with those options:
ansible-playbook $custom_options site.yml
However this fails, because on execution there were added apostrophes around the inner string:
ansible-playbook --diff --extra-vars '"client=yes fast=no"' site.yml
Does anybody know how to substitute the variable string as-is?
Here is a short script to quickly reproduce the behavior:
#!/bin/bash
set -x
touch "as is"
command='-name "as is"'
find . $command -type f
"client=yes fast=no"
is one argument, starting and ending with double quotes. – Gilles 'SO- stop being evil' Mar 03 '16 at 23:38