[pacman-dev] configurable shell for install scripts

Aaron Griffin aaronmgriffin at gmail.com
Sun Mar 28 21:03:26 CEST 2010


On Sun, Mar 28, 2010 at 8:18 AM, Florian Pritz
<bluewind at server-speed.net> wrote:
> On 28.03.2010 14:27, Allan McRae wrote:
>> On 28/03/10 22:12, Dieter Plaetinck wrote:
>>> Hi Allan,
>>>
>>> can't we use shebangs instead of inventing our own which-shell-to-use
>>> implementation? (#!/bin/sh, #!/bin/bash, ..)
>>
>> No we can not unless I am missing something.  We need to source the
>> script and run a particular function within that script.
>
> head -n1 installscript | grep '^#!/.*$'

Or:

#define BUFSIZ 1024

int bufsiz = BUFSIZ;
char buffer[BUFSIZ+1];
int fd = open(scriptlet, O_RDONLY);
int bytes = getline(&buffer, &bufsiz, fd);

if(buffer[0] == '#' && buffer[1] == '!') {
    char *shell = strdup(buffer+2);
    ....
}


More information about the pacman-dev mailing list