 # Using it looks like this:
 #
 #     coffee> console.log "#{num} bottles of beer" for num in [99..1]
+
+# Start by opening up `stdin` and `stdout`.
+stdin = process.openStdin()
+stdout = process.stdout
 
 # Require the **coffee-script** module to get access to the compiler.
 CoffeeScript = require './coffee-script'


# Config
REPL_PROMPT = 'coffee> '
REPL_PROMPT_CONTINUATION = '......> '
enableColours = no
unless process.platform is 'win32'
  enableColours = not process.env.NODE_DISABLE_COLORS

# Start by opening up `stdin` and `stdout`.
stdin = process.openStdin()
stdout = process.stdout

# Log an error.
error = (err) ->
  stdout.write (err.stack or err.toString()) + '\n'

# The current backlog of multi-line code.
backlog = ''

# The main REPL function. **run** is called every time a line of code is entered.
# Attempt to evaluate the command. If there's an exception, print it out instead
# of exiting.
run = (buffer) ->
  if !buffer.toString().trim() and !backlog
    repl.prompt()
    return

    }
    if returnValue is undefined
      global._ = _
    repl.output.write "#{inspect returnValue, no, 2, enableColours}\n"
  catch err
    error err
  repl.prompt()

repl.setPrompt REPL_PROMPT
repl.prompt()

## Autocompletion

