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

Support shebang line (ES14) #24379

Closed
fzn0x opened this issue Jul 1, 2024 · 5 comments
Closed

Support shebang line (ES14) #24379

fzn0x opened this issue Jul 1, 2024 · 5 comments

Comments

@fzn0x
Copy link
Contributor

fzn0x commented Jul 1, 2024

Shebang line caused several packages issue, the reason is Deno couldn't support running with executable script.

Working in other runtimes:

#!/usr/bin/env bun

console.log("Hello, world!");
#!/usr/bin/env node

console.log("Hello, world!");

In Deno:

#!/usr/bin/env deno

console.log("Hello, world!");

You will receive:

$ ./index.js
error: unrecognized subcommand './index.js'

Usage: deno [OPTIONS] [COMMAND]

For more information, try '--help'.
@bartlomieju
Copy link
Member

Deno supports shebangs, see docs for details: https://docs.deno.com/runtime/tutorials/hashbang

@fzn0x
Copy link
Contributor Author

fzn0x commented Jul 1, 2024

Deno supports shebangs, see docs for details: https://docs.deno.com/runtime/tutorials/hashbang

Thanks, could we shorthand #!/usr/bin/env -S deno run --allow-env to #!/usr/bin/env deno ?

@fzn0x
Copy link
Contributor Author

fzn0x commented Jul 1, 2024

After shorthand you could handle more permissions if needed

#!/usr/bin/env deno --allow-net

console.log("Hello, world!");

@bartlomieju
Copy link
Member

After shorthand you could handle more permissions if needed

#!/usr/bin/env deno --allow-net

console.log("Hello, world!");

This doesn't work, you need to use -S to pass argument to the interpreter, so the only shortcut would be the removal of run subcommand from the shebang invocation.

@fzn0x
Copy link
Contributor Author

fzn0x commented Jul 1, 2024

Thanks! noted

@fzn0x fzn0x closed this as completed Jul 1, 2024
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