title: Segmentation fault on bash script
body: <p>i have a bash script that shows "Segment Violation" on line</p>
  
  <pre><code>sp-sc-auth "${sopUrl}" 8809 8908 &gt; /dev/null &amp;
  </code></pre>
  
  <p>but when <code>sp-sc-auth</code> is executed from terminal works fine</p>
  
  <p>I set: </p>
  
  <pre><code>set -o pipefail
  set -o errexit
  set -o xtrace
  set -o nounset
  </code></pre>
  
  <p>end script continue executing but throws that "Segment Violation" error...</p>
  
  <p>System is a debian 64 bits</p>
  
  <p>Thanks in advance
  Regars</p>
  
  <p>The ugly code:</p>
  
  <pre><code>#!/usr/bin/env bash
  # Init
  set -o pipefail
  set -o errexit
  #set -o xtrace
  set -o nounset
  
  __DIR__="$(cd "$(dirname "${0}")"; echo $(pwd))"
  __BASE__="$(basename "${0}")"
  __FILE__="${__DIR__}/${__BASE__}"
  
  ARG1="${1:-Undefined}"
  
  display_usage() {
      scriptName=$(basename $0)   
      echo -e "Uso:\n "${scriptName}" [6,7,8,9,10 o 12]"
      echo "Sin especificar el canal, búsqueda de retransmisiones"
  }
  
  parse_arenavision() {
  url="http://www.arenavision.in/agenda"
  
  if ! av=$(curl -s "${url}");then
      echo "Sin conexión"
      exit 1
  fi
  started="off"
  declare -a _list
  element=""
  
  while read line
  do
  if [[ $line =~ (([0-9][0-9]+/[0-9]+/[0-9]+.*)) ]]; then
      element=$(echo "${BASH_REMATCH[0]}" | sed -r 's#CET|AV([^6789]|1[02])##g; s#&lt;br /&gt;##g; s#//|&amp;.*;##g; s#/\s*$##g; s#INGLATERRA/PREMIER LEAGUE#PREMIER#g; s#ITALIA/SERIE A#SERIE A#g; s#ITALIA/SERIE A#SERIE A#g;' | tr -dc '[:print:]')
      if [[ "${element}" =~ (.*AV[6789]|.*AV10|.*AV12) ]]; then
      _list+=("${element}")
      fi
      started="on"
  else
      if [[ ${started} == "on" ]]; then
          break
      fi
  fi
  done &lt;&lt;&lt; "${av}"
  
  for i in "${_list[@]}"; do
      if [[ "${i}" =~ (.*BALONCESTO.*) ]]; then
          echo -e "\e[92m${i}\e[0m"
      elif [[ "${i}" =~ (.*LIGA BBVA.*) ]]; then
          echo -e "\e[37m${i}\e[0m"
      else 
          echo "${i}"
      fi
  done
  
  }
  
  case $ARG1 in
      "Undefined" )
          parse_arenavision
          exit 0
          ;;
      [6789] )
          page="${ARG1}"
          ;;
      10 )
          page="${ARG1}"
          ;;
      * )
          display_usage
          exit 1
          ;;
  esac
  
  # Delete "zombies"
  if pgrep -f "sp-sc"
  then
      kill -9 `pgrep -f "sp-sc-auth"`
  fi
  
  url="http://www.arenavision.in/arenavision$page"
  
  # Get url content and url sop
  if ! content=$(curl -s "${url}");then
      echo "Sin conexión"
  fi
  
  if [[ $content =~ (sop://([A-Za-z0-9_]+|\.)+:[0-9]+) ]]; then
      sopUrl=${BASH_REMATCH[1]}
  else
      echo "No se ha encontrado la url"
      exit 1
  fi
  
  # Connect ArenaVision 1
  children=""
  trap 'kill $children 1&gt;/dev/null 2&gt;&amp;1; exit 143' EXIT
  
  sp-sc-auth "${sopUrl}" 8809 8908 &gt; /dev/null &amp;
  children="$!"
  
  # Check if exists
  line='[                ]'
  for i in {0..15}
  do
  replace="${line/ /#}"
  line=$replace
  echo -ne "Comprobando sopcast  ${replace}" \\r
  sleep 1
  done
  echo -ne "\033[2K"
  
  if ! kill -0 "${children}" 1&gt;/dev/null 2&gt;&amp;1; then
      echo "Sin emisión"
      exit 1
  else
      echo -ne "Comprobando sopcast  [ OK ]" \\r
      echo
  fi
  
  # Open VLC player
  line='[                          ]'
  for i in {0..25}
  do
  replace="${line/ /#}"
  line=$replace
  echo -ne "Cargando reproductor ${replace}" \\r
  sleep 1
  done
  if ! kill -0 "${children}" 1&gt;/dev/null 2&gt;&amp;1; then
      echo "Fallo en recepción"
      exit 1
  else
      vlc http://localhost:8908/tv.asf 1&gt;/dev/null 2&gt;&amp;1
      echo -ne "\033[2K"
  fi
  
  exit 0
  </code></pre>