title: Preventing Airflow BashOperator tasks from throwing "AirflowException: Bash command failed"
body: <p>I have an Airflow task that runs <code>youtube-dl</code> and works fine. I'm running this with a BashOperator:</p>
  
  <pre><code>YOUTUBE_DL_CMD = (
      '/usr/local/bin/youtube-dl -w -i '
      '--max-downloads {{ params.max_downloads }} '
      '--write-info-json "{{ params.playlist_url }}" '
      '-o "{{ params.output }}"'
  )
  </code></pre>
  
  <p>However, when it's done it triggers an error due to "bad exit code". And hence marks my DAG run as failed.</p>
  
  <p>This is being cased by the way that the tool exits after being called. Here is some output about the error that I pulled from the airflow log. Note that <code>--max-download limit reached, aborting</code> is output from <code>youtube-dl</code> when it exits successfully. </p>
  
  <pre><code>{{bash_operator.py:128}} INFO - --max-download limit reached, aborting.
  {{bash_operator.py:132}} INFO - Command exited with return code 101
  {{taskinstance.py:1047}} ERROR - Bash command failed
  Traceback (most recent call last):
    File "/usr/local/lib/python3.7/site-packages/airflow/models/taskinstance.py", line 922, in _run_raw_task
      result = task_copy.execute(context=context)
    File "/usr/local/lib/python3.7/site-packages/airflow/operators/bash_operator.py", line 136, in execute
      raise AirflowException("Bash command failed")
  airflow.exceptions.AirflowException: Bash command failed
  </code></pre>
  
  <p>Is there a way I can prevent this error from being raised in Airflow?</p>