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

shebang support for qjs #243

Closed
maroziza opened this issue Feb 21, 2024 · 3 comments
Closed

shebang support for qjs #243

maroziza opened this issue Feb 21, 2024 · 3 comments

Comments

@maroziza
Copy link

maroziza commented Feb 21, 2024

I'm going to use qjs as system script interpreter. it works perfectly good, i added ioctl call as an shared library and qjs can configure all the system now but i have a problem running scripts with eXecutable status,
So adding #!/bin/qjs as the first line of the script renders file unrunnable.
I think there should be an option to run it as script interpreter and skip the first line.

For Node.js it can (but often doesn’t) look like this:

#!/usr/bin/node

Node.js will happily ignore this as a comment only if it is the very first line of the file (it won’t work even if there’s an empty line or //comment line before it). Browsers ignore it too (Chrome 74+, FF 67+).

I want also to note, that shebang is limited to 127 chars on 99.9% of systems due to kernel compile time buffer limit. It's limited in the kernel by BINPRM_BUF_SIZE.

@saghul
Copy link
Contributor

saghul commented Feb 21, 2024

There is code to support that in qjs, what error do you get?

@maroziza
Copy link
Author

test file:

#!/bin/qjs
import * as std from "std";
import * as os from "os";
console.log("ok");

errors:

$ ./bdf2.js
SyntaxError: expecting '('
    at ./bdf2.js:2

$ qjs bdf2.js
SyntaxError: expecting '('
    at bdf2.js:2

@maroziza
Copy link
Author

thanks, double checked the env and it was older branch of qjs, now it works

GerHobbelt pushed a commit to GerHobbelt/quickjs that referenced this issue May 6, 2024
The shell script runs the tests and diffs stdout against v8.txt.
Lines added/removed means tests were broken/fixed.

Future work is to a) fix failing tests, and b) enable more tests.

A number are disabled for various reasons and mjsunit subdirectories are
currently skipped. Need to decide on a case-by-case basis what is and
isn't relevant to us.

At the moment about 430 tests are run of which approx. 80% pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants