title: How can I make this match a directory given
body: <pre><code>currDir = ""
  # 
  # regex is from stack overflow question:
  dirRegex = Regexp.new '^(?!.*[\\/]\.{2}[\\/])(?!\.{2}[\\/])[-\w.\\/]+$'
  if ARGV.length == 1 &amp;&amp; $1.to_s.match dirRegex
    currDir = $1
    puts $1
    puts "#{currDir}"
    puts ARGV.length
  else
    currDir = "./"
    puts $1
    puts "#{currDir}"
    puts ARGV.length
  end
  </code></pre>
  
  <p>When I try to have the above code match a directory such as home or ~/test/ it gives me an error.</p>
  
  <pre><code>./script.rb /home/local/NKU/dixonc3/test
  ./script.rb:9: syntax error, unexpected tIDENTIFIER, expecting keyword_then or ';' or '\n'
  ./script.rb:14: syntax error, unexpected keyword_else, expecting $end
  </code></pre>