title: Shell: tar exit code 126
body: <p>So I have this script here called <code>updaterct2.sh</code></p>
  
  <pre><code>#!/bin/bash
  FILE="./newopenrct2.tar.gz"
  $(wget $1 -O $FILE)
  $(tar xvzf $FILE)
  echo $?
  </code></pre>
  
  <p>and the only file inside <code>./newopenrct2.tar.gz</code> is a folder titled <code>OpenRCT2</code> which has all the contents. Running this script produces</p>
  
  <pre><code>./updaterct2.sh: line 4: OpenRCT2/: Is a directory
  126
  </code></pre>
  
  <p>even though it properly extracts the files...</p>
  
  <p>As a test I tried modifying <code>updaterct2.sh</code> to create the directory</p>
  
  <pre><code>#!/bin/bash
  FILE="./newopenrct2.tar.gz"
  DIR="./OpenRCT2"
  $(wget $1 -O $FILE)
  $(tar xvzf $FILE -C $DIR)
  echo $?
  </code></pre>
  
  <p>But it still produces the same result.</p>
  
  <p>Running the commands in terminal</p>
  
  <pre><code>wget http://cdn.limetric.com/games/openrct2/0.2.0/develop/2e36253/9/OpenRCT2-0.2.0-develop-2e36253-linux-x86_64.tar.gz -O ./newopenrct2.tar.gz
  tar xvzf ./newopenrct2.tar.gz
  </code></pre>
  
  <p>works without any errors and outputs</p>
  
  <pre><code>./newopenrct2.tar.g 100%[===================&gt;]  33.16M  9.96MB/s    in 3.7s
  ...
  OpenRCT2/
  OpenRCT2/doc/
  OpenRCT2/doc/changelog.txt
  OpenRCT2/doc/licence.txt
  OpenRCT2/doc/readme.txt
  ...
  </code></pre>
  
  <p>I don't think the permissions should be a problem, they are as follows</p>
  
  <pre><code>-rw-rw-r--   newopenrct2.tar.gz
  -rwxrwxr-x   updaterct2.sh
  </code></pre>
  
  <p>What exactly is going wrong in the bash script? Why is it giving a non-zero exit code?</p>