dub icon indicating copy to clipboard operation
dub copied to clipboard

Multiline shebang is not supported

Open rikkimax opened this issue 2 years ago • 3 comments

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

rikkimax avatar Oct 23 '23 14:10 rikkimax

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.

nekowinston avatar Oct 23 '23 14:10 nekowinston

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

Geod24 avatar Dec 28 '23 16:12 Geod24

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: @.***>

rikkimax avatar Dec 28 '23 18:12 rikkimax