Hello world/Standard error: Difference between revisions
(Blade) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 31: | Line 31: | ||
{{trans|Python}} |
{{trans|Python}} |
||
< |
<syntaxhighlight lang="11l">:stderr.write("Goodbye, World!\n")</syntaxhighlight> |
||
=={{header|4DOS Batch}}== |
=={{header|4DOS Batch}}== |
||
<lang |
<syntaxhighlight lang="4dos">echoerr Goodbye, World!</syntaxhighlight> |
||
=={{header|AArch64 Assembly}}== |
=={{header|AArch64 Assembly}}== |
||
< |
<syntaxhighlight lang="arm_assembly">.equ STDERR, 2 |
||
.equ SVC_WRITE, 64 |
.equ SVC_WRITE, 64 |
||
.equ SVC_EXIT, 93 |
.equ SVC_EXIT, 93 |
||
Line 57: | Line 57: | ||
svc #0 // exit(0); |
svc #0 // exit(0); |
||
msg: .ascii "Goodbye World!\n"</ |
msg: .ascii "Goodbye World!\n"</syntaxhighlight> |
||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
< |
<syntaxhighlight lang="ada">with Ada.Text_IO; use Ada.Text_IO; |
||
procedure Goodbye_World is |
procedure Goodbye_World is |
||
begin |
begin |
||
Put_Line (Standard_Error, "Goodbye, World!"); |
Put_Line (Standard_Error, "Goodbye, World!"); |
||
end Goodbye_World;</ |
end Goodbye_World;</syntaxhighlight> |
||
=={{header|Agena}}== |
=={{header|Agena}}== |
||
< |
<syntaxhighlight lang="agena">io.write( io.stderr, "Goodbye, World!\n" )</syntaxhighlight> |
||
=={{header|Aime}}== |
=={{header|Aime}}== |
||
< |
<syntaxhighlight lang="aime">v_text("Goodbye, World!\n");</syntaxhighlight> |
||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
Line 82: | Line 82: | ||
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d] - note that printf and putf were not ported into ELLA's libraries.}} |
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d] - note that printf and putf were not ported into ELLA's libraries.}} |
||
< |
<syntaxhighlight lang="algol68">main:( |
||
put(stand error, ("Goodbye, World!", new line)) |
put(stand error, ("Goodbye, World!", new line)) |
||
)</ |
)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 91: | Line 91: | ||
=={{header|Argile}}== |
=={{header|Argile}}== |
||
< |
<syntaxhighlight lang="argile">use std |
||
eprint "Goodbye, World!"</ |
eprint "Goodbye, World!"</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="argile">use std |
||
eprintf "Goodbye, World!\n"</ |
eprintf "Goodbye, World!\n"</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="argile">use std |
||
fprintf stderr "Goodbye, World!\n"</ |
fprintf stderr "Goodbye, World!\n"</syntaxhighlight> |
||
=={{header|ARM Assembly}}== |
=={{header|ARM Assembly}}== |
||
{{works with|as|Raspberry Pi}} |
{{works with|as|Raspberry Pi}} |
||
<syntaxhighlight lang="arm assembly"> |
|||
<lang ARM Assembly> |
|||
/* ARM assembly Raspberry PI */ |
/* ARM assembly Raspberry PI */ |
||
/* program hellowordLP.s */ |
/* program hellowordLP.s */ |
||
Line 124: | Line 124: | ||
iAdrMessage: .int szMessage |
iAdrMessage: .int szMessage |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Arturo}}== |
=={{header|Arturo}}== |
||
< |
<syntaxhighlight lang="arturo">panic "Goodbye, World!"</syntaxhighlight> |
||
=={{header|ATS}}== |
=={{header|ATS}}== |
||
< |
<syntaxhighlight lang="ats">implement main0 () = fprint (stderr_ref, "Goodbye, World!\n")</syntaxhighlight> |
||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
requires [http://github.com/tinku99/ahkdll/tree/master AutoHotkey_N] |
requires [http://github.com/tinku99/ahkdll/tree/master AutoHotkey_N] |
||
implementation. |
implementation. |
||
< |
<syntaxhighlight lang="autohotkey">; c:\> autohotkey.exe stderr.ahk 2> error.txt |
||
FileAppend, Goodbye`, World!, stderr ; requires AutoHotkey_N</ |
FileAppend, Goodbye`, World!, stderr ; requires AutoHotkey_N</syntaxhighlight> |
||
Or with the current AutoHotkey_L: |
Or with the current AutoHotkey_L: |
||
{{works with|AutoHotkey_L}} |
{{works with|AutoHotkey_L}} |
||
(documentation on this behavior: http://www.autohotkey.net/~Lexikos/AutoHotkey_L/docs/commands/FileAppend.htm) |
(documentation on this behavior: http://www.autohotkey.net/~Lexikos/AutoHotkey_L/docs/commands/FileAppend.htm) |
||
< |
<syntaxhighlight lang="autohotkey">FileAppend, Goodbye`, World!, *</syntaxhighlight> |
||
=={{header|AutoIt}}== |
=={{header|AutoIt}}== |
||
< |
<syntaxhighlight lang="autoit">ConsoleWriteError("Goodbye, World!" & @CRLF)</syntaxhighlight> |
||
=={{header|Avail}}== |
=={{header|Avail}}== |
||
< |
<syntaxhighlight lang="avail">Error: "Goodbye, World!";</syntaxhighlight> |
||
=={{header|AWK}}== |
=={{header|AWK}}== |
||
Line 153: | Line 153: | ||
pipe it through a shell command: |
pipe it through a shell command: |
||
< |
<syntaxhighlight lang="awk">BEGIN { |
||
print "Goodbye, World!"| "cat 1>&2" |
print "Goodbye, World!"| "cat 1>&2" |
||
}</ |
}</syntaxhighlight> |
||
Or write to /dev/stderr: |
Or write to /dev/stderr: |
||
Line 162: | Line 162: | ||
{{works with|mawk}} |
{{works with|mawk}} |
||
{{works with|nawk}} |
{{works with|nawk}} |
||
< |
<syntaxhighlight lang="awk">BEGIN { |
||
print "Goodbye, World!" > "/dev/stderr" |
print "Goodbye, World!" > "/dev/stderr" |
||
}</ |
}</syntaxhighlight> |
||
With ''gawk'', ''mawk'' and ''nawk'': a special feature |
With ''gawk'', ''mawk'' and ''nawk'': a special feature |
||
Line 179: | Line 179: | ||
=={{header|BASIC}}== |
=={{header|BASIC}}== |
||
{{works with|QBasic}} |
{{works with|QBasic}} |
||
< |
<syntaxhighlight lang="basic"> |
||
ON ERROR GOTO ManejoErrores |
ON ERROR GOTO ManejoErrores |
||
ERROR 99 |
ERROR 99 |
||
Line 188: | Line 188: | ||
PRINT "Googbye World!" |
PRINT "Googbye World!" |
||
RESUME |
RESUME |
||
</syntaxhighlight> |
|||
</lang> |
|||
==={{header|BaCon}}=== |
==={{header|BaCon}}=== |
||
< |
<syntaxhighlight lang="freebasic">EPRINT "Goodbye, World!"</syntaxhighlight> |
||
==={{header|BASIC256}}=== |
==={{header|BASIC256}}=== |
||
<syntaxhighlight lang="basic256"> |
|||
<lang BASIC256> |
|||
onerror errortrap |
onerror errortrap |
||
throwerror 99 |
throwerror 99 |
||
Line 203: | Line 203: | ||
print "Goodbye World!" |
print "Goodbye World!" |
||
return |
return |
||
</syntaxhighlight> |
|||
</lang> |
|||
==={{header|ZX Spectrum Basic}}=== |
==={{header|ZX Spectrum Basic}}=== |
||
Line 209: | Line 209: | ||
On the ZX Spectrum, standard error is on stream 1: |
On the ZX Spectrum, standard error is on stream 1: |
||
< |
<syntaxhighlight lang="zxbasic"> |
||
10 PRINT #1;"Goodbye, World!" |
10 PRINT #1;"Goodbye, World!" |
||
20 PAUSE 50: REM allow time for the user to see the error message |
20 PAUSE 50: REM allow time for the user to see the error message |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Batch File}}== |
=={{header|Batch File}}== |
||
< |
<syntaxhighlight lang="dos">1>&2 echo Goodbye, World!</syntaxhighlight> |
||
The redirection operator <code>1>&2</code> causes all output on stream 1 (standard out) to be redirected to stream 2 (standard error). |
The redirection operator <code>1>&2</code> causes all output on stream 1 (standard out) to be redirected to stream 2 (standard error). |
||
The redirection can be moved to the end of the line, too. |
The redirection can be moved to the end of the line, too. |
||
Line 222: | Line 222: | ||
{{works with|BBC BASIC for Windows}} |
{{works with|BBC BASIC for Windows}} |
||
The program must be compiled as a console application for this to work. |
The program must be compiled as a console application for this to work. |
||
< |
<syntaxhighlight lang="bbcbasic"> STD_ERROR_HANDLE = -12 |
||
SYS "GetStdHandle", STD_ERROR_HANDLE TO @hfile%(1) |
SYS "GetStdHandle", STD_ERROR_HANDLE TO @hfile%(1) |
||
PRINT #13, "Goodbye, World!" |
PRINT #13, "Goodbye, World!" |
||
QUIT</ |
QUIT</syntaxhighlight> |
||
=={{header|Blade}}== |
=={{header|Blade}}== |
||
< |
<syntaxhighlight lang="blade">import io |
||
io.stderr.write('Goodbye, World!')</ |
io.stderr.write('Goodbye, World!')</syntaxhighlight> |
||
=={{header|C}}== |
=={{header|C}}== |
||
Unlike puts(), fputs() does not append a terminal newline. |
Unlike puts(), fputs() does not append a terminal newline. |
||
< |
<syntaxhighlight lang="c">#include <stdio.h> |
||
int main() |
int main() |
||
Line 241: | Line 241: | ||
return 0; |
return 0; |
||
}</ |
}</syntaxhighlight> |
||
=={{header|C sharp|C#}}== |
=={{header|C sharp|C#}}== |
||
< |
<syntaxhighlight lang="csharp">static class StdErr |
||
{ |
{ |
||
static void Main(string[] args) |
static void Main(string[] args) |
||
Line 250: | Line 250: | ||
Console.Error.WriteLine("Goodbye, World!"); |
Console.Error.WriteLine("Goodbye, World!"); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|C++}}== |
=={{header|C++}}== |
||
< |
<syntaxhighlight lang="cpp">#include <iostream> |
||
int main() { |
int main() { |
||
std::cerr << "Goodbye, World!\n"; |
std::cerr << "Goodbye, World!\n"; |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Clojure}}== |
=={{header|Clojure}}== |
||
< |
<syntaxhighlight lang="lisp">(binding [*out* *err*] |
||
(println "Goodbye, world!"))</ |
(println "Goodbye, world!"))</syntaxhighlight> |
||
=={{header|CLU}}== |
=={{header|CLU}}== |
||
< |
<syntaxhighlight lang="clu">start_up = proc () |
||
stream$putl(stream$error_output(), "Goodbye, World!") |
stream$putl(stream$error_output(), "Goodbye, World!") |
||
end start_up</ |
end start_up</syntaxhighlight> |
||
=={{header|CMake}}== |
=={{header|CMake}}== |
||
Most messages go to standard error. |
Most messages go to standard error. |
||
< |
<syntaxhighlight lang="cmake">message("Goodbye, World!")</syntaxhighlight> |
||
The message cannot be a keyword; <code>message("STATUS")</code> never prints "STATUS", but <code>message("" "STATUS")</code> does work. |
The message cannot be a keyword; <code>message("STATUS")</code> never prints "STATUS", but <code>message("" "STATUS")</code> does work. |
||
Line 279: | Line 279: | ||
{{works with|OpenCOBOL}} |
{{works with|OpenCOBOL}} |
||
< |
<syntaxhighlight lang="cobol"> program-id. ehello. |
||
procedure division. |
procedure division. |
||
display "Goodbye, world!" upon syserr. |
display "Goodbye, world!" upon syserr. |
||
stop run.</ |
stop run.</syntaxhighlight> |
||
=={{header|CoffeeScript}}== |
=={{header|CoffeeScript}}== |
||
{{trans|JavaScript}} |
{{trans|JavaScript}} |
||
{{works with|Node.js}} |
{{works with|Node.js}} |
||
< |
<syntaxhighlight lang="coffeescript">console.warn "Goodbye, World!"</syntaxhighlight> |
||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
< |
<syntaxhighlight lang="lisp">(format *error-output* "Goodbye, world!~%")</syntaxhighlight> |
||
=={{header|D}}== |
=={{header|D}}== |
||
< |
<syntaxhighlight lang="d">import std.stdio; |
||
void main () { |
void main () { |
||
stderr.writeln("Goodbye, World!"); |
stderr.writeln("Goodbye, World!"); |
||
}</ |
}</syntaxhighlight> |
||
===Alternative Version=== |
===Alternative Version=== |
||
{{libheader|tango}} |
{{libheader|tango}} |
||
< |
<syntaxhighlight lang="d">import tango.io.Stdout; |
||
void main () { |
void main () { |
||
Stderr("Goodbye, World!").newline; |
Stderr("Goodbye, World!").newline; |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Dart}}== |
=={{header|Dart}}== |
||
< |
<syntaxhighlight lang="dart">import 'dart:io'; |
||
void main() { |
void main() { |
||
stderr.writeln('Goodbye, World!'); |
stderr.writeln('Goodbye, World!'); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
< |
<syntaxhighlight lang="delphi">program Project1; |
||
{$APPTYPE CONSOLE} |
{$APPTYPE CONSOLE} |
||
Line 321: | Line 321: | ||
begin |
begin |
||
WriteLn(ErrOutput, 'Goodbye, World!'); |
WriteLn(ErrOutput, 'Goodbye, World!'); |
||
end.</ |
end.</syntaxhighlight> |
||
=={{header|Dylan.NET}}== |
=={{header|Dylan.NET}}== |
||
Line 332: | Line 332: | ||
{{works with|.NET|4.5}} |
{{works with|.NET|4.5}} |
||
One Line version: |
One Line version: |
||
< |
<syntaxhighlight lang="dylan.net">Console::get_Error()::WriteLine("Goodbye World!")</syntaxhighlight> |
||
Goodbye World Program: |
Goodbye World Program: |
||
<syntaxhighlight lang="dylan.net"> |
|||
<lang Dylan.NET> |
|||
//compile using the new dylan.NET v, 11.5.1.2 or later |
//compile using the new dylan.NET v, 11.5.1.2 or later |
||
//use mono to run the compiler |
//use mono to run the compiler |
||
Line 351: | Line 351: | ||
end class |
end class |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Déjà Vu}}== |
=={{header|Déjà Vu}}== |
||
< |
<syntaxhighlight lang="dejavu">!write-fragment!stderr !encode!utf-8 "Goodbye, World!\n"</syntaxhighlight> |
||
=={{header|E}}== |
=={{header|E}}== |
||
< |
<syntaxhighlight lang="e">stderr.println("Goodbye, World!")</syntaxhighlight> |
||
=={{header|Elixir}}== |
=={{header|Elixir}}== |
||
< |
<syntaxhighlight lang="elixir">IO.puts :stderr, "Goodbye, World!"</syntaxhighlight> |
||
=={{header|Emacs Lisp}}== |
=={{header|Emacs Lisp}}== |
||
Line 367: | Line 367: | ||
In batch mode, <code>message</code> actually prints to standard error: |
In batch mode, <code>message</code> actually prints to standard error: |
||
< |
<syntaxhighlight lang="lisp">(message "Goodbye, World!")</syntaxhighlight> |
||
For greater control, <code>princ</code> can be used with a special printing function: |
For greater control, <code>princ</code> can be used with a special printing function: |
||
< |
<syntaxhighlight lang="lisp">(princ "Goodbye, World!\n" 'external-debugging-output)</syntaxhighlight> |
||
=={{header|Erlang}}== |
=={{header|Erlang}}== |
||
< |
<syntaxhighlight lang="erlang">io:put_chars(standard_error, "Goodbye, World!\n").</syntaxhighlight> |
||
=={{header|Euphoria}}== |
=={{header|Euphoria}}== |
||
< |
<syntaxhighlight lang="euphoria">puts(2,"Goodbye, world!\n") -- 2 means output to 'standard error'</syntaxhighlight> |
||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |
||
< |
<syntaxhighlight lang="fsharp">eprintfn "%s" "Goodbye, World!"</syntaxhighlight> |
||
or you can use the .Net classes |
or you can use the .Net classes |
||
< |
<syntaxhighlight lang="fsharp">System.Console.Error.WriteLine("Goodbye, World!");</syntaxhighlight> |
||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
Start Factor in a terminal for this: |
Start Factor in a terminal for this: |
||
< |
<syntaxhighlight lang="factor">error-stream get [ "Goodbye, World! bbl, crashing" print flush ] with-output-stream*</syntaxhighlight> |
||
=={{header|Fantom}}== |
=={{header|Fantom}}== |
||
< |
<syntaxhighlight lang="fantom"> |
||
class Main |
class Main |
||
{ |
{ |
||
Line 398: | Line 398: | ||
} |
} |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Forth}}== |
=={{header|Forth}}== |
||
{{works with|GNU Forth}} |
{{works with|GNU Forth}} |
||
< |
<syntaxhighlight lang="forth">outfile-id |
||
stderr to outfile-id |
stderr to outfile-id |
||
." Goodbye, World!" cr |
." Goodbye, World!" cr |
||
to outfile-id</ |
to outfile-id</syntaxhighlight> |
||
=={{header|Fortran}}== |
=={{header|Fortran}}== |
||
Line 414: | Line 414: | ||
which defines the parameter ERROR_UNIT. |
which defines the parameter ERROR_UNIT. |
||
< |
<syntaxhighlight lang="fortran">program StdErr |
||
! Fortran 2003 |
! Fortran 2003 |
||
use iso_fortran_env |
use iso_fortran_env |
||
Line 422: | Line 422: | ||
write (ERROR_UNIT, *) "Goodbye, World!" |
write (ERROR_UNIT, *) "Goodbye, World!" |
||
end program StdErr</ |
end program StdErr</syntaxhighlight> |
||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |
||
< |
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64 |
||
Open Err As #1 |
Open Err As #1 |
||
Print #1, "Goodbye World!" |
Print #1, "Goodbye World!" |
||
Close #1 |
Close #1 |
||
Sleep</ |
Sleep</syntaxhighlight> |
||
=={{header|Frink}}== |
=={{header|Frink}}== |
||
< |
<syntaxhighlight lang="frink"> |
||
staticJava["java.lang.System","err"].println["Goodbye, World!"] |
staticJava["java.lang.System","err"].println["Goodbye, World!"] |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Genie}}== |
=={{header|Genie}}== |
||
< |
<syntaxhighlight lang="genie">[indent=4] |
||
/* |
/* |
||
Hello, to Standard error, in Genie |
Hello, to Standard error, in Genie |
||
Line 445: | Line 445: | ||
init |
init |
||
stderr.printf("%s\n", "Goodbye, World!")</ |
stderr.printf("%s\n", "Goodbye, World!")</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 454: | Line 454: | ||
=={{header|Go}}== |
=={{header|Go}}== |
||
Built in println now goes to stderr. |
Built in println now goes to stderr. |
||
< |
<syntaxhighlight lang="go">package main |
||
func main() { println("Goodbye, World!") }</ |
func main() { println("Goodbye, World!") }</syntaxhighlight> |
||
but the builtin print() and println() functions are not guaranteed to stay in the language. So you should probably use |
but the builtin print() and println() functions are not guaranteed to stay in the language. So you should probably use |
||
< |
<syntaxhighlight lang="go">package main |
||
import ("fmt"; "os") |
import ("fmt"; "os") |
||
func main() { fmt.Fprintln(os.Stderr, "Goodbye, World!") }</ |
func main() { fmt.Fprintln(os.Stderr, "Goodbye, World!") }</syntaxhighlight> |
||
=={{header|Groovy}}== |
=={{header|Groovy}}== |
||
< |
<syntaxhighlight lang="groovy">System.err.println("Goodbye, World!")</syntaxhighlight> |
||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
< |
<syntaxhighlight lang="haskell">import System.IO |
||
main = hPutStrLn stderr "Goodbye, World!"</ |
main = hPutStrLn stderr "Goodbye, World!"</syntaxhighlight> |
||
=={{header|Huginn}}== |
=={{header|Huginn}}== |
||
< |
<syntaxhighlight lang="huginn">#! /bin/sh |
||
exec huginn --no-argv -E "${0}" "${@}" |
exec huginn --no-argv -E "${0}" "${@}" |
||
#! huginn |
#! huginn |
||
Line 478: | Line 478: | ||
os.stderr().write( "Goodbye, World!\n" ); |
os.stderr().write( "Goodbye, World!\n" ); |
||
return ( 0 ); |
return ( 0 ); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Icon}} and {{header|Unicon}}== |
=={{header|Icon}} and {{header|Unicon}}== |
||
< |
<syntaxhighlight lang="icon">procedure main() |
||
write(&errout, "Goodbye World" ) |
write(&errout, "Goodbye World" ) |
||
end</ |
end</syntaxhighlight> |
||
=={{header|J}}== |
=={{header|J}}== |
||
< |
<syntaxhighlight lang="j">stderr =: 1!:2&4 |
||
stderr 'Goodbye, World!'</ |
stderr 'Goodbye, World!'</syntaxhighlight> |
||
=={{header|Java}}== |
=={{header|Java}}== |
||
< |
<syntaxhighlight lang="java">public class Err{ |
||
public static void main(String[] args){ |
public static void main(String[] args){ |
||
System.err.println("Goodbye, World!"); |
System.err.println("Goodbye, World!"); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|JavaScript}}== |
=={{header|JavaScript}}== |
||
{{works with|JScript}} and only with <code>cscript.exe</code> |
{{works with|JScript}} and only with <code>cscript.exe</code> |
||
< |
<syntaxhighlight lang="javascript">WScript.StdErr.WriteLine("Goodbye, World!");</syntaxhighlight> |
||
{{works with|Node.js}} |
{{works with|Node.js}} |
||
< |
<syntaxhighlight lang="javascript">console.warn("Goodbye, World!")</syntaxhighlight> |
||
{{works with|Firefox}} |
{{works with|Firefox}} |
||
< |
<syntaxhighlight lang="javascript">console.error("Goodbye, World!")//only works if console object exists</syntaxhighlight> |
||
OR |
OR |
||
< |
<syntaxhighlight lang="javascript">throw new Error("Goodbye, World!")//Should work in any browser</syntaxhighlight> |
||
=={{header|jq}}== |
=={{header|jq}}== |
||
< |
<syntaxhighlight lang="jq">jq -n —-arg s 'Goodbye, World!' '$s | stderr | empty'</syntaxhighlight> |
||
`stderr` copies its input to STDERR before passing it along the pipeline, and hence the occurrence of `empty` above. |
`stderr` copies its input to STDERR before passing it along the pipeline, and hence the occurrence of `empty` above. |
||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
< |
<syntaxhighlight lang="julia">println(STDERR, "Goodbye, World!")</syntaxhighlight> |
||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
< |
<syntaxhighlight lang="scala">fun main(args: Array<String>) { |
||
System.err.println("Goodbye, World!") |
System.err.println("Goodbye, World!") |
||
}</ |
}</syntaxhighlight> |
||
=={{header|langur}}== |
=={{header|langur}}== |
||
< |
<syntaxhighlight lang="langur">writelnErr "goodbye, people"</syntaxhighlight> |
||
=={{header|Lasso}}== |
=={{header|Lasso}}== |
||
< |
<syntaxhighlight lang="lasso">define stderr(s::string) => { |
||
file_stderr->writeBytes(#s->asBytes) |
file_stderr->writeBytes(#s->asBytes) |
||
} |
} |
||
stderr('Goodbye, World!')</ |
stderr('Goodbye, World!')</syntaxhighlight> |
||
=={{header|Lingo}}== |
=={{header|Lingo}}== |
||
*Windows: |
*Windows: |
||
{{libheader|CommandLine Xtra}} |
{{libheader|CommandLine Xtra}} |
||
< |
<syntaxhighlight lang="lingo">-- print to standard error |
||
stdErr("Goodbye, World!", TRUE) |
stdErr("Goodbye, World!", TRUE) |
||
-- print to the Windows debug console (shown in realtime e.g. in Systernal's DebugView) |
-- print to the Windows debug console (shown in realtime e.g. in Systernal's DebugView) |
||
dbgPrint("Goodbye, World!")</ |
dbgPrint("Goodbye, World!")</syntaxhighlight> |
||
*Mac OS X: |
*Mac OS X: |
||
{{libheader|Shell Xtra}} |
{{libheader|Shell Xtra}} |
||
< |
<syntaxhighlight lang="lingo">sx = xtra("Shell").new() |
||
-- print to standard error |
-- print to standard error |
||
Line 549: | Line 549: | ||
-- print to system.log (shown in realtime e.g. in Konsole.app) |
-- print to system.log (shown in realtime e.g. in Konsole.app) |
||
sx.shell_cmd("logger Goodbye, World!")</ |
sx.shell_cmd("logger Goodbye, World!")</syntaxhighlight> |
||
=={{header|LLVM}}== |
=={{header|LLVM}}== |
||
< |
<syntaxhighlight lang="llvm">; This is not strictly LLVM, as it uses the C library function "printf". |
||
; LLVM does not provide a way to print values, so the alternative would be |
; LLVM does not provide a way to print values, so the alternative would be |
||
; to just load the string into memory, and that would be boring. |
; to just load the string into memory, and that would be boring. |
||
Line 576: | Line 576: | ||
;-- exit |
;-- exit |
||
ret i32 0 |
ret i32 0 |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>Goodbye, world!</pre> |
<pre>Goodbye, world!</pre> |
||
Line 582: | Line 582: | ||
=={{header|Logtalk}}== |
=={{header|Logtalk}}== |
||
The stream alias "user_error" can be used to print to the "standard error" stream. |
The stream alias "user_error" can be used to print to the "standard error" stream. |
||
< |
<syntaxhighlight lang="logtalk"> |
||
:- object(error_message). |
:- object(error_message). |
||
Line 590: | Line 590: | ||
:- end_object. |
:- end_object. |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
< |
<syntaxhighlight lang="lua">io.stderr:write("Goodbye, World!\n")</syntaxhighlight> |
||
=={{header|m4}}== |
=={{header|m4}}== |
||
< |
<syntaxhighlight lang="m4">errprint(`Goodbye, World! |
||
')dnl</ |
')dnl</syntaxhighlight> |
||
=={{header|MANOOL}}== |
=={{header|MANOOL}}== |
||
< |
<syntaxhighlight lang="manool">{{extern "manool.org.18/std/0.3/all"} in Err.WriteLine["Goodbye, World!"]}</syntaxhighlight> |
||
=={{header|Maple}}== |
=={{header|Maple}}== |
||
<syntaxhighlight lang="maple"> |
|||
<lang Maple> |
|||
error "Goodbye World" |
error "Goodbye World" |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
||
< |
<syntaxhighlight lang="mathematica">Write[Streams["stderr"], "Goodbye, World!"]</syntaxhighlight> |
||
=={{header|MATLAB}} / {{header|Octave}}== |
=={{header|MATLAB}} / {{header|Octave}}== |
||
This prints to standard error, and continues execution |
This prints to standard error, and continues execution |
||
< |
<syntaxhighlight lang="matlab">fprintf(2,'Goodbye, World!')</syntaxhighlight> |
||
This will not stop further execution, if called from within a script or function. |
This will not stop further execution, if called from within a script or function. |
||
<lang |
<syntaxhighlight lang="matlab">error 'Goodbye, World!'</syntaxhighlight> |
||
=={{header|Mercury}}== |
=={{header|Mercury}}== |
||
<lang> |
<syntaxhighlight lang="text"> |
||
:- module hello_error. |
:- module hello_error. |
||
:- interface. |
:- interface. |
||
Line 629: | Line 629: | ||
io.stderr_stream(Stderr, !IO), |
io.stderr_stream(Stderr, !IO), |
||
io.write_string(Stderr, "Goodbye, World!\n", !IO). |
io.write_string(Stderr, "Goodbye, World!\n", !IO). |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Metafont}}== |
=={{header|Metafont}}== |
||
Metafont has no a real way to send a text to the standard output/error nor to a file. Anyway it exists the <code>errmessage</code> command which will output an error message and prompt the user for action (suspending the interpretation of the source). |
Metafont has no a real way to send a text to the standard output/error nor to a file. Anyway it exists the <code>errmessage</code> command which will output an error message and prompt the user for action (suspending the interpretation of the source). |
||
< |
<syntaxhighlight lang="metafont">errmessage "Error"; |
||
message "...going on..."; % if the user decides to go on and not to stop |
message "...going on..."; % if the user decides to go on and not to stop |
||
% the program because of the error.</ |
% the program because of the error.</syntaxhighlight> |
||
=={{header|ML/I}}== |
=={{header|ML/I}}== |
||
< |
<syntaxhighlight lang="ml/i">MCSET S4=1 |
||
MCNOTE Goodbye, World!</ |
MCNOTE Goodbye, World!</syntaxhighlight> |
||
=={{header|Modula-2}}== |
=={{header|Modula-2}}== |
||
< |
<syntaxhighlight lang="modula2">MODULE HelloErr; |
||
IMPORT StdError; |
IMPORT StdError; |
||
Line 649: | Line 649: | ||
StdError.WriteString('Goodbye, World!'); |
StdError.WriteString('Goodbye, World!'); |
||
StdError.WriteLn |
StdError.WriteLn |
||
END HelloErr.</ |
END HelloErr.</syntaxhighlight> |
||
=={{header|Modula-3}}== |
=={{header|Modula-3}}== |
||
< |
<syntaxhighlight lang="modula3">MODULE Stderr EXPORTS Main; |
||
IMPORT Wr, Stdio; |
IMPORT Wr, Stdio; |
||
Line 658: | Line 658: | ||
BEGIN |
BEGIN |
||
Wr.PutText(Stdio.stderr, "Goodbye, World!\n"); |
Wr.PutText(Stdio.stderr, "Goodbye, World!\n"); |
||
END Stderr.</ |
END Stderr.</syntaxhighlight> |
||
=={{header|N/t/roff}}== |
=={{header|N/t/roff}}== |
||
Line 664: | Line 664: | ||
The request <code>.tm</code> prints whatever after it, until and including the newline character, to the standard error. The string parsed to it need not be quoted and will never appear on standard output. |
The request <code>.tm</code> prints whatever after it, until and including the newline character, to the standard error. The string parsed to it need not be quoted and will never appear on standard output. |
||
< |
<syntaxhighlight lang="n/t/roff"> |
||
.tm Goodbye, World! |
.tm Goodbye, World! |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Neko}}== |
=={{header|Neko}}== |
||
<syntaxhighlight lang="actionscript">/** |
|||
<lang ActionScript>/** |
|||
Hello world, to standard error, in Neko |
Hello world, to standard error, in Neko |
||
Tectonics: |
Tectonics: |
||
Line 682: | Line 682: | ||
var stderr = $loader.loadprim("std@file_stderr", 0)(); |
var stderr = $loader.loadprim("std@file_stderr", 0)(); |
||
file_write(stderr, "Goodbye, World!\n", 0, 16);</ |
file_write(stderr, "Goodbye, World!\n", 0, 16);</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 692: | Line 692: | ||
=={{header|Nemerle}}== |
=={{header|Nemerle}}== |
||
< |
<syntaxhighlight lang="nemerle">System.Console.Error.WriteLine("Goodbye, World!");</syntaxhighlight> |
||
=={{header|NetRexx}}== |
=={{header|NetRexx}}== |
||
< |
<syntaxhighlight lang="netrexx">/* NetRexx */ |
||
options replace format comments java crossref savelog symbols binary |
options replace format comments java crossref savelog symbols binary |
||
System.err.println("Goodbye, World!") |
System.err.println("Goodbye, World!") |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
< |
<syntaxhighlight lang="nim">stderr.writeln "Hello World"</syntaxhighlight> |
||
=={{header|Oberon-2}}== |
=={{header|Oberon-2}}== |
||
Oxford Oberon-2 |
Oxford Oberon-2 |
||
< |
<syntaxhighlight lang="oberon2"> |
||
MODULE HelloErr; |
MODULE HelloErr; |
||
IMPORT Err; |
IMPORT Err; |
||
Line 713: | Line 713: | ||
Err.String("Goodbye, World!");Err.Ln |
Err.String("Goodbye, World!");Err.Ln |
||
END HelloErr. |
END HelloErr. |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 727: | Line 727: | ||
is an NSString object, and it also prepends a timestamp. |
is an NSString object, and it also prepends a timestamp. |
||
< |
<syntaxhighlight lang="objc">#import <Foundation/Foundation.h> |
||
int main() |
int main() |
||
Line 735: | Line 735: | ||
NSLog(@"Goodbye, World!"); |
NSLog(@"Goodbye, World!"); |
||
return 0; |
return 0; |
||
}</ |
}</syntaxhighlight> |
||
=={{header|OCaml}}== |
=={{header|OCaml}}== |
||
< |
<syntaxhighlight lang="ocaml">prerr_endline "Goodbye, World!"; (* this is how you print a string with newline to stderr *) |
||
Printf.eprintf "Goodbye, World!\n"; (* this is how you would use printf with stderr *)</ |
Printf.eprintf "Goodbye, World!\n"; (* this is how you would use printf with stderr *)</syntaxhighlight> |
||
we can also use the ''out_channel'' '''stderr''': |
we can also use the ''out_channel'' '''stderr''': |
||
< |
<syntaxhighlight lang="ocaml">output_string stderr "Goodbye, World!\n"; |
||
Printf.fprintf stderr "Goodbye, World!\n";</ |
Printf.fprintf stderr "Goodbye, World!\n";</syntaxhighlight> |
||
finally the [http://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html Unix] module also provides unbuffered write functions: |
finally the [http://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html Unix] module also provides unbuffered write functions: |
||
< |
<syntaxhighlight lang="ocaml">let msg = "Goodbye, World!\n" in |
||
ignore(Unix.write Unix.stderr msg 0 (String.length msg)) ;;</ |
ignore(Unix.write Unix.stderr msg 0 (String.length msg)) ;;</syntaxhighlight> |
||
=={{header|Octave}}== |
=={{header|Octave}}== |
||
< |
<syntaxhighlight lang="octave">fprintf(stderr, "Goodbye, World!\n");</syntaxhighlight> |
||
=={{header|Oforth}}== |
=={{header|Oforth}}== |
||
< |
<syntaxhighlight lang="oforth">System.Err "Goodbye, World!" << cr</syntaxhighlight> |
||
=={{header|Ol}}== |
=={{header|Ol}}== |
||
< |
<syntaxhighlight lang="scheme"> |
||
(print-to stderr "Goodbye, World!") |
(print-to stderr "Goodbye, World!") |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|ooRexx}}== |
=={{header|ooRexx}}== |
||
ooRexx provides a .error object that writes output to the standard error stream. |
ooRexx provides a .error object that writes output to the standard error stream. |
||
< |
<syntaxhighlight lang="oorexx">.error~lineout("Goodbye, World!")</syntaxhighlight> |
||
The .error object is a proxy that delegates to a backing stream, so this might be redirected. |
The .error object is a proxy that delegates to a backing stream, so this might be redirected. |
||
By default, this delegates to the .stderr object, which can also be used directly. |
By default, this delegates to the .stderr object, which can also be used directly. |
||
< |
<syntaxhighlight lang="oorexx">.stderr~lineout("Goodbye, World!")</syntaxhighlight> |
||
or in 'Classic REXX style' |
or in 'Classic REXX style' |
||
< |
<syntaxhighlight lang="oorexx">/* REXX --------------------------------------------------------------- |
||
* 07.07.2014 Walter Pachl |
* 07.07.2014 Walter Pachl |
||
* 12.07.2014 WP see Discussion where redirection from within the program is shown |
* 12.07.2014 WP see Discussion where redirection from within the program is shown |
||
Line 777: | Line 777: | ||
Call lineout ,'Hello, world!' |
Call lineout ,'Hello, world!' |
||
Say 'and this is the error output:' |
Say 'and this is the error output:' |
||
'type err.txt' </ |
'type err.txt' </syntaxhighlight> |
||
=={{header|Oz}}== |
=={{header|Oz}}== |
||
< |
<syntaxhighlight lang="oz">functor |
||
import Application System |
import Application System |
||
define |
define |
||
{System.showError "Goodbye, World!"} |
{System.showError "Goodbye, World!"} |
||
{Application.exit 0} |
{Application.exit 0} |
||
end</ |
end</syntaxhighlight> |
||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |
||
< |
<syntaxhighlight lang="parigp">error("Goodbye, World!")</syntaxhighlight> |
||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||
{{Works with|Free Pascal}} |
{{Works with|Free Pascal}} |
||
< |
<syntaxhighlight lang="pascal">program byeworld; |
||
begin |
begin |
||
writeln(StdErr, 'Goodbye, World!'); |
writeln(StdErr, 'Goodbye, World!'); |
||
end.</ |
end.</syntaxhighlight> |
||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
< |
<syntaxhighlight lang="perl">warn "Goodbye, World!\n";</syntaxhighlight> |
||
Or: |
Or: |
||
< |
<syntaxhighlight lang="perl">print STDERR "Goodbye, World!\n";</syntaxhighlight> |
||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
<!--< |
<!--<syntaxhighlight lang="phix">--> |
||
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Goodbye, World!"</span><span style="color: #0000FF;">)</span> |
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Goodbye, World!"</span><span style="color: #0000FF;">)</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
=={{header|PHP}}== |
=={{header|PHP}}== |
||
< |
<syntaxhighlight lang="php">fprintf(STDERR, "Goodbye, World!\n");</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="php">file_put_contents("php://stderr","Hello World!\n");</syntaxhighlight> |
||
=={{header|Picat}}== |
=={{header|Picat}}== |
||
< |
<syntaxhighlight lang="picat">println(stderr,"Goodbye, World!")</syntaxhighlight> |
||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |
||
< |
<syntaxhighlight lang="picolisp">(out 2 (prinl "Goodbye, World!"))</syntaxhighlight> |
||
=={{header|Pike}}== |
=={{header|Pike}}== |
||
< |
<syntaxhighlight lang="pike">werror("Goodbye, World!");</syntaxhighlight> |
||
=={{header|PL/I}}== |
=={{header|PL/I}}== |
||
< |
<syntaxhighlight lang="pl/i">display ('Goodbye, World');</syntaxhighlight> |
||
=={{header|PostScript}}== |
=={{header|PostScript}}== |
||
< |
<syntaxhighlight lang="postscript">(%stderr) (w) file dup |
||
(Goodbye, World! |
(Goodbye, World! |
||
) writestring |
) writestring |
||
closefile</ |
closefile</syntaxhighlight> |
||
=={{header|PowerBASIC}}== |
=={{header|PowerBASIC}}== |
||
{{works with|PowerBASIC Console Compiler}} |
{{works with|PowerBASIC Console Compiler}} |
||
< |
<syntaxhighlight lang="powerbasic">STDERR "Goodbye, World!"</syntaxhighlight> |
||
=={{header|PowerShell}}== |
=={{header|PowerShell}}== |
||
Line 843: | Line 843: | ||
standard Write-Error cmdlet is mainly for sending annotated error messages |
standard Write-Error cmdlet is mainly for sending annotated error messages |
||
to the host: |
to the host: |
||
< |
<syntaxhighlight lang="powershell">Write-Error "Goodbye, World!"</syntaxhighlight> |
||
Note that this outputs more than just the message, |
Note that this outputs more than just the message, |
||
because behind the scenes it is an uncaught exception: |
because behind the scenes it is an uncaught exception: |
||
Line 850: | Line 850: | ||
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException</pre> |
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException</pre> |
||
To accurately reproduce the behavior of other languages one has to resort to .NET in this case: |
To accurately reproduce the behavior of other languages one has to resort to .NET in this case: |
||
< |
<syntaxhighlight lang="powershell">[Console]::Error.WriteLine("Goodbye, World!")</syntaxhighlight> |
||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |
||
Line 858: | Line 858: | ||
Standard error output can be used in conjunction with [http://www.purebasic.com/documentation/process/readprogramerror.html ReadProgramError()] to reads a line from an other programs error output (stderr). |
Standard error output can be used in conjunction with [http://www.purebasic.com/documentation/process/readprogramerror.html ReadProgramError()] to reads a line from an other programs error output (stderr). |
||
< |
<syntaxhighlight lang="purebasic">ConsoleError("Goodbye, World!")</syntaxhighlight> |
||
=={{header|Python}}== |
=={{header|Python}}== |
||
{{works with|Python|2.x}} |
{{works with|Python|2.x}} |
||
< |
<syntaxhighlight lang="python">import sys |
||
print >> sys.stderr, "Goodbye, World!"</ |
print >> sys.stderr, "Goodbye, World!"</syntaxhighlight> |
||
{{works with|Python|3.x}} |
{{works with|Python|3.x}} |
||
< |
<syntaxhighlight lang="python">import sys |
||
print("Goodbye, World!", file=sys.stderr)</ |
print("Goodbye, World!", file=sys.stderr)</syntaxhighlight> |
||
Works with either: |
Works with either: |
||
< |
<syntaxhighlight lang="python">import sys |
||
sys.stderr.write("Goodbye, World!\n")</ |
sys.stderr.write("Goodbye, World!\n")</syntaxhighlight> |
||
=={{header|R}}== |
=={{header|R}}== |
||
< |
<syntaxhighlight lang="r">cat("Goodbye, World!", file=stderr())</syntaxhighlight> |
||
=={{header|Ra}}== |
=={{header|Ra}}== |
||
<syntaxhighlight lang="ra"> |
|||
<lang Ra> |
|||
class HelloWorld |
class HelloWorld |
||
**Prints "Goodbye, World!" to standard error** |
**Prints "Goodbye, World!" to standard error** |
||
Line 887: | Line 887: | ||
print to Console.error made !, "Goodbye, World!" |
print to Console.error made !, "Goodbye, World!" |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Racket}}== |
=={{header|Racket}}== |
||
<syntaxhighlight lang="racket"> |
|||
<lang Racket> |
|||
(eprintf "Goodbye, World!\n") |
(eprintf "Goodbye, World!\n") |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
(formerly Perl 6) |
(formerly Perl 6) |
||
<lang |
<syntaxhighlight lang="raku" line>note "Goodbye, World!";</syntaxhighlight> |
||
=={{header|Retro}}== |
=={{header|Retro}}== |
||
< |
<syntaxhighlight lang="retro">'Goodbye,_World! '/dev/stderr file:spew</syntaxhighlight> |
||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
Line 908: | Line 908: | ||
<br>If the '''stderr''' name is supported and enabled, the output is written to the terminal. |
<br>If the '''stderr''' name is supported and enabled, the output is written to the terminal. |
||
<br>If not supported or disabled, the output is written to a (disk) file named '''STDERR'''. |
<br>If not supported or disabled, the output is written to a (disk) file named '''STDERR'''. |
||
< |
<syntaxhighlight lang="rexx">call lineout 'STDERR', "Goodbye, World!"</syntaxhighlight> |
||
===version 2=== |
===version 2=== |
||
Same as above, but uses a different style and also invokes '''charout''' instead of '''lineout'''. |
Same as above, but uses a different style and also invokes '''charout''' instead of '''lineout'''. |
||
< |
<syntaxhighlight lang="rexx">msgText = 'Goodbye, World!' |
||
call charout 'STDERR', msgText</ |
call charout 'STDERR', msgText</syntaxhighlight> |
||
===version 3=== |
===version 3=== |
||
This works on Windows 7 and ooRexx and REGINA |
This works on Windows 7 and ooRexx and REGINA |
||
< |
<syntaxhighlight lang="rexx">/* REXX --------------------------------------------------------------- |
||
* 07.07.2014 Walter Pachl |
* 07.07.2014 Walter Pachl |
||
* enter the appropriate command shown in a command prompt. |
* enter the appropriate command shown in a command prompt. |
||
Line 930: | Line 930: | ||
Call lineout ,'Hello, world!' |
Call lineout ,'Hello, world!' |
||
Say 'and this is the error output:' |
Say 'and this is the error output:' |
||
'type err.txt'</ |
'type err.txt'</syntaxhighlight> |
||
===version 4=== |
===version 4=== |
||
ARexx with tracing console |
ARexx with tracing console |
||
< |
<syntaxhighlight lang="rexx">/**/ |
||
Address command tco |
Address command tco |
||
Call writeln stderr,'Good bye, world!' |
Call writeln stderr,'Good bye, world!' |
||
Call writeln stdout,'Hello, world!'</ |
Call writeln stdout,'Hello, world!'</syntaxhighlight> |
||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
< |
<syntaxhighlight lang="ring">fputs(stderr,"Goodbye, World!")</syntaxhighlight> |
||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
< |
<syntaxhighlight lang="ruby">STDERR.puts "Goodbye, World!"</syntaxhighlight> |
||
The following also works, unless you have disabled warnings (ruby command line option "-W0" or set <code>$VERBOSE=nil</code>) |
The following also works, unless you have disabled warnings (ruby command line option "-W0" or set <code>$VERBOSE=nil</code>) |
||
< |
<syntaxhighlight lang="ruby">warn "Goodbye, World!"</syntaxhighlight> |
||
=={{header|Run BASIC}}== |
=={{header|Run BASIC}}== |
||
< |
<syntaxhighlight lang="runbasic">html "<script> |
||
window.open('','error_msg',''); |
window.open('','error_msg',''); |
||
document.write('Goodbye, World!'); |
document.write('Goodbye, World!'); |
||
</script>""</ |
</script>""</syntaxhighlight> |
||
Run Basic runs in a browser. |
Run Basic runs in a browser. |
||
This opens a new browser window, |
This opens a new browser window, |
||
Line 957: | Line 957: | ||
=={{header|Rust}}== |
=={{header|Rust}}== |
||
< |
<syntaxhighlight lang="rust">fn main() { |
||
eprintln!("Hello, {}!", "world"); |
eprintln!("Hello, {}!", "world"); |
||
}</ |
}</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="rust">fn main() { |
||
use ::std::io::Write; |
use ::std::io::Write; |
||
let (stderr, errmsg) = (&mut ::std::io::stderr(), "Error writing to stderr"); |
let (stderr, errmsg) = (&mut ::std::io::stderr(), "Error writing to stderr"); |
||
Line 968: | Line 968: | ||
let (goodbye, world) = ("Goodbye", "world"); |
let (goodbye, world) = ("Goodbye", "world"); |
||
writeln!(stderr, "{}, {}!", goodbye, world).expect(errmsg); |
writeln!(stderr, "{}, {}!", goodbye, world).expect(errmsg); |
||
}</ |
}</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="rust">fn main() { |
||
use std::io::{self, Write}; |
use std::io::{self, Write}; |
||
Line 979: | Line 979: | ||
io::stderr().write(&*format!("{}, {}!", goodbye, world).as_bytes()).expect("Could not write to stderr"); |
io::stderr().write(&*format!("{}, {}!", goodbye, world).as_bytes()).expect("Could not write to stderr"); |
||
// Clearly, if you want formatted strings there's no reason not to just use writeln! |
// Clearly, if you want formatted strings there's no reason not to just use writeln! |
||
}</ |
}</syntaxhighlight> |
||
=={{header|S-lang}}== |
=={{header|S-lang}}== |
||
< |
<syntaxhighlight lang="s-lang">() = fputs("Goodbye, World!\n", stderr);</syntaxhighlight> |
||
=={{header|Salmon}}== |
=={{header|Salmon}}== |
||
<syntaxhighlight lang="salmon"> |
|||
<lang Salmon> |
|||
standard_error.print("Goodbye, World!\n"); |
standard_error.print("Goodbye, World!\n"); |
||
</syntaxhighlight> |
|||
</lang> |
|||
or |
or |
||
<syntaxhighlight lang="salmon"> |
|||
<lang Salmon> |
|||
include "short.salm"; |
include "short.salm"; |
||
stderr.print("Goodbye, World!\n"); |
stderr.print("Goodbye, World!\n"); |
||
</syntaxhighlight> |
|||
</lang> |
|||
or |
or |
||
<syntaxhighlight lang="salmon"> |
|||
<lang Salmon> |
|||
include "shorter.salm"; |
include "shorter.salm"; |
||
err.print("Goodbye, World!\n"); |
err.print("Goodbye, World!\n"); |
||
</syntaxhighlight> |
|||
</lang> |
|||
or |
or |
||
<syntaxhighlight lang="salmon"> |
|||
<lang Salmon> |
|||
include "shorter.salm"; |
include "shorter.salm"; |
||
se.print("Goodbye, World!\n"); |
se.print("Goodbye, World!\n"); |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Sather}}== |
=={{header|Sather}}== |
||
< |
<syntaxhighlight lang="sather">class MAIN is |
||
main is |
main is |
||
#ERR + "Hello World!\n"; |
#ERR + "Hello World!\n"; |
||
end; |
end; |
||
end;</ |
end;</syntaxhighlight> |
||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
Line 1,022: | Line 1,022: | ||
===Ad hoc REPL solution=== |
===Ad hoc REPL solution=== |
||
Ad hoc solution as [http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop REPL] script: |
Ad hoc solution as [http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop REPL] script: |
||
< |
<syntaxhighlight lang="scala">Console.err.println("Goodbye, World!")</syntaxhighlight> |
||
===Via Java runtime=== |
===Via Java runtime=== |
||
This is a call to the Java run-time library. '''Not recommendated'''. |
This is a call to the Java run-time library. '''Not recommendated'''. |
||
< |
<syntaxhighlight lang="scala">System.err.println("Goodbye, World!")</syntaxhighlight> |
||
===Via Scala Console API=== |
===Via Scala Console API=== |
||
This is a call to the Scala API. '''Recommendated'''. |
This is a call to the Scala API. '''Recommendated'''. |
||
< |
<syntaxhighlight lang="scala">Console.err.println("Goodbye, World!")</syntaxhighlight> |
||
===Short term deviation to err=== |
===Short term deviation to err=== |
||
< |
<syntaxhighlight lang="scala">Console.withOut(Console.err) { println("This goes to default _err_") }</syntaxhighlight> |
||
===Long term deviation to err=== |
===Long term deviation to err=== |
||
< |
<syntaxhighlight lang="scala"> println ("Out not deviated") |
||
Console.setOut(Console.err) |
Console.setOut(Console.err) |
||
println ("Out deviated") |
println ("Out deviated") |
||
Console.setOut(Console.out) // Reset to normal</ |
Console.setOut(Console.out) // Reset to normal</syntaxhighlight> |
||
=={{header|Scheme}}== |
=={{header|Scheme}}== |
||
< |
<syntaxhighlight lang="scheme">(error "Goodbye, World!")</syntaxhighlight> |
||
=={{header|Scilab}}== |
=={{header|Scilab}}== |
||
< |
<syntaxhighlight lang="scilab">error("Goodbye, World!")</syntaxhighlight> |
||
=={{header|sed}}== |
=={{header|sed}}== |
||
Requires <tt>/dev/stderr</tt> |
Requires <tt>/dev/stderr</tt> |
||
< |
<syntaxhighlight lang="sed">#n |
||
1 { |
1 { |
||
s/.*/Goodbye, World!/w /dev/stderr |
s/.*/Goodbye, World!/w /dev/stderr |
||
}</ |
}</syntaxhighlight> |
||
This program requires at least 1 line of input. |
This program requires at least 1 line of input. |
||
Line 1,061: | Line 1,061: | ||
{{out|Test output}} |
{{out|Test output}} |
||
< |
<syntaxhighlight lang="bash">$ echo a | sed -f error.sed >/dev/null |
||
Goodbye, World!</ |
Goodbye, World!</syntaxhighlight> |
||
=={{header|Seed7}}== |
=={{header|Seed7}}== |
||
< |
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i"; |
||
const proc: main is func |
const proc: main is func |
||
begin |
begin |
||
writeln(STD_ERR, "Goodbye, World!"); |
writeln(STD_ERR, "Goodbye, World!"); |
||
end func;</ |
end func;</syntaxhighlight> |
||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
< |
<syntaxhighlight lang="ruby">STDERR.println("Goodbye, World!");</syntaxhighlight> |
||
=={{header|Slate}}== |
=={{header|Slate}}== |
||
< |
<syntaxhighlight lang="slate">inform: 'Goodbye, World!' &target: DebugConsole.</syntaxhighlight> |
||
=={{header|Smalltalk}}== |
=={{header|Smalltalk}}== |
||
The details on to which name stderr is bound may vary between Smalltalk dialects. If different, a "Smalltalk at:#Stderr put:<name your stream here>" should provide compatibility. |
The details on to which name stderr is bound may vary between Smalltalk dialects. If different, a "Smalltalk at:#Stderr put:<name your stream here>" should provide compatibility. |
||
< |
<syntaxhighlight lang="smalltalk">Stderr nextPutAll: 'Goodbye, World!'</syntaxhighlight> |
||
However, all Smalltalks provide a console named "Transcript", where diagnostics is usually sent to (which is convenient, if there is no stderr to look at, as when started in Windows as an exe, vs. a com).<br>Thus: |
However, all Smalltalks provide a console named "Transcript", where diagnostics is usually sent to (which is convenient, if there is no stderr to look at, as when started in Windows as an exe, vs. a com).<br>Thus: |
||
< |
<syntaxhighlight lang="smalltalk">Transcript show: 'Goodbye, World!'</syntaxhighlight> |
||
will work on all, and is the preferred way to do this. |
will work on all, and is the preferred way to do this. |
||
Line 1,090: | Line 1,090: | ||
The above tells the stream to write a string; |
The above tells the stream to write a string; |
||
you can also tell the string to print itself onto some stream: |
you can also tell the string to print itself onto some stream: |
||
< |
<syntaxhighlight lang="smalltalk">'Goodbye, World!' printOn: Stderr</syntaxhighlight> |
||
Both have the same effect. |
Both have the same effect. |
||
=={{header|SNOBOL4}}== |
=={{header|SNOBOL4}}== |
||
< |
<syntaxhighlight lang="snobol4"> terminal = "Error" |
||
output = "Normal text" |
output = "Normal text" |
||
end</ |
end</syntaxhighlight> |
||
=={{header|Standard ML}}== |
=={{header|Standard ML}}== |
||
< |
<syntaxhighlight lang="sml">TextIO.output (TextIO.stdErr, "Goodbye, World!\n")</syntaxhighlight> |
||
=={{header|Swift}}== |
=={{header|Swift}}== |
||
< |
<syntaxhighlight lang="swift">import Foundation |
||
let out = NSOutputStream(toFileAtPath: "/dev/stderr", append: true) |
let out = NSOutputStream(toFileAtPath: "/dev/stderr", append: true) |
||
Line 1,112: | Line 1,112: | ||
if let bytes = success { |
if let bytes = success { |
||
println("\nWrote \(bytes) bytes") |
println("\nWrote \(bytes) bytes") |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 1,120: | Line 1,120: | ||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
< |
<syntaxhighlight lang="tcl">puts stderr "Goodbye, World!"</syntaxhighlight> |
||
=={{header|Transact-SQL}}== |
=={{header|Transact-SQL}}== |
||
< |
<syntaxhighlight lang="transact-sql"> RAISERROR 'Goodbye, World!', 16, 1 </syntaxhighlight> |
||
=={{header|True BASIC}}== |
=={{header|True BASIC}}== |
||
< |
<syntaxhighlight lang="basic"> |
||
CAUSE error 1, "Goodbye World!" |
CAUSE error 1, "Goodbye World!" |
||
END |
END |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|TUSCRIPT}}== |
=={{header|TUSCRIPT}}== |
||
< |
<syntaxhighlight lang="tuscript"> |
||
$$ MODE TUSCRIPT |
$$ MODE TUSCRIPT |
||
PRINT/ERROR "hello world" |
PRINT/ERROR "hello world" |
||
text="goodbye world" |
text="goodbye world" |
||
PRINT/ERROR text |
PRINT/ERROR text |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 1,146: | Line 1,146: | ||
=={{header|UNIX Shell}}== |
=={{header|UNIX Shell}}== |
||
{{works with|Bourne Shell}} |
{{works with|Bourne Shell}} |
||
< |
<syntaxhighlight lang="bash">echo "Goodbye, World!" >&2</syntaxhighlight> |
||
==={{header|C Shell}}=== |
==={{header|C Shell}}=== |
||
< |
<syntaxhighlight lang="csh">echo "Goodbye, World!" >/dev/stderr</syntaxhighlight> |
||
This requires <code>/dev/stderr</code>, a device node from [[BSD]] |
This requires <code>/dev/stderr</code>, a device node from [[BSD]] |
||
Line 1,156: | Line 1,156: | ||
=={{header|Ursa}}== |
=={{header|Ursa}}== |
||
< |
<syntaxhighlight lang="ursa">out "goodbye, world!" endl console.err</syntaxhighlight> |
||
=={{header|VBA}}== |
=={{header|VBA}}== |
||
<syntaxhighlight lang="vb"> |
|||
<lang VB> |
|||
Sub StandardError() |
Sub StandardError() |
||
Debug.Print "Goodbye World!" |
Debug.Print "Goodbye World!" |
||
End Sub |
End Sub |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|VBScript}}== |
=={{header|VBScript}}== |
||
Must work in cscript.exe |
Must work in cscript.exe |
||
< |
<syntaxhighlight lang="vb">WScript.StdErr.WriteLine "Goodbye, World!"</syntaxhighlight> |
||
=={{header|Verbexx}}== |
=={{header|Verbexx}}== |
||
< |
<syntaxhighlight lang="verbexx">@STDERR "Goodbye, World!\n";</syntaxhighlight> |
||
=={{header|Visual Basic .NET}}== |
=={{header|Visual Basic .NET}}== |
||
< |
<syntaxhighlight lang="vbnet">Module Module1 |
||
Sub Main() |
Sub Main() |
||
Line 1,179: | Line 1,179: | ||
End Sub |
End Sub |
||
End Module</ |
End Module</syntaxhighlight> |
||
=={{header|WDTE}}== |
=={{header|WDTE}}== |
||
< |
<syntaxhighlight lang="wdte">io.writeln io.stderr 'Goodbye, World!';</syntaxhighlight> |
||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
< |
<syntaxhighlight lang="ecmascript">Fiber.abort("Goodbye, World!")</syntaxhighlight> |
||
=={{header|X86 Assembly}}== |
=={{header|X86 Assembly}}== |
||
Line 1,195: | Line 1,195: | ||
Prints "Goodbye, World!" to stderr (and there is probably an even simpler version): |
Prints "Goodbye, World!" to stderr (and there is probably an even simpler version): |
||
< |
<syntaxhighlight lang="asm">section .data |
||
msg db 'Goodbye, World!', 0AH |
msg db 'Goodbye, World!', 0AH |
||
len equ $-msg |
len equ $-msg |
||
Line 1,209: | Line 1,209: | ||
mov ebx, 1 |
mov ebx, 1 |
||
mov eax, 1 |
mov eax, 1 |
||
int 80h</ |
int 80h</syntaxhighlight> |
||
=={{header|XLISP}}== |
=={{header|XLISP}}== |
||
< |
<syntaxhighlight lang="xlisp">(DISPLAY "Goodbye, World!" *ERROR-OUTPUT*)</syntaxhighlight> |
||
=={{header|XPL0}}== |
=={{header|XPL0}}== |
||
Line 1,222: | Line 1,222: | ||
which is device 2. |
which is device 2. |
||
< |
<syntaxhighlight lang="xpl0">code Text=12; |
||
Text(2, "Goodbye, World!")</ |
Text(2, "Goodbye, World!")</syntaxhighlight> |
||
=={{header|Yabasic}}== |
=={{header|Yabasic}}== |
||
< |
<syntaxhighlight lang="yabasic"> |
||
error "Goodbye World!" |
error "Goodbye World!" |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Zig}}== |
=={{header|Zig}}== |
||
< |
<syntaxhighlight lang="zig">const std = @import("std"); |
||
pub fn main() !void { |
pub fn main() !void { |
||
try std.io.getStdErr().writer().writeAll("Goodbye, World!\n"); |
try std.io.getStdErr().writer().writeAll("Goodbye, World!\n"); |
||
// debug messages are also printed to stderr |
// debug messages are also printed to stderr |
||
//std.debug.print("Goodbye, World!\n"); |
//std.debug.print("Goodbye, World!\n"); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|zkl}}== |
=={{header|zkl}}== |
||
< |
<syntaxhighlight lang="zkl">File.stderr.writeln("Goodbye, World!")</syntaxhighlight> |
Revision as of 15:05, 27 August 2022
You are encouraged to solve this task according to the task description, using any language you may know.
A common practice in computing is to send error messages to a different output stream than normal text console messages.
The normal messages print to what is called "standard output" or "standard out".
The error messages print to "standard error".
This separation can be used to redirect error messages to a different place than normal messages.
- Task
Show how to print a message to standard error by printing Goodbye, World! on that stream.
11l
:stderr.write("Goodbye, World!\n")
4DOS Batch
echoerr Goodbye, World!
AArch64 Assembly
.equ STDERR, 2
.equ SVC_WRITE, 64
.equ SVC_EXIT, 93
.text
.global _start
_start:
stp x29, x30, [sp, -16]!
mov x0, #STDERR
ldr x1, =msg
mov x2, 15
mov x8, #SVC_WRITE
mov x29, sp
svc #0 // write(stderr, msg, 15);
ldp x29, x30, [sp], 16
mov x0, #0
mov x8, #SVC_EXIT
svc #0 // exit(0);
msg: .ascii "Goodbye World!\n"
Ada
with Ada.Text_IO; use Ada.Text_IO;
procedure Goodbye_World is
begin
Put_Line (Standard_Error, "Goodbye, World!");
end Goodbye_World;
Agena
io.write( io.stderr, "Goodbye, World!\n" )
Aime
v_text("Goodbye, World!\n");
ALGOL 68
The procedures print and printf output to stand out, whereas put and putf can output to any open file, including stand error.
main:(
put(stand error, ("Goodbye, World!", new line))
)
- Output:
Goodbye, World!
Argile
use std
eprint "Goodbye, World!"
or
use std
eprintf "Goodbye, World!\n"
or
use std
fprintf stderr "Goodbye, World!\n"
ARM Assembly
/* ARM assembly Raspberry PI */
/* program hellowordLP.s */
.data
szMessage: .asciz "Goodbye world. \n " @ error message
.equ LGMESSAGE, . - szMessage @ compute length of message
.text
.global main
main:
mov r0, #2 @ output error linux
ldr r1, iAdrMessage @ adresse of message
mov r2, #LGMESSAGE @ sizeof(message)
mov r7, #4 @ select system call 'write'
swi #0 @ perform the system call
mov r0, #0 @ return code
mov r7, #1 @ request to exit program
swi #0 @ perform the system call
iAdrMessage: .int szMessage
Arturo
panic "Goodbye, World!"
ATS
implement main0 () = fprint (stderr_ref, "Goodbye, World!\n")
AutoHotkey
requires AutoHotkey_N implementation.
; c:\> autohotkey.exe stderr.ahk 2> error.txt
FileAppend, Goodbye`, World!, stderr ; requires AutoHotkey_N
Or with the current AutoHotkey_L:
(documentation on this behavior: http://www.autohotkey.net/~Lexikos/AutoHotkey_L/docs/commands/FileAppend.htm)
FileAppend, Goodbye`, World!, *
AutoIt
ConsoleWriteError("Goodbye, World!" & @CRLF)
Avail
Error: "Goodbye, World!";
AWK
To print a message to standard error, pipe it through a shell command:
BEGIN {
print "Goodbye, World!"| "cat 1>&2"
}
Or write to /dev/stderr:
BEGIN {
print "Goodbye, World!" > "/dev/stderr"
}
With gawk, mawk and nawk: a special feature associates "/dev/stderr" with standard error. The manuals of gawk and mawk describe this feature; nawk also has this feature.
Other implementations might try to open /dev/stderr as a file. Some Unix clones, like BSD, have a /dev/stderr device node that duplicates standard error, so this code would still work. Some systems have no such device node, so this code would fail. We recommend "cat 1>&2", which is more portable, and works with any Unix clone.
BASIC
ON ERROR GOTO ManejoErrores
ERROR 99
END
ManejoErrores:
PRINT "Googbye World!"
RESUME
BaCon
EPRINT "Goodbye, World!"
BASIC256
onerror errortrap
throwerror 99
end
errortrap:
print "Goodbye World!"
return
ZX Spectrum Basic
On the ZX Spectrum, standard error is on stream 1:
10 PRINT #1;"Goodbye, World!"
20 PAUSE 50: REM allow time for the user to see the error message
Batch File
1>&2 echo Goodbye, World!
The redirection operator 1>&2
causes all output on stream 1 (standard out) to be redirected to stream 2 (standard error).
The redirection can be moved to the end of the line, too.
BBC BASIC
The program must be compiled as a console application for this to work.
STD_ERROR_HANDLE = -12
SYS "GetStdHandle", STD_ERROR_HANDLE TO @hfile%(1)
PRINT #13, "Goodbye, World!"
QUIT
Blade
import io
io.stderr.write('Goodbye, World!')
C
Unlike puts(), fputs() does not append a terminal newline.
#include <stdio.h>
int main()
{
fprintf(stderr, "Goodbye, ");
fputs("World!\n", stderr);
return 0;
}
C#
static class StdErr
{
static void Main(string[] args)
{
Console.Error.WriteLine("Goodbye, World!");
}
}
C++
#include <iostream>
int main() {
std::cerr << "Goodbye, World!\n";
}
Clojure
(binding [*out* *err*]
(println "Goodbye, world!"))
CLU
start_up = proc ()
stream$putl(stream$error_output(), "Goodbye, World!")
end start_up
CMake
Most messages go to standard error.
message("Goodbye, World!")
The message cannot be a keyword; message("STATUS")
never prints "STATUS", but message("" "STATUS")
does work.
COBOL
Using fixed format.
program-id. ehello.
procedure division.
display "Goodbye, world!" upon syserr.
stop run.
CoffeeScript
console.warn "Goodbye, World!"
Common Lisp
(format *error-output* "Goodbye, world!~%")
D
import std.stdio;
void main () {
stderr.writeln("Goodbye, World!");
}
Alternative Version
import tango.io.Stdout;
void main () {
Stderr("Goodbye, World!").newline;
}
Dart
import 'dart:io';
void main() {
stderr.writeln('Goodbye, World!');
}
Delphi
program Project1;
{$APPTYPE CONSOLE}
begin
WriteLn(ErrOutput, 'Goodbye, World!');
end.
Dylan.NET
One Line version:
Console::get_Error()::WriteLine("Goodbye World!")
Goodbye World Program:
//compile using the new dylan.NET v, 11.5.1.2 or later
//use mono to run the compiler
#refstdasm mscorlib.dll
import System
assembly stderrex exe
ver 1.1.0.0
class public Program
method public static void main()
Console::get_Error()::WriteLine("Goodbye World!")
end method
end class
Déjà Vu
!write-fragment!stderr !encode!utf-8 "Goodbye, World!\n"
E
stderr.println("Goodbye, World!")
Elixir
IO.puts :stderr, "Goodbye, World!"
Emacs Lisp
In batch mode, message
actually prints to standard error:
(message "Goodbye, World!")
For greater control, princ
can be used with a special printing function:
(princ "Goodbye, World!\n" 'external-debugging-output)
Erlang
io:put_chars(standard_error, "Goodbye, World!\n").
Euphoria
puts(2,"Goodbye, world!\n") -- 2 means output to 'standard error'
F#
eprintfn "%s" "Goodbye, World!"
or you can use the .Net classes
System.Console.Error.WriteLine("Goodbye, World!");
Factor
Start Factor in a terminal for this:
error-stream get [ "Goodbye, World! bbl, crashing" print flush ] with-output-stream*
Fantom
class Main
{
public static Void main ()
{
Env.cur.err.printLine ("Goodbye, World!")
}
}
Forth
outfile-id
stderr to outfile-id
." Goodbye, World!" cr
to outfile-id
Fortran
Normally standard error is associated with the unit 0 but this could be different for different vendors. Therefore since Fortran 2003 there's an intrinsic module which defines the parameter ERROR_UNIT.
program StdErr
! Fortran 2003
use iso_fortran_env
! in case there's no module iso_fortran_env ...
!integer, parameter :: ERROR_UNIT = 0
write (ERROR_UNIT, *) "Goodbye, World!"
end program StdErr
FreeBASIC
' FB 1.05.0 Win64
Open Err As #1
Print #1, "Goodbye World!"
Close #1
Sleep
Frink
staticJava["java.lang.System","err"].println["Goodbye, World!"]
Genie
[indent=4]
/*
Hello, to Standard error, in Genie
valac helloStderr.gs
*/
init
stderr.printf("%s\n", "Goodbye, World!")
- Output:
prompt$ ./helloStderr | wc Goodbye, World! 0 0 0
Go
Built in println now goes to stderr.
package main
func main() { println("Goodbye, World!") }
but the builtin print() and println() functions are not guaranteed to stay in the language. So you should probably use
package main
import ("fmt"; "os")
func main() { fmt.Fprintln(os.Stderr, "Goodbye, World!") }
Groovy
System.err.println("Goodbye, World!")
Haskell
import System.IO
main = hPutStrLn stderr "Goodbye, World!"
Huginn
#! /bin/sh
exec huginn --no-argv -E "${0}" "${@}"
#! huginn
import OperatingSystem as os;
main() {
os.stderr().write( "Goodbye, World!\n" );
return ( 0 );
}
Icon and Unicon
J
stderr =: 1!:2&4
stderr 'Goodbye, World!'
Java
public class Err{
public static void main(String[] args){
System.err.println("Goodbye, World!");
}
}
JavaScript
and only with cscript.exe
WScript.StdErr.WriteLine("Goodbye, World!");
console.warn("Goodbye, World!")
console.error("Goodbye, World!")//only works if console object exists
OR
throw new Error("Goodbye, World!")//Should work in any browser
jq
jq -n —-arg s 'Goodbye, World!' '$s | stderr | empty'
`stderr` copies its input to STDERR before passing it along the pipeline, and hence the occurrence of `empty` above.
Julia
println(STDERR, "Goodbye, World!")
Kotlin
fun main(args: Array<String>) {
System.err.println("Goodbye, World!")
}
langur
writelnErr "goodbye, people"
Lasso
define stderr(s::string) => {
file_stderr->writeBytes(#s->asBytes)
}
stderr('Goodbye, World!')
Lingo
- Windows:
-- print to standard error
stdErr("Goodbye, World!", TRUE)
-- print to the Windows debug console (shown in realtime e.g. in Systernal's DebugView)
dbgPrint("Goodbye, World!")
- Mac OS X:
sx = xtra("Shell").new()
-- print to standard error
sx.shell_cmd("echo Goodbye, World!>&2")
-- print to system.log (shown in realtime e.g. in Konsole.app)
sx.shell_cmd("logger Goodbye, World!")
LLVM
; This is not strictly LLVM, as it uses the C library function "printf".
; LLVM does not provide a way to print values, so the alternative would be
; to just load the string into memory, and that would be boring.
; Additional comments have been inserted, as well as changes made from the output produced by clang such as putting more meaningful labels for the jumps
%struct._iobuf = type { i8* }
$"message" = comdat any
@"message" = linkonce_odr unnamed_addr constant [17 x i8] c"Goodbye, world!\0A\00", comdat, align 1
;-- For discovering stderr (io pipe 2)
declare %struct._iobuf* @__acrt_iob_func(i32)
;--- The declaration for the external C fprintf function.
declare i32 @fprintf(%struct._iobuf*, i8*, ...)
define i32 @main() {
;-- load stderr
%1 = call %struct._iobuf* @__acrt_iob_func(i32 2)
;-- print the message to stderr with fprintf
%2 = call i32 (%struct._iobuf*, i8*, ...) @fprintf(%struct._iobuf* %1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @"message", i32 0, i32 0))
;-- exit
ret i32 0
}
- Output:
Goodbye, world!
Logtalk
The stream alias "user_error" can be used to print to the "standard error" stream.
:- object(error_message).
% the initialization/1 directive argument is automatically executed
% when the object is compiled and loaded into memory:
:- initialization(write(user_error, 'Goodbye, World!\n')).
:- end_object.
Lua
io.stderr:write("Goodbye, World!\n")
m4
errprint(`Goodbye, World!
')dnl
MANOOL
{{extern "manool.org.18/std/0.3/all"} in Err.WriteLine["Goodbye, World!"]}
Maple
error "Goodbye World"
Mathematica / Wolfram Language
Write[Streams["stderr"], "Goodbye, World!"]
MATLAB / Octave
This prints to standard error, and continues execution
fprintf(2,'Goodbye, World!')
This will not stop further execution, if called from within a script or function.
error 'Goodbye, World!'
Mercury
:- module hello_error.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
main(!IO) :-
io.stderr_stream(Stderr, !IO),
io.write_string(Stderr, "Goodbye, World!\n", !IO).
Metafont
Metafont has no a real way to send a text to the standard output/error nor to a file. Anyway it exists the errmessage
command which will output an error message and prompt the user for action (suspending the interpretation of the source).
errmessage "Error";
message "...going on..."; % if the user decides to go on and not to stop
% the program because of the error.
ML/I
MCSET S4=1
MCNOTE Goodbye, World!
Modula-2
MODULE HelloErr;
IMPORT StdError;
BEGIN
StdError.WriteString('Goodbye, World!');
StdError.WriteLn
END HelloErr.
Modula-3
MODULE Stderr EXPORTS Main;
IMPORT Wr, Stdio;
BEGIN
Wr.PutText(Stdio.stderr, "Goodbye, World!\n");
END Stderr.
N/t/roff
The request .tm
prints whatever after it, until and including the newline character, to the standard error. The string parsed to it need not be quoted and will never appear on standard output.
.tm Goodbye, World!
Neko
/**
Hello world, to standard error, in Neko
Tectonics:
nekoc hello-stderr.neko
neko hello-stderr
*/
/* Assume stderr is already open, just need write */
var file_write = $loader.loadprim("std@file_write", 4);
/* Load (and execute) the file_stderr primitive */
var stderr = $loader.loadprim("std@file_stderr", 0)();
file_write(stderr, "Goodbye, World!\n", 0, 16);
- Output:
prompt$ nekoc hello-stderr.neko prompt$ neko hello-stderr Goodbye, World! prompt$ neko hello-stderr 2>/dev/null prompt$
Nemerle
System.Console.Error.WriteLine("Goodbye, World!");
NetRexx
/* NetRexx */
options replace format comments java crossref savelog symbols binary
System.err.println("Goodbye, World!")
Nim
stderr.writeln "Hello World"
Oberon-2
Oxford Oberon-2
MODULE HelloErr;
IMPORT Err;
BEGIN
Err.String("Goodbye, World!");Err.Ln
END HelloErr.
- Output:
Goodbye, World!
Objective-C
In Objective-C one can use the standard C library and the stderr as in the C language; nonetheless a common way to output to stderr for logging purpose and/or error notification is the NSLog function, that works almost like fprintf(stderr, "..."), save for the fact that the format string is an NSString object, and it also prepends a timestamp.
#import <Foundation/Foundation.h>
int main()
{
fprintf(stderr, "Goodbye, World!\n");
fputs("Goodbye, World!\n", stderr);
NSLog(@"Goodbye, World!");
return 0;
}
OCaml
prerr_endline "Goodbye, World!"; (* this is how you print a string with newline to stderr *)
Printf.eprintf "Goodbye, World!\n"; (* this is how you would use printf with stderr *)
we can also use the out_channel stderr:
output_string stderr "Goodbye, World!\n";
Printf.fprintf stderr "Goodbye, World!\n";
finally the Unix module also provides unbuffered write functions:
let msg = "Goodbye, World!\n" in
ignore(Unix.write Unix.stderr msg 0 (String.length msg)) ;;
Octave
fprintf(stderr, "Goodbye, World!\n");
Oforth
System.Err "Goodbye, World!" << cr
Ol
(print-to stderr "Goodbye, World!")
ooRexx
ooRexx provides a .error object that writes output to the standard error stream.
.error~lineout("Goodbye, World!")
The .error object is a proxy that delegates to a backing stream, so this might be redirected. By default, this delegates to the .stderr object, which can also be used directly.
.stderr~lineout("Goodbye, World!")
or in 'Classic REXX style'
/* REXX ---------------------------------------------------------------
* 07.07.2014 Walter Pachl
* 12.07.2014 WP see Discussion where redirection from within the program is shown
*--------------------------------------------------------------------*/
Say 'rexx serr 2>err.txt directs the stderr output to the file err.txt'
Call lineout 'stderr','Good bye, world!'
Call lineout ,'Hello, world!'
Say 'and this is the error output:'
'type err.txt'
Oz
functor
import Application System
define
{System.showError "Goodbye, World!"}
{Application.exit 0}
end
PARI/GP
error("Goodbye, World!")
Pascal
program byeworld;
begin
writeln(StdErr, 'Goodbye, World!');
end.
Perl
warn "Goodbye, World!\n";
Or:
print STDERR "Goodbye, World!\n";
Phix
puts(2,"Goodbye, World!")
PHP
fprintf(STDERR, "Goodbye, World!\n");
or
file_put_contents("php://stderr","Hello World!\n");
Picat
println(stderr,"Goodbye, World!")
PicoLisp
(out 2 (prinl "Goodbye, World!"))
Pike
werror("Goodbye, World!");
PL/I
display ('Goodbye, World');
PostScript
(%stderr) (w) file dup
(Goodbye, World!
) writestring
closefile
PowerBASIC
STDERR "Goodbye, World!"
PowerShell
Since PowerShell has a slightly different system of pipes and streams (to facilitate easy usage from a host application) the standard Write-Error cmdlet is mainly for sending annotated error messages to the host:
Write-Error "Goodbye, World!"
Note that this outputs more than just the message, because behind the scenes it is an uncaught exception:
Write-Error "Goodbye, World!" : Goodbye, World! + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException
To accurately reproduce the behavior of other languages one has to resort to .NET in this case:
[Console]::Error.WriteLine("Goodbye, World!")
PureBasic
ConsoleError() writes the message string (plus a newline) to the standard error output of current program.
Standard error output can be used in conjunction with ReadProgramError() to reads a line from an other programs error output (stderr).
ConsoleError("Goodbye, World!")
Python
import sys
print >> sys.stderr, "Goodbye, World!"
import sys
print("Goodbye, World!", file=sys.stderr)
Works with either:
import sys
sys.stderr.write("Goodbye, World!\n")
R
cat("Goodbye, World!", file=stderr())
Ra
class HelloWorld
**Prints "Goodbye, World!" to standard error**
on start
print to Console.error made !, "Goodbye, World!"
Racket
(eprintf "Goodbye, World!\n")
Raku
(formerly Perl 6)
note "Goodbye, World!";
Retro
'Goodbye,_World! '/dev/stderr file:spew
REXX
version 1
This version will work with those operating systems (hosts)
that support stream output and a STDERR output
stream (by name).
If the stderr name is supported and enabled, the output is written to the terminal.
If not supported or disabled, the output is written to a (disk) file named STDERR.
call lineout 'STDERR', "Goodbye, World!"
version 2
Same as above, but uses a different style and also invokes charout instead of lineout.
msgText = 'Goodbye, World!'
call charout 'STDERR', msgText
version 3
This works on Windows 7 and ooRexx and REGINA
/* REXX ---------------------------------------------------------------
* 07.07.2014 Walter Pachl
* enter the appropriate command shown in a command prompt.
* "rexx serr.rex 2>err.txt"
* or "regina serr.rex 2>err.txt"
* 2>file will redirect the stderr stream to the specified file.
* I don't know any other way to catch this stream
*--------------------------------------------------------------------*/
Parse Version v
Say v
Call lineout 'stderr','Good bye, world!'
Call lineout ,'Hello, world!'
Say 'and this is the error output:'
'type err.txt'
version 4
ARexx with tracing console
/**/
Address command tco
Call writeln stderr,'Good bye, world!'
Call writeln stdout,'Hello, world!'
Ring
fputs(stderr,"Goodbye, World!")
Ruby
STDERR.puts "Goodbye, World!"
The following also works, unless you have disabled warnings (ruby command line option "-W0" or set $VERBOSE=nil
)
warn "Goodbye, World!"
Run BASIC
html "<script>
window.open('','error_msg','');
document.write('Goodbye, World!');
</script>""
Run Basic runs in a browser. This opens a new browser window, or a tab in the case of Chrome and some others.
Rust
fn main() {
eprintln!("Hello, {}!", "world");
}
or
fn main() {
use ::std::io::Write;
let (stderr, errmsg) = (&mut ::std::io::stderr(), "Error writing to stderr");
writeln!(stderr, "Bye, world!").expect(errmsg);
let (goodbye, world) = ("Goodbye", "world");
writeln!(stderr, "{}, {}!", goodbye, world).expect(errmsg);
}
or
fn main() {
use std::io::{self, Write};
io::stderr().write(b"Goodbye, world!").expect("Could not write to stderr");
// With some finagling, you can do a formatted string here as well
let goodbye = "Goodbye";
let world = "world";
io::stderr().write(&*format!("{}, {}!", goodbye, world).as_bytes()).expect("Could not write to stderr");
// Clearly, if you want formatted strings there's no reason not to just use writeln!
}
S-lang
() = fputs("Goodbye, World!\n", stderr);
Salmon
standard_error.print("Goodbye, World!\n");
or
include "short.salm";
stderr.print("Goodbye, World!\n");
or
include "shorter.salm";
err.print("Goodbye, World!\n");
or
include "shorter.salm";
se.print("Goodbye, World!\n");
Sather
class MAIN is
main is
#ERR + "Hello World!\n";
end;
end;
Scala
Ad hoc REPL solution
Ad hoc solution as REPL script:
Console.err.println("Goodbye, World!")
Via Java runtime
This is a call to the Java run-time library. Not recommendated.
System.err.println("Goodbye, World!")
Via Scala Console API
This is a call to the Scala API. Recommendated.
Console.err.println("Goodbye, World!")
Short term deviation to err
Console.withOut(Console.err) { println("This goes to default _err_") }
Long term deviation to err
println ("Out not deviated")
Console.setOut(Console.err)
println ("Out deviated")
Console.setOut(Console.out) // Reset to normal
Scheme
(error "Goodbye, World!")
Scilab
error("Goodbye, World!")
sed
Requires /dev/stderr
#n
1 {
s/.*/Goodbye, World!/w /dev/stderr
}
This program requires at least 1 line of input. It changes the first line to "Goodbye, World!" and then prints the first line to standard error. It reads and ignores the remaining lines.
- Test output:
$ echo a | sed -f error.sed >/dev/null
Goodbye, World!
Seed7
$ include "seed7_05.s7i";
const proc: main is func
begin
writeln(STD_ERR, "Goodbye, World!");
end func;
Sidef
STDERR.println("Goodbye, World!");
Slate
inform: 'Goodbye, World!' &target: DebugConsole.
Smalltalk
The details on to which name stderr is bound may vary between Smalltalk dialects. If different, a "Smalltalk at:#Stderr put:<name your stream here>" should provide compatibility.
Stderr nextPutAll: 'Goodbye, World!'
However, all Smalltalks provide a console named "Transcript", where diagnostics is usually sent to (which is convenient, if there is no stderr to look at, as when started in Windows as an exe, vs. a com).
Thus:
Transcript show: 'Goodbye, World!'
will work on all, and is the preferred way to do this.
(and yes, when running UI-less as a console program, the global "Transcript" is usually bound to the stderr stream).
The above tells the stream to write a string; you can also tell the string to print itself onto some stream:
'Goodbye, World!' printOn: Stderr
Both have the same effect.
SNOBOL4
terminal = "Error"
output = "Normal text"
end
Standard ML
TextIO.output (TextIO.stdErr, "Goodbye, World!\n")
Swift
import Foundation
let out = NSOutputStream(toFileAtPath: "/dev/stderr", append: true)
let err = "Goodbye, World!".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
out?.open()
let success = out?.write(UnsafePointer<UInt8>(err!.bytes), maxLength: err!.length)
out?.close()
if let bytes = success {
println("\nWrote \(bytes) bytes")
}
- Output:
Goodbye, World! Wrote 15 bytes
Tcl
puts stderr "Goodbye, World!"
Transact-SQL
RAISERROR 'Goodbye, World!', 16, 1
True BASIC
CAUSE error 1, "Goodbye World!"
END
TUSCRIPT
$$ MODE TUSCRIPT
PRINT/ERROR "hello world"
text="goodbye world"
PRINT/ERROR text
- Output:
@@@@@@@@ hello world @@@@@@@@ @@@@@@@@ goodbye world @@@@@@@@
UNIX Shell
echo "Goodbye, World!" >&2
C Shell
echo "Goodbye, World!" >/dev/stderr
This requires /dev/stderr
, a device node from BSD
and some other Unix clones.
This command works with both Bourne Shell and C Shell.
Ursa
out "goodbye, world!" endl console.err
VBA
Sub StandardError()
Debug.Print "Goodbye World!"
End Sub
VBScript
Must work in cscript.exe
WScript.StdErr.WriteLine "Goodbye, World!"
Verbexx
@STDERR "Goodbye, World!\n";
Visual Basic .NET
Module Module1
Sub Main()
Console.Error.WriteLine("Goodbye, World!")
End Sub
End Module
WDTE
io.writeln io.stderr 'Goodbye, World!';
Wren
Fiber.abort("Goodbye, World!")
X86 Assembly
This is known to work on Linux, it may or may not work on other Unix-like systems
Note that it is only 2 characters different from the Assembly example on User Output - text
Prints "Goodbye, World!" to stderr (and there is probably an even simpler version):
section .data
msg db 'Goodbye, World!', 0AH
len equ $-msg
section .text
global _start
_start: mov edx, len
mov ecx, msg
mov ebx, 2
mov eax, 4
int 80h
mov ebx, 1
mov eax, 1
int 80h
XLISP
(DISPLAY "Goodbye, World!" *ERROR-OUTPUT*)
XPL0
The terms "standard output" and "standard error" are not used, but it's trivial to send messages to a variety of devices by specifying their numbers. Normally messages are displayed on the text console, which is device 0. Instead, this example sends the message to the (first) printer, which is device 2.
code Text=12;
Text(2, "Goodbye, World!")
Yabasic
error "Goodbye World!"
Zig
const std = @import("std");
pub fn main() !void {
try std.io.getStdErr().writer().writeAll("Goodbye, World!\n");
// debug messages are also printed to stderr
//std.debug.print("Goodbye, World!\n");
}
zkl
File.stderr.writeln("Goodbye, World!")
- Programming Tasks
- Basic language learning
- Selection/Short Circuit/Console Program Basics
- Streams
- Applesoft BASIC/Omit
- Bc/Omit
- Brainf***/Omit
- Dc/Omit
- GUISS/Omit
- Integer BASIC/Omit
- Jack/Omit
- SQL PL/Omit
- TI-83 BASIC/Omit
- TI-89 BASIC/Omit
- Unlambda/Omit
- 11l
- 4DOS Batch
- AArch64 Assembly
- Ada
- Agena
- Aime
- ALGOL 68
- Argile
- ARM Assembly
- Arturo
- ATS
- AutoHotkey
- AutoIt
- Avail
- AWK
- BASIC
- BaCon
- BASIC256
- ZX Spectrum Basic
- Batch File
- BBC BASIC
- Blade
- C
- C sharp
- C++
- Clojure
- CLU
- CMake
- COBOL
- CoffeeScript
- Common Lisp
- D
- Tango
- Dart
- Delphi
- Dylan.NET
- Déjà Vu
- E
- Elixir
- Emacs Lisp
- Erlang
- Euphoria
- F Sharp
- Factor
- Fantom
- Forth
- Fortran
- FreeBASIC
- Frink
- Genie
- Go
- Groovy
- Haskell
- Huginn
- Icon
- Unicon
- J
- Java
- JavaScript
- Jq
- Julia
- Kotlin
- Langur
- Lasso
- Lingo
- CommandLine Xtra
- Shell Xtra
- LLVM
- Logtalk
- Lua
- M4
- MANOOL
- Maple
- Mathematica
- Wolfram Language
- MATLAB
- Octave
- Mercury
- Metafont
- ML/I
- Modula-2
- Modula-3
- N/t/roff
- Neko
- Nemerle
- NetRexx
- Nim
- Oberon-2
- Objective-C
- OCaml
- Oforth
- Ol
- OoRexx
- Oz
- PARI/GP
- Pascal
- Perl
- Phix
- PHP
- Picat
- PicoLisp
- Pike
- PL/I
- PostScript
- PowerBASIC
- PowerShell
- PureBasic
- Python
- R
- Ra
- Racket
- Raku
- Retro
- REXX
- Ring
- Ruby
- Run BASIC
- Rust
- S-lang
- Salmon
- Sather
- Scala
- Console
- Scheme
- Scilab
- Sed
- Seed7
- Sidef
- Slate
- Smalltalk
- SNOBOL4
- Standard ML
- Swift
- Tcl
- Transact-SQL
- True BASIC
- TUSCRIPT
- UNIX Shell
- C Shell
- Ursa
- VBA
- VBScript
- Verbexx
- Visual Basic .NET
- WDTE
- Wren
- X86 Assembly
- XLISP
- XPL0
- Yabasic
- Zig
- Zkl
- Pages with too many expensive parser function calls