title: Add command arguments using inline if-statement in bash
body: <p>I'd like to add an argument to a command in bash only if a variable evaluates to a certain value. For example this works:</p>
  
  <pre><code>test=1
  if [ "${test}" == 1 ]; then
      ls -la -R
  else
      ls -R   
  fi
  </code></pre>
  
  <p>The problem with this approach is that I have to duplicate <code>ls -R</code> both when <code>test</code> is <code>1</code> or if it's something else. I'd prefer if I could write this in one line instead such as this (pseudo code that doesn't work):</p>
  
  <pre><code>ls (if ${test} == 1 then -la) -R
  </code></pre>
  
  <p>I've tried the following but it doesn't work:</p>
  
  <pre><code>test=1
  ls `if [ $test -eq 1 ]; then -la; fi` -R
  </code></pre>
  
  <p>This gives me the following error:</p>
  
  <pre><code>./test.sh: line 3: -la: command not found
  </code></pre>