pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg_alternatives wrapper program doesn't work in script shebang



Hello!

I can't use a pkg_alternatives wrapper program in a script shebang.  I
think this is because my OS requires the shebang interpreter to be
a compiled binary, not another shebang program (which the wrapper
program is).  Is this the intended behavior for pkg_alternatives wrapper
programs?

I'm using pkgsrc-2015Q4 on OS X El Capitan (Darwin 15.3.0).  I also
confirmed that NetBSD 6.1_STABLE (amd64) has the same requirement that
the shebang interpreter must be a compiled binary, not another shebang
program.

For example, on OS X I have a pkg_alternatives wrapper program for ruby
at /opt/pkg/bin/ruby which is a shell script:

===
$ head -n 1 /opt/pkg/bin/ruby
#!/bin/sh
===

Using this wrapper program as the shebang interpreter in a script
doesn't work:

===
$ cat hello-world
#!/opt/pkg/bin/ruby

puts 'hello, world'
$ ./hello-world
./hello-world: line 4: puts: command not found
===

A workaround is to use the env program in the script to call the wrapper
program:

===
$ cat hello-world
#!/usr/bin/env /opt/pkg/bin/ruby

puts 'hello, world'
$ ./hello-world
hello, world
===

Obviously, I could just always use this workaround, but I wish I didn't
have to.

One solution would be to convert the pkg_alternatives wrapper program
into a C program that is compiled into a binary.  Or, it could be a
really simple C program that just execs the existing wrapper script.

Thoughts?

Thanks!

Lewis


Home | Main Index | Thread Index | Old Index