title: Shell expansion within a function
body: <p>Im attempting to create a function that when called it will create as many files as the value of a parameter given. For instance, if I call it :</p>
  
  <pre><code>ejercicio_VI file 4
  </code></pre>
  
  <p>It will create file1 and file2 and file3 and so on...</p>
  
  <p>This obviously works manually but it seems it does not work correctly within a function.</p>
  
  <p>Why is my function not expanding the filenames correctly?</p>
  
  <pre><code>ejercicio_VI() {
      if [[ $# -ne 2 ]]
      then
          echo "Esta funcion solo acepta dos parametros"
          return 255;
      fi
  
      if [[ ! $1 =~ ^[a-zA-Z]+$ ]]
      then
          echo "El primer parametro debe ser una string que matchee con esta expresion regular : ^[a-zA-Z]+$"
          echo "Asi no creamos archivos basura :P "
          return 255;
      fi
      if [[ ! $2 =~ ^[1-9]([1-9])?+$ ]]
      then
          echo "El segundo parametro debe ser un numero"
          return 255;
      fi
  
      touch "$1"{1.."$2"}
  
  
  }
  </code></pre>