10

I know there is echo, which writes to stdout. Is it possible to redirect echo to stderr, or is there another way to write to stderr?

bluenote10
  • 23,414
  • 14
  • 122
  • 178

2 Answers2

13

It is not possible to redirect echo, but the same can be achieved by using writeLine on the stderr handle (no special imports required):

stderr.writeLine("Error: ", 42)

Documentation links:

bluenote10
  • 23,414
  • 14
  • 122
  • 178
0

Another way is to call writeLine. It is listed among the system Exports. The docs for echo suggest also calling flushFile as below.

writeLine(stderr, "my err")
flushFile(stderr)

This was tested with Nim 1.4.2.

Asclepius
  • 57,944
  • 17
  • 167
  • 143