Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

livescript binary eats all of argv #569

Closed
appedemic opened this issue Oct 5, 2014 · 4 comments
Closed

livescript binary eats all of argv #569

appedemic opened this issue Oct 5, 2014 · 4 comments
Labels

Comments

@appedemic
Copy link
Contributor

Consider the following node program test.js:

console.log(process.argv);

When I run the program "node test.js hello" it prints:

$ node test.js hello
[ 'node', '/home/derk/test.js', 'hello' ]

LiveScript was behaving like this but with 1.3 it eats all arguments. Consider the following livescript program test.ls:

console.log process.argv

When I run this in 1.3 I get an error message from livescript:

$ lsc test.ls hello
Can't find hallo.ls

It seems as if anything passed to the command line is consumed and processed by lsc.

@gkz gkz added the bug label Oct 5, 2014
appedemic pushed a commit to appedemic/LiveScript that referenced this issue Oct 5, 2014
@appedemic
Copy link
Contributor Author

Not completely right. With this patch the argv contains an extra argument. Livescript.run evaluates the compiled code with the argv as passed to the compiler, making my argv:

$ lsc test.ls hello
[ 'node', '/home/derk/test.ls', 'test.ls', 'hello' ]

I don't think this is the desired result and the behaviour should match node as close as possible?

appedemic pushed a commit to appedemic/LiveScript that referenced this issue Oct 5, 2014
@appedemic
Copy link
Contributor Author

$ lsc test.ls hello
[ 'node', '/home/derk/test.ls', 'hello' ]

behaves as

$ node test.js hello
[ 'node', '/home/derk/test.js', 'hello' ]

@appedemic appedemic mentioned this issue Oct 5, 2014
@gkz gkz closed this as completed in c959444 Oct 7, 2014
@gkz
Copy link
Owner

gkz commented Oct 7, 2014

My fix works for me, check it out and make sure it works for you too, so I can then push out a minor release.

@vzaccaria
Copy link

Maybe I am doing something wrong; I have a script.ls that begins with:

#!/usr/bin/env lsc 

...
here I process a `-w` option from process.argv
...

Before (~1.2), I was using the script like this:

$ ./script.ls -w

With 1.3.1, I have to put -- before the options otherwise they are assumed to be lsc options:

$ ./script.ls -- -w

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants