title: Remove last argument from argument list of shell script (bash)
body: <p>This question concerns a bash script that is run in automator osx. I am using automator actions to get and filter a bunch of file references from the finder. Then I append to that list the name of the parent folder, also via an automator action. Automator then feeds these arguments to an action called "run shell script". I am not sure exactly how automator invokes the script but the argument list looks like this when echoed with: <code>echo "$@"</code></p>
  
  <blockquote>
    <p>/Volumes/G-Raid/Online/WAV_TEST/Testbok 50/01/01000 43-001.wav /Volumes/G-Raid/Online/WAV_TEST/Testbok 50/02/02000 43-002.wav /Volumes/G-Raid/Online/WAV_TEST/Testbok 50/03/03000 43-003.wav /Volumes/G-Raid/Online/WAV_TEST/Testbok 50</p>
  </blockquote>
  
  <p>In this case path to 3 files and a folder.</p>
  
  <p>In the shell script I launch an application called ripcheckc* with the args passed from automator minus the last argument(the folder) in the list.</p>
  
  <p>I use this to remove the last argument:</p>
  
  <pre><code>_args=( "$@" )
  unset _args[${#_args[@]}-1]
  </code></pre>
  
  <p>And this is <code>echo $_args</code>:</p>
  
  <blockquote>
    <p>/Volumes/G-Raid/Online/WAV_TEST/Testbok 50/01/01000 43-001.wav /Volumes/G-Raid/Online/WAV_TEST/Testbok 50/02/02000 43-002.wav /Volumes/G-Raid/Online/WAV_TEST/Testbok 50/03/03000 43-003.wav</p>
  </blockquote>
  
  <p>Same as before but without the folder.</p>
  
  <p>Now, if I run ripcheckc with <code>"$@"</code> as argument it works (but fails later on because of that last path in the argument list) If I use <code>${_args[@]}</code> the application will just abort silently. When I echo <code>$@</code> and <code>_args</code> the output looks identical except for the last argument.</p>
  
  <p>My question is - what is the difference between $@ and $_args that make the first valid input and the second not?</p>
  
  <p>*The application is <a href="http://sourceforge.net/projects/ripcheck/files/?source=navbar" rel="noreferrer">ripcheckc</a></p>
  
  <p>I hope my question makes sense.</p>
  
  <p>EDIT: Solved.</p>