[Mono-list] csharp REPL scripts

Ian Norton inb at ncipher.com
Sat Mar 5 09:34:33 EST 2011


The original example would try to run the script using the /usr/bin/csharp program, which is not there but in the place miguel gave. env runs the csharp comand and will search $PATH for it. I remembered it from my perl days as this works on windows in cygwin too

Ian

"Steve Lessard" <s_lessard at yahoo.com> wrote:

>Yes, both Miguel's solution and Ian's solution work. I pretty much
>understand why Miguel's solution works. As for Ian's solution I read
>the man page for env but it's not clear as to what env does that makes
>Ian's solution work. Would you care to share a short explanation?
>
>
>  _____
>
>From: Ian Norton <Ian.Norton-Badrul at thales-esecurity.com>
>To: Miguel de Icaza <miguel at novell.com>
>Cc: Steve Lessard <s_lessard at yahoo.com>; Mono
><Mono-list at lists.ximian.com>
>Sent: Fri, March 4, 2011 10:44:28 PM
>Subject: Re: [Mono-list] csharp REPL scripts
>
>Would
>
>#!/usr/bin/env csharp
>
>Work?
>
>Ian
>
>On 5 Mar 2011, at 01:29, "Miguel de Icaza" <
>miguel at novell.com<mailto:miguel at novell.com>> wrote:
>
>> Hello,
>>
>>    Seems to be a problem with the way OSX launches the program, try
>> this instead for the first line:
>>
>> #!/usr/bin/mono
>> /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.0/
>> csharp.exe
>>
>>
>> On Thu, Mar 3, 2011 at 1:10 PM, Steve Lessard <
>s_lessard at yahoo.com<mailto:s_lessard at yahoo.com>>
>> wrote:
>>> I read in the release notes for Mono 2.10
>>> ( http://www.mono-project.com/Release_Notes_Mono_2.10) that "the C#
>>> REPL now
>>> can
>>> be used as a program to run C# scripts in Unix. Your Unix scripts
>>> can now
>>> contain as their first line the #!/usr/bin/csharp line which allows
>>> you to
>>> create C# scripts that can be treated like programs."  The release
>>> notes
>>> give
>>> this very simple demo:
>>>
>>> $ echo '#!/usr/bin/csharp' > demo
>>> $ echo 'System.Console.WriteLine (10+2);' >> demo
>>> $ chmod +x demo
>>> $ ./demo
>>> 12
>>> $
>>>
>>> So I tried it on my machine running 2.10.1, but it always fails
>>> with a
>>> syntax
>>> error. (See below.) Is anyone else able to run this simple demo of
>>> the C#
>>> REPL?
>>> tools$ echo '#!/usr/bin/csharp' > demo
>>> tools$ echo 'System.Console.WriteLine (10+2);' >> demo
>>> tools$ chmod +x demo
>>> tools$ ./demo
>>> ./demo: line 2: syntax error near unexpected token `10+2'
>>> ./demo: line 2: `System.Console.WriteLine (10+2);'
>>> tools$
>>>
>>> -SteveL
>>>
>>>
>>>
>>> $ uname -a
>>> Darwin applejacks 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10
>>> 18:13:17
>>> PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386
>>> $ mono --version
>>> Mono JIT compiler version 2.10.1 (tarball Fri Feb 25 15:56:49 MST
>>> 2011)
>>> Copyright (C) 2002-2011 Novell, Inc and Contributors.
>www.mono-project.com<http://www.mono-project.com>
>>> TLS:          normal
>>> SIGSEGV:      normal
>>> Notification:  Thread + polling
>>> Architecture:  x86
>>> Disabled:      none
>>> Misc:          debugger softdebug
>>> LLVM:          yes(2.9svn-mono)
>>> GC:            Included Boehm (with typed GC)
>>> $ /usr/bin/csharp --version
>>> Mono C# compiler version 4.0.0.0
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Mono-list maillist  - 
>Mono-list at lists.ximian.com<mailto:Mono-list at lists.ximian.com>
>>> http://lists.ximian.com/mailman/listinfo/mono-list
>>>
>>>
>> _______________________________________________
>> Mono-list maillist  - 
>Mono-list at lists.ximian.com<mailto:Mono-list at lists.ximian.com>
>> http://lists.ximian.com/mailman/listinfo/mono-list

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.


More information about the Mono-list mailing list