Yelp/dumb-init

Ignore shebang parameters

Closed this issue · 3 comments

Hi all,

I have usual bash file this the shabang:

#!/usr/bin/env bash

See:
https://en.wikipedia.org/wiki/Shebang_(Unix)#Portability

If I replace this line to the:

#!/usr/bin/dumb-init /usr/bin/env bash

dumb-init consider parameters as "one" and writes this error message:

[dumb-init] /usr/bin/env bash: No such file or directory

shebangs may only have one argument, in this case you should be able to just drop /usr/bin/env:

#!/usr/bin/dumb-init bash

echo 'hi!'

As written in your example, the operating system is calling essentially ["/usr/bin/dumb-init", "/usr/bin/env bash"] and we don't have any control over what the OS does :)

Yeah, unfortunately I think this is just a limitation of the way shebangs work. It's the same reason you can have a shebang like #!/bin/bash -eu but not #!/bin/bash -euo pipefail. Every argument in the shebang is passed as argv[1] (argv[2] is always the filename) :(

Is it correct to assume that /usr/bin/dumb-init will anyway resolve bash argument the same way /usr/bin/env would (i.e. the first bash in $PATH)?