Fastq-dump script download X spots or all
You don't need to copy your arguments into variables, you can just use $1 directly. Anyway, this should be enough:

#!/bin/bash
# usage : bash dump_qc.sh &lt;run id&gt; &lt;number of reads&gt;

if [ -z $1 ]; then
  echo "ERROR: at least one argument need to be given!" &gt;&amp;2
  exit 1
fi

if [ ! -z $2 ]; then
    x="-X '$2'"
fi

fastq-dump --split-3 "$x" "$1"