Open rikkimax opened 11 months ago
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.
@rikkimax : Is there a spec somewhere or is this a Nix-specific feature ? Never seen it used anywhere else.
It is nix specific.
POSIX is single line only if I remember right.
On Fri, Dec 29, 2023, 05:41 Mathias LANG @.***> wrote:
@rikkimax https://github.com/rikkimax : Is there a spec somewhere or is this a Nix-specific feature ? Never seen it used anywhere else.
— Reply to this email directly, view it on GitHub https://github.com/dlang/dub/issues/2708#issuecomment-1871332387, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHSL42KXUGXGDKRAOAUR2TYLWONPAVCNFSM6AAAAAA6ME7A2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZRGMZTEMZYG4 . You are receiving this because you were mentioned.Message ID: @.***>
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.
https://github.com/dlang/dub/blob/2ea883833adf085095b07a7dba8250fb3db79a71/source/dub/dub.d#L507
Related dmd issue: https://issues.dlang.org/show_bug.cgi?id=24194