title: bash test cmd fails with too many args
body: <p>In Puppet provisioning, I do have problems which cause puppet run in every turn. It's masterless configuration using perodic cron job execution.</p>
  
  <pre><code> exec { 'postgresql::server::database::action1':
          command =&gt; "sudo -u postgres psql -d ${db_name} -a -f /opt/folderx/v2/createdb.sql",
          path    =&gt; '/usr/pgsql-9.5/bin:/usr/bin:/bin',
          user    =&gt; 'root',
          onlyif  =&gt; "test $(sudo -u postgres psql -d ${db_name} -c 'SELECT version();' ; echo $?) -ne 0",
      }
  </code></pre>
  
  <p>Question which is correct syntax to onlyif testing ? In bash shell I will get:</p>
  
  <blockquote>
    <p>bash: test: too many arguments</p>
  </blockquote>
  
  <p>Basically I need to test does some tables and functions exist in given $dbame</p>