title: Calling commands in bash script with parameters which have embedded spaces (eg filenames)
body: <p>I am trying to write a bash script which does some processing on music files.  Here is the script so far:</p>
  
  <pre><code>#!/bin/bash
  
  SAVEIFS=$IFS
  IFS=printf"\n\0"
  
  find `pwd` -iname "*.mp3" -o -iname "*.flac" | while read f
  do
      echo "$f"
      $arr=($(f))
      exiftool "${arr[@]}"
  done
  
  IFS=$SAVEIFS
  </code></pre>
  
  <p>This fails with:</p>
  
  <pre><code>[johnd:/tmp/tunes] 2 $ ./test.sh 
  ./test.sh: line 9: syntax error near unexpected token `$(f)'
  ./test.sh: line 9: `    $arr=($(f))'
  [johnd:/tmp/tunes] 2 $ 
  </code></pre>
  
  <p>I have tried many different incantations, none of which have worked.  The bottom line is I'm trying to call a command <code>exiftool</code>, and one of the parameters of that command is a filename which may contain spaces.  Above I'm trying to assign the filename <code>$f</code> to an array and pass that array to <code>exiftool</code>, but I'm having trouble with the construction of the array.</p>
  
  <p>Immediate question is, how do I construct this array?  But the deeper question is how, from within a bash script, do I call an external command with parameters which may contain spaces?</p>