Hello world/Standard error: Difference between revisions
m
syntax highlighting fixup automation
(Blade) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 31:
{{trans|Python}}
<
=={{header|4DOS Batch}}==
<syntaxhighlight lang
=={{header|AArch64 Assembly}}==
<
.equ SVC_WRITE, 64
.equ SVC_EXIT, 93
Line 57:
svc #0 // exit(0);
msg: .ascii "Goodbye World!\n"</
=={{header|Ada}}==
<
procedure Goodbye_World is
begin
Put_Line (Standard_Error, "Goodbye, World!");
end Goodbye_World;</
=={{header|Agena}}==
<
=={{header|Aime}}==
<
=={{header|ALGOL 68}}==
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.}}
<
put(stand error, ("Goodbye, World!", new line))
)</
{{out}}
<pre>
Line 91:
=={{header|Argile}}==
<
eprint "Goodbye, World!"</
or
<
eprintf "Goodbye, World!\n"</
or
<
fprintf stderr "Goodbye, World!\n"</
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi}}
<syntaxhighlight lang="arm assembly">
/* ARM assembly Raspberry PI */
/* program hellowordLP.s */
Line 124:
iAdrMessage: .int szMessage
</syntaxhighlight>
=={{header|Arturo}}==
<
=={{header|ATS}}==
<
=={{header|AutoHotkey}}==
requires [http://github.com/tinku99/ahkdll/tree/master AutoHotkey_N]
implementation.
<
FileAppend, Goodbye`, World!, stderr ; requires AutoHotkey_N</
Or with the current AutoHotkey_L:
{{works with|AutoHotkey_L}}
(documentation on this behavior: http://www.autohotkey.net/~Lexikos/AutoHotkey_L/docs/commands/FileAppend.htm)
<
=={{header|AutoIt}}==
<
=={{header|Avail}}==
<
=={{header|AWK}}==
Line 153:
pipe it through a shell command:
<
print "Goodbye, World!"| "cat 1>&2"
}</
Or write to /dev/stderr:
Line 162:
{{works with|mawk}}
{{works with|nawk}}
<
print "Goodbye, World!" > "/dev/stderr"
}</
With ''gawk'', ''mawk'' and ''nawk'': a special feature
Line 179:
=={{header|BASIC}}==
{{works with|QBasic}}
<
ON ERROR GOTO ManejoErrores
ERROR 99
Line 188:
PRINT "Googbye World!"
RESUME
</syntaxhighlight>
==={{header|BaCon}}===
<
==={{header|BASIC256}}===
<syntaxhighlight lang="basic256">
onerror errortrap
throwerror 99
Line 203:
print "Goodbye World!"
return
</syntaxhighlight>
==={{header|ZX Spectrum Basic}}===
Line 209:
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
</syntaxhighlight>
=={{header|Batch File}}==
<
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.
Line 222:
{{works with|BBC BASIC for Windows}}
The program must be compiled as a console application for this to work.
<
SYS "GetStdHandle", STD_ERROR_HANDLE TO @hfile%(1)
PRINT #13, "Goodbye, World!"
QUIT</
=={{header|Blade}}==
<
io.stderr.write('Goodbye, World!')</
=={{header|C}}==
Unlike puts(), fputs() does not append a terminal newline.
<
int main()
Line 241:
return 0;
}</
=={{header|C sharp|C#}}==
<
{
static void Main(string[] args)
Line 250:
Console.Error.WriteLine("Goodbye, World!");
}
}</
=={{header|C++}}==
<
int main() {
std::cerr << "Goodbye, World!\n";
}</
=={{header|Clojure}}==
<
(println "Goodbye, world!"))</
=={{header|CLU}}==
<
stream$putl(stream$error_output(), "Goodbye, World!")
end start_up</
=={{header|CMake}}==
Most messages go to standard error.
<
The message cannot be a keyword; <code>message("STATUS")</code> never prints "STATUS", but <code>message("" "STATUS")</code> does work.
Line 279:
{{works with|OpenCOBOL}}
<
procedure division.
display "Goodbye, world!" upon syserr.
stop run.</
=={{header|CoffeeScript}}==
{{trans|JavaScript}}
{{works with|Node.js}}
<
=={{header|Common Lisp}}==
<
=={{header|D}}==
<
void main () {
stderr.writeln("Goodbye, World!");
}</
===Alternative Version===
{{libheader|tango}}
<
void main () {
Stderr("Goodbye, World!").newline;
}</
=={{header|Dart}}==
<
void main() {
stderr.writeln('Goodbye, World!');
}</
=={{header|Delphi}}==
<
{$APPTYPE CONSOLE}
Line 321:
begin
WriteLn(ErrOutput, 'Goodbye, World!');
end.</
=={{header|Dylan.NET}}==
Line 332:
{{works with|.NET|4.5}}
One Line version:
<
Goodbye World Program:
<syntaxhighlight lang="dylan.net">
//compile using the new dylan.NET v, 11.5.1.2 or later
//use mono to run the compiler
Line 351:
end class
</syntaxhighlight>
=={{header|Déjà Vu}}==
<
=={{header|E}}==
<
=={{header|Elixir}}==
<
=={{header|Emacs Lisp}}==
Line 367:
In batch mode, <code>message</code> actually prints to standard error:
<
For greater control, <code>princ</code> can be used with a special printing function:
<
=={{header|Erlang}}==
<
=={{header|Euphoria}}==
<
=={{header|F_Sharp|F#}}==
<
or you can use the .Net classes
<
=={{header|Factor}}==
Start Factor in a terminal for this:
<
=={{header|Fantom}}==
<
class Main
{
Line 398:
}
}
</syntaxhighlight>
=={{header|Forth}}==
{{works with|GNU Forth}}
<
stderr to outfile-id
." Goodbye, World!" cr
to outfile-id</
=={{header|Fortran}}==
Line 414:
which defines the parameter ERROR_UNIT.
<
! Fortran 2003
use iso_fortran_env
Line 422:
write (ERROR_UNIT, *) "Goodbye, World!"
end program StdErr</
=={{header|FreeBASIC}}==
<
Open Err As #1
Print #1, "Goodbye World!"
Close #1
Sleep</
=={{header|Frink}}==
<
staticJava["java.lang.System","err"].println["Goodbye, World!"]
</syntaxhighlight>
=={{header|Genie}}==
<
/*
Hello, to Standard error, in Genie
Line 445:
init
stderr.printf("%s\n", "Goodbye, World!")</
{{out}}
Line 454:
=={{header|Go}}==
Built in println now goes to stderr.
<
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
<
import ("fmt"; "os")
func main() { fmt.Fprintln(os.Stderr, "Goodbye, World!") }</
=={{header|Groovy}}==
<
=={{header|Haskell}}==
<
main = hPutStrLn stderr "Goodbye, World!"</
=={{header|Huginn}}==
<
exec huginn --no-argv -E "${0}" "${@}"
#! huginn
Line 478:
os.stderr().write( "Goodbye, World!\n" );
return ( 0 );
}</
=={{header|Icon}} and {{header|Unicon}}==
<
write(&errout, "Goodbye World" )
end</
=={{header|J}}==
<
stderr 'Goodbye, World!'</
=={{header|Java}}==
<
public static void main(String[] args){
System.err.println("Goodbye, World!");
}
}</
=={{header|JavaScript}}==
{{works with|JScript}} and only with <code>cscript.exe</code>
<
{{works with|Node.js}}
<
{{works with|Firefox}}
<
OR
<
=={{header|jq}}==
<
`stderr` copies its input to STDERR before passing it along the pipeline, and hence the occurrence of `empty` above.
=={{header|Julia}}==
<
=={{header|Kotlin}}==
<
System.err.println("Goodbye, World!")
}</
=={{header|langur}}==
<
=={{header|Lasso}}==
<
file_stderr->writeBytes(#s->asBytes)
}
stderr('Goodbye, World!')</
=={{header|Lingo}}==
*Windows:
{{libheader|CommandLine Xtra}}
<
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:
{{libheader|Shell Xtra}}
<
-- print to standard error
Line 549:
-- print to system.log (shown in realtime e.g. in Konsole.app)
sx.shell_cmd("logger Goodbye, World!")</
=={{header|LLVM}}==
<
; 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.
Line 576:
;-- exit
ret i32 0
}</
{{out}}
<pre>Goodbye, world!</pre>
Line 582:
=={{header|Logtalk}}==
The stream alias "user_error" can be used to print to the "standard error" stream.
<
:- object(error_message).
Line 590:
:- end_object.
</syntaxhighlight>
=={{header|Lua}}==
<
=={{header|m4}}==
<
')dnl</
=={{header|MANOOL}}==
<
=={{header|Maple}}==
<syntaxhighlight lang="maple">
error "Goodbye World"
</syntaxhighlight>
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<
=={{header|MATLAB}} / {{header|Octave}}==
This prints to standard error, and continues execution
<
This will not stop further execution, if called from within a script or function.
<syntaxhighlight lang
=={{header|Mercury}}==
<syntaxhighlight lang="text">
:- module hello_error.
:- interface.
Line 629:
io.stderr_stream(Stderr, !IO),
io.write_string(Stderr, "Goodbye, World!\n", !IO).
</syntaxhighlight>
=={{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).
<
message "...going on..."; % if the user decides to go on and not to stop
% the program because of the error.</
=={{header|ML/I}}==
<
MCNOTE Goodbye, World!</
=={{header|Modula-2}}==
<
IMPORT StdError;
Line 649:
StdError.WriteString('Goodbye, World!');
StdError.WriteLn
END HelloErr.</
=={{header|Modula-3}}==
<
IMPORT Wr, Stdio;
Line 658:
BEGIN
Wr.PutText(Stdio.stderr, "Goodbye, World!\n");
END Stderr.</
=={{header|N/t/roff}}==
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.
<
.tm Goodbye, World!
</syntaxhighlight>
=={{header|Neko}}==
<syntaxhighlight lang="actionscript">/**
Hello world, to standard error, in Neko
Tectonics:
Line 682:
var stderr = $loader.loadprim("std@file_stderr", 0)();
file_write(stderr, "Goodbye, World!\n", 0, 16);</
{{out}}
Line 692:
=={{header|Nemerle}}==
<
=={{header|NetRexx}}==
<
options replace format comments java crossref savelog symbols binary
System.err.println("Goodbye, World!")
</syntaxhighlight>
=={{header|Nim}}==
<
=={{header|Oberon-2}}==
Oxford Oberon-2
<
MODULE HelloErr;
IMPORT Err;
Line 713:
Err.String("Goodbye, World!");Err.Ln
END HelloErr.
</syntaxhighlight>
{{out}}
<pre>
Line 727:
is an NSString object, and it also prepends a timestamp.
<
int main()
Line 735:
NSLog(@"Goodbye, World!");
return 0;
}</
=={{header|OCaml}}==
<
Printf.eprintf "Goodbye, World!\n"; (* this is how you would use printf with stderr *)</
we can also use the ''out_channel'' '''stderr''':
<
Printf.fprintf stderr "Goodbye, World!\n";</
finally the [http://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html Unix] module also provides unbuffered write functions:
<
ignore(Unix.write Unix.stderr msg 0 (String.length msg)) ;;</
=={{header|Octave}}==
<
=={{header|Oforth}}==
<
=={{header|Ol}}==
<
(print-to stderr "Goodbye, World!")
</syntaxhighlight>
=={{header|ooRexx}}==
ooRexx provides a .error object that writes output to the standard error stream.
<
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.
<
or in 'Classic REXX style'
<
* 07.07.2014 Walter Pachl
* 12.07.2014 WP see Discussion where redirection from within the program is shown
Line 777:
Call lineout ,'Hello, world!'
Say 'and this is the error output:'
'type err.txt' </
=={{header|Oz}}==
<
import Application System
define
{System.showError "Goodbye, World!"}
{Application.exit 0}
end</
=={{header|PARI/GP}}==
<
=={{header|Pascal}}==
{{Works with|Free Pascal}}
<
begin
writeln(StdErr, 'Goodbye, World!');
end.</
=={{header|Perl}}==
<
Or:
<
=={{header|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>
<!--</
=={{header|PHP}}==
<
or
<
=={{header|Picat}}==
<
=={{header|PicoLisp}}==
<
=={{header|Pike}}==
<
=={{header|PL/I}}==
<
=={{header|PostScript}}==
<
(Goodbye, World!
) writestring
closefile</
=={{header|PowerBASIC}}==
{{works with|PowerBASIC Console Compiler}}
<
=={{header|PowerShell}}==
Line 843:
standard Write-Error cmdlet is mainly for sending annotated error messages
to the host:
<
Note that this outputs more than just the message,
because behind the scenes it is an uncaught exception:
Line 850:
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException</pre>
To accurately reproduce the behavior of other languages one has to resort to .NET in this case:
<
=={{header|PureBasic}}==
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).
<
=={{header|Python}}==
{{works with|Python|2.x}}
<
print >> sys.stderr, "Goodbye, World!"</
{{works with|Python|3.x}}
<
print("Goodbye, World!", file=sys.stderr)</
Works with either:
<
sys.stderr.write("Goodbye, World!\n")</
=={{header|R}}==
<
=={{header|Ra}}==
<syntaxhighlight lang="ra">
class HelloWorld
**Prints "Goodbye, World!" to standard error**
Line 887:
print to Console.error made !, "Goodbye, World!"
</syntaxhighlight>
=={{header|Racket}}==
<syntaxhighlight lang="racket">
(eprintf "Goodbye, World!\n")
</syntaxhighlight>
=={{header|Raku}}==
(formerly Perl 6)
<syntaxhighlight lang="raku"
=={{header|Retro}}==
<
=={{header|REXX}}==
Line 908:
<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'''.
<
===version 2===
Same as above, but uses a different style and also invokes '''charout''' instead of '''lineout'''.
<
call charout 'STDERR', msgText</
===version 3===
This works on Windows 7 and ooRexx and REGINA
<
* 07.07.2014 Walter Pachl
* enter the appropriate command shown in a command prompt.
Line 930:
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!'</
=={{header|Ring}}==
<
=={{header|Ruby}}==
<
The following also works, unless you have disabled warnings (ruby command line option "-W0" or set <code>$VERBOSE=nil</code>)
<
=={{header|Run BASIC}}==
<
window.open('','error_msg','');
document.write('Goodbye, World!');
</script>""</
Run Basic runs in a browser.
This opens a new browser window,
Line 957:
=={{header|Rust}}==
<
eprintln!("Hello, {}!", "world");
}</
or
<
use ::std::io::Write;
let (stderr, errmsg) = (&mut ::std::io::stderr(), "Error writing to stderr");
Line 968:
let (goodbye, world) = ("Goodbye", "world");
writeln!(stderr, "{}, {}!", goodbye, world).expect(errmsg);
}</
or
<
use std::io::{self, Write};
Line 979:
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!
}</
=={{header|S-lang}}==
<
=={{header|Salmon}}==
<syntaxhighlight lang="salmon">
standard_error.print("Goodbye, World!\n");
</syntaxhighlight>
or
<syntaxhighlight lang="salmon">
include "short.salm";
stderr.print("Goodbye, World!\n");
</syntaxhighlight>
or
<syntaxhighlight lang="salmon">
include "shorter.salm";
err.print("Goodbye, World!\n");
</syntaxhighlight>
or
<syntaxhighlight lang="salmon">
include "shorter.salm";
se.print("Goodbye, World!\n");
</syntaxhighlight>
=={{header|Sather}}==
<
main is
#ERR + "Hello World!\n";
end;
end;</
=={{header|Scala}}==
Line 1,022:
===Ad hoc REPL solution===
Ad hoc solution as [http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop REPL] script:
<
===Via Java runtime===
This is a call to the Java run-time library. '''Not recommendated'''.
<
===Via Scala Console API===
This is a call to the Scala API. '''Recommendated'''.
<
===Short term deviation to err===
<
===Long term deviation to err===
<
Console.setOut(Console.err)
println ("Out deviated")
Console.setOut(Console.out) // Reset to normal</
=={{header|Scheme}}==
<
=={{header|Scilab}}==
<
=={{header|sed}}==
Requires <tt>/dev/stderr</tt>
<
1 {
s/.*/Goodbye, World!/w /dev/stderr
}</
This program requires at least 1 line of input.
Line 1,061:
{{out|Test output}}
<
Goodbye, World!</
=={{header|Seed7}}==
<
const proc: main is func
begin
writeln(STD_ERR, "Goodbye, World!");
end func;</
=={{header|Sidef}}==
<
=={{header|Slate}}==
<
=={{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.
<
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:
<
will work on all, and is the preferred way to do this.
Line 1,090:
The above tells the stream to write a string;
you can also tell the string to print itself onto some stream:
<
Both have the same effect.
=={{header|SNOBOL4}}==
<
output = "Normal text"
end</
=={{header|Standard ML}}==
<
=={{header|Swift}}==
<
let out = NSOutputStream(toFileAtPath: "/dev/stderr", append: true)
Line 1,112:
if let bytes = success {
println("\nWrote \(bytes) bytes")
}</
{{out}}
<pre>
Line 1,120:
=={{header|Tcl}}==
<
=={{header|Transact-SQL}}==
<
=={{header|True BASIC}}==
<
CAUSE error 1, "Goodbye World!"
END
</syntaxhighlight>
=={{header|TUSCRIPT}}==
<
$$ MODE TUSCRIPT
PRINT/ERROR "hello world"
text="goodbye world"
PRINT/ERROR text
</syntaxhighlight>
{{out}}
<pre>
Line 1,146:
=={{header|UNIX Shell}}==
{{works with|Bourne Shell}}
<
==={{header|C Shell}}===
<
This requires <code>/dev/stderr</code>, a device node from [[BSD]]
Line 1,156:
=={{header|Ursa}}==
<
=={{header|VBA}}==
<syntaxhighlight lang="vb">
Sub StandardError()
Debug.Print "Goodbye World!"
End Sub
</syntaxhighlight>
=={{header|VBScript}}==
Must work in cscript.exe
<
=={{header|Verbexx}}==
<
=={{header|Visual Basic .NET}}==
<
Sub Main()
Line 1,179:
End Sub
End Module</
=={{header|WDTE}}==
<
=={{header|Wren}}==
<
=={{header|X86 Assembly}}==
Line 1,195:
Prints "Goodbye, World!" to stderr (and there is probably an even simpler version):
<
msg db 'Goodbye, World!', 0AH
len equ $-msg
Line 1,209:
mov ebx, 1
mov eax, 1
int 80h</
=={{header|XLISP}}==
<
=={{header|XPL0}}==
Line 1,222:
which is device 2.
<
Text(2, "Goodbye, World!")</
=={{header|Yabasic}}==
<
error "Goodbye World!"
</syntaxhighlight>
=={{header|Zig}}==
<
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");
}</
=={{header|zkl}}==
<
|