Jruby -e?

I am new to JRuby, and when trying my first executions, I ran into an
issue
trying the simple program from the command line. It was my
understanding
that running jruby -e ‘puts “hello”’ on the command line (using Windows)
would print out hello in the console. All I get is an error “:1: -e:2:
unterminated string meets end of file (SyntaxError)”. I can put the
same
code in a .rb file, and it runs fine. Does jruby -e work? Or what am I
doing wrong syntactically or setup-wise that is causing this error?


View this message in context:
http://www.nabble.com/jruby--e--tp26001280p26001280.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Wed, Oct 21, 2009 at 3:27 PM, kwikgoal [email protected] wrote:

I am new to JRuby, and when trying my first executions, I ran into an issue
trying the simple program from the command line. It was my understanding
that running jruby -e ‘puts “hello”’ on the command line (using Windows)
would print out hello in the console. All I get is an error “:1: -e:2:
unterminated string meets end of file (SyntaxError)”. I can put the same
code in a .rb file, and it runs fine. Does jruby -e work? Or what am I
doing wrong syntactically or setup-wise that is causing this error?

on OS X –
ripple:/tmp$ ruby -e ‘puts “hello”’
hello
ripple:/tmp$ jruby -v
jruby 1.3.1 (ruby 1.8.6p287) (2009-06-15 2fd6c3d) (Java HotSpot™
64-Bit Server VM 1.6.0_15) [x86_64-java]
ripple:/tmp$

Dunno if there’s a Windows-specific issue…

HTH,

Hassan S. ------------------------ [email protected]
twitter: @hassan


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

what version of jruby you using?

does it work if you try: jruby -e “puts ‘hello’”

?

Jay

On Wed, Oct 21, 2009 at 7:01 PM, Hassan S.
[email protected] wrote:

on OS X –

Hassan S. ------------------------ [email protected]
twitter: @hassan


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

kwikgoal wrote:

I am new to JRuby, and when trying my first executions, I ran into an
issue trying the simple program from the command line. It was my
understanding that running jruby -e ‘puts “hello”’ on the command line
(using Windows) would print out hello in the console. All I get is an
error “:1: -e:2: unterminated string meets end of file (SyntaxError)”.
I can put the same code in a .rb file, and it runs fine. Does jruby -e
work? Or what am I doing wrong syntactically or setup-wise that is
causing this error?

The single quote is not a quote character in CMD.EXE. Only the double
quote is a quote character. If you want double quotes inside a double
quoted string, you need double double quotes:

jruby -e “puts ““hello”””

What you wrote is interpreted as: evaluate the Ruby expression

'puts

and then execute the file named

hello

Obviously the first one is an illegal program (as the error message
tells
you, it is an unterminated string literal) and the latter one doesn’t
exist.

This has absolutely nothing to do with JRuby, however. It’s just that
all
shells have different syntax, whether that be COMMAND.COM, CMD.EXE,
PowerShell, Bash, TCsh, FiSH, Hotwire-Shell or whatever shell you are
using.

jwm


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi,

Jörg W Mittag’s response provides the background and the reason why -e
‘…’ doesn’t work with JRuby on Windows. JRuby’s Main starter class
sees two arguments [‘puts, and “hello”’]. As a rule of thumb, try
always to use -e with double-quotes at the top level. Inside
double-quotes on might use single-quotes, no problem.

So, this should work fine: jruby -e "puts ‘hello’ "

Interestingly enough, MRI’s ruby.exe does some magic, it seems, and it
actually can handle single quotes. I need to figure out what kind of
tricks they play and whether it is suitable for JRuby at all. Now that
we have the native launcher (jruby.exe) on Windows, there might be
something we could do, this remains to be seen though.

Thanks,
–Vladimir

On Thu, Oct 22, 2009 at 12:27 AM, kwikgoal [email protected] wrote:

View this message in context: http://www.nabble.com/jruby--e--tp26001280p26001280.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

In message
[email protected], Vladimir
Sizikov [email protected] writes

Interestingly enough, MRI’s ruby.exe does some magic, it seems, and it
actually can handle single quotes. I need to figure out what kind of
tricks they play and whether it is suitable for JRuby at all. Now that
we have the native launcher (jruby.exe) on Windows, there might be
something we could do, this remains to be seen though.

In MS-DOS^H^H^H^H^H^H (cough) Windows, I think the whole command line
(after the executable name) gets passed to the program. That will be
after any command line expansion, of course. But it is normally the C
runtime that parses into argc &argv & so loses you the whitespace etc…

Regards

Thanks to all for your responses. They really cleared up how CMD.exe
interprets the command. Using 1.4.0RC2, both: jruby -e “puts ‘hello’”
and:
jruby -e “puts ““hello””” work.

kwikgoal wrote:


View this message in context:
http://www.nabble.com/jruby--e--tp26001280p26009839.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email