On 29/03/10 05:03, Aaron Griffin wrote:
On Sun, Mar 28, 2010 at 8:18 AM, Florian Pritz
<[email protected]>  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);
     ....
}


I actually like that approach better that defining a default shell. I will look into implementing it.

Allan

Reply via email to