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

Multiline shebang is not supported #2708

Open
rikkimax opened this issue Oct 23, 2023 · 3 comments
Open

Multiline shebang is not supported #2708

rikkimax opened this issue Oct 23, 2023 · 3 comments

Comments

@rikkimax
Copy link
Contributor

Multiline shebangs are not currently supported. This could be useful in some software like Nix.

It should be an easy fix in both dmd and dub.

if (file_content.startsWith("#!")) {

Related dmd issue: https://issues.dlang.org/show_bug.cgi?id=24194

@nekowinston
Copy link

Two examples of how this could be used, both don't work at the moment:

#!/usr/bin/env nix-shell
#!nix-shell -i dub -p dub ldc
import std.stdio;

void main()
{
    writeln("Hello, world!");
}
#!/usr/bin/env nix-shell
#!nix-shell -i dub -p dub ldc
/+ dub.sdl:
   name "hello_vibed"
   dependency "vibe-d" version="~>0.9.0"
+/
import vibe.vibe;

void main()
{
    listenHTTP("127.0.0.1:8080", (req, res) {
        res.writeBody("Hello Vibe.d: " ~ req.path);
    });

    runApplication();
}

The double-shebang is enforced by nix-shell

To do this, start the script with multiple shebang (#!) lines.
The first shebang line is always #! /usr/bin/env nix-shell.
The second shebang line declares the script language and the script dependencies.

@Geod24
Copy link
Member

Geod24 commented Dec 28, 2023

@rikkimax : Is there a spec somewhere or is this a Nix-specific feature ? Never seen it used anywhere else.

@rikkimax
Copy link
Contributor Author

rikkimax commented Dec 28, 2023 via email

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

3 participants