X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=man%2Fcsharp.1;h=430a160896890929ca709deef67a6085bdd83460;hb=4c144cfacfbfc8b67e78fe6d864329003bf94a93;hp=2f6497d2e90474e334264bcca4b53b5460f0f465;hpb=6c035e225abc36a15501a03f574744824225350b;p=mono.git diff --git a/man/csharp.1 b/man/csharp.1 index 2f6497d2e90..430a1608968 100644 --- a/man/csharp.1 +++ b/man/csharp.1 @@ -2,34 +2,79 @@ .if t .sp .5v .if n .sp .. -.TH csharp 1 "4 September 2008" +.TH csharp 1 "22 March 2017" .SH NAME -csharp, gsharp \- Interactive C# Shell +csharp \- Interactive C# Shell and Scripting .SH SYNOPSIS -.B csharp [--attach PID] [file1 [file2]] -[options] -.P -.B gsharp [file1 [file2]] +.B csharp [--attach PID] [-e EXPRESSION] [file1 [file2]] +[compiler-options] [--|-s script-options] .SH DESCRIPTION The .I csharp -is an interactive C# shell that allows the user to enter and evaluate -C# statements and expressions from the command line. The regular +command is an interactive C# shell and scripting host that allows +the user to enter and evaluate C# statements and expressions from +the command line or execute C# scripts. +The regular .I mcs command line options can be used in this version of the compiler. .PP -The -.I gsharp -command is a GUI version of the C# interpreter that uses Gtk# and -provides an area to attach widgets as well. This version can be -attached to other Gtk# applications in a safe way as it injects itself -into the main loop of a Gtk# application, avoiding any problems -arising from the multi-threaded nature of injecting itself into a -target process. -.PP Files specified in the command line will be loaded and executed as scripts. +.PP +Starting with Mono 2.10, the +.I csharp +command can be used as an interpreter executed by executables flagged +with the Unix execute attribute. To do this, make the first line of +your C# source code look like this: +.PP +.nf + #!/usr/bin/csharp + Console.WriteLine ("Hello, World"); +.fi +.PP +Starting with Mono 5.0, command line arguments may now be passed +to the +.I csharp +command by specifying either the +.I -s +or +.I -- +(script) options. +.PP +The +.I -s +option is ideal for interpreting executable scripts that utilize +shebang syntax (introduced in Mono 2.10). This allows command line +arguments to be passed to and consumed cleanly by the script: +.PP +.nf + #!/usr/bin/csharp -s + foreach (var arg in Args) + Console.WriteLine ($"script argument: {arg}"); +.fi .SH OPTIONS +The commands accept all of the commands that are available to the +.I mcs +command, so you can reference assemblies, specify paths, language +level and so on from the command line. In addition, the following +command line options are supported: +.TP +.I "\-s" SCRIPT_FILE +This option is ideal for authoring executable scripts that utilize +the Unix shebang feature. Unix will implicitly append as an argument +the path of the script to execute. When the executable is invoked, +any arguments then passed to it will be available in the +.I Args +global. Example: +.I "#!/usr/bin/env csharp -s" +.TP +.I "\-\-" +Any arguments that follow will not be passed to the compiler driver, +and instead will be made available in the +.I Args +global. Example: +.I csharp -- a b c +will result in Args = { "a", "b", "c" } in the interactive shell. .TP .I "\-\-attach" This is an advanced option and should only be used if you have a deep @@ -42,6 +87,9 @@ special measures to avoid crashing the target application while using it. For example, you might have to take the proper locks before issuing any commands that might affect the target process state, or sending commands through a method dispatcher. +.TP +.I "\-e" EXPRESSION +This will evaluate the specified C# EXPRESSION and exit .SH OPERATION Once you launch the csharp command, you will be greeted with the interactive prompt: @@ -206,7 +254,7 @@ versions uses the standard Gtk# key bindings. .PP The command set is similar to many other applications (cursor keys) and incorporates some of the Emacs commands for editing as well as a -history mechanism to +history mechanism too. .PP .PP The following keyboard input is supported: @@ -229,7 +277,7 @@ line in the history. .TP .I Down Arrow Key, Control-n Moves forward in the history, replaces the current line with the next -lien in the history. +line in the history. .TP .I Return Executes the current line if the statement or expression is complete, @@ -272,6 +320,15 @@ statements and expressions are executed are static, they can be invoked directly from the shell. These are the available properties and methods: .TP +.I Args +An easy to consume array of any arguments specified after either +.I -s +or +.I -- +on the command line. Ideal for self-executing scripts utilizing the +.I -s +option. +.TP .I void LoadAssembly(string assembly) Loads the given assembly. This is equivalent to passing the compiler the -r: flag with the specified string. @@ -340,9 +397,9 @@ gmcs(1), mcs(1), mdb(1), mono(1), pkg-config(1) .SH BUGS To report bugs in the compiler, you must file them on our bug tracking system, at: -http://www.mono-project.com/Bugs +http://www.mono-project.com/community/bugs/ .SH MAILING LIST -The Mono Mailing lists are listed at http://www.mono-project.com/Mailing_Lists +The Mono Mailing lists are listed at http://www.mono-project.com/community/help/mailing-lists/ .SH MORE INFORMATION The Mono C# compiler was developed by Novell, Inc (http://www.novell.com, http) and is based on the @@ -350,5 +407,5 @@ ECMA C# language standard available here: http://www.ecma.ch/ecma1/STAND/ecma-334.htm .PP The home page for the Mono C# compiler is at -http://www.mono-project.com/CSharp_Compiler information about the -interactive mode for C# is available in http://mono-project.com/CsharpRepl +http://www.mono-project.com/docs/about-mono/languages/csharp/ information about the +interactive mode for C# is available in http://mono-project.com/docs/tools+libraries/tools/repl/