title: Game can't detect Winning
body: <p>I am trying to make a little game. I tried to make the diagonal winning line, but it did not work. If I tried the normal winning line, it worked, but, only in the first 3 fields. I made a check_winner() function, where I detect all winning fields. I do not know, why it is not detecting the winning fields.</p>
  <p>This is my Code:</p>
  <pre><code>#!/usr/bin/bash
  
  player_1=&quot;X&quot;
  player_2=&quot;O&quot;
  
  turn=1
  
  game_on=true
  
  moves=( - - - - - - - - - )
  
  welcome_message() {
    clear
    echo &quot;========================&quot;
    echo &quot;=== LETS PLAY A GAME ===&quot;
    echo &quot;========================&quot;
    sleep 3
  }
  print_board () {
    clear
    echo &quot; ${moves[0]} | ${moves[1]} | ${moves[2]} &quot;
    echo &quot;-----------&quot;
    echo &quot; ${moves[3]} | ${moves[4]} | ${moves[5]} &quot;
    echo &quot;-----------&quot;
    echo &quot; ${moves[6]} | ${moves[7]} | ${moves[8]} &quot;
    echo &quot;=============&quot;
  }
  
  player_pick(){
    if [ $(($turn % 2)) == 0 ]
    then
      echo &quot;Player 1 pick a square: &quot;
      play=$player_2
    else
  
      play=$player_1
      echo &quot;Player 2 pick a sqaure: &quot;
    fi
  
    read square
  
    space=${moves[(square -1)]} 
    
    
      
    if [[ ${moves[(square-1)]} == &quot;-&quot; ]] &amp;&amp; [[ $square = [0-9] ]] || [[ $space = [0-9]  ]]
    then 
      moves[(square -1)]=$play
      ((turn+=1))
    else
    
      player_pick
      echo &quot;Not a valid square.&quot;
    fi
    space=${moves[(square-1)]} 
  }
  
  check_match() {
    if  [[ ${moves[0]} == ${moves[1]} ]]&amp;&amp; 
        [[ ${moves[1]} == ${moves[2]} ]]; then
      game_on=false
    fi
    if [ $game_on == false ]; then
      if [ ${moves[$1]} == 'x' ];then
        echo &quot;Player one wins!&quot;
        return 
      else
        echo &quot;player two wins!&quot;
        return 
      fi
    fi
  }
  
  check_winner(){
    if [ $game_on == false ]; then return; fi
    check_match 0 1 2
    if [ $game_on == false ]; then return; fi
    check_match 3 4 5
    if [ $game_on == false ]; then return; fi
    check_match 6 7 8
    if [ $game_on == false ]; then return; fi
    check_match 0 4 8
    if [ $game_on == false ]; then return; fi
    check_match 2 4 6
    if [ $game_on == false ]; then return; fi
    check_match 0 3 6
    if [ $game_on == false ]; then return; fi
    check_match 1 4 7
    if [ $game_on == false ]; then return; fi
    check_match 2 5 8
    if [ $game_on == false ]; then return; fi
    
    if [ $turn -gt 9 ]; then 
      $game_on=false
      echo &quot;Its a draw!&quot;
    fi
  }
  
  
  welcome_message
  print_board
  while $game_on
  do
    player_pick
    print_board
    check_winner
  done
  </code></pre>