[pacman-dev] configurable shell for install scripts
Hi, I thought I'd run this past people on this list before I spent the two weeks that this would take me to figure out how to implement it! This is motivated by experience packaging for Arch. Install scriptlets are written assuming /bin/sh is bash, which is true on a default system. But some people want to change their /bin/sh to (e.g.) dash. As pacman uses the default shell (as given by /bin/sh) to run install scriptlets, pointing /bin/sh at dash may cause failures when bash specific features are used. So I thought, why not manually specify the shell for install scriptlets in pacman.conf. Something like "INSTALL_SHELL=/bin/sh" by default. Then _alpm_runscriptlet would call something like "<shell> -c ". <scriptlet path> && <function>" (which works for bash, dash, zsh, pdksh). Comments? Allan
On Sun, 28 Mar 2010 21:44:28 +1000 Allan McRae <allan@archlinux.org> wrote:
Hi,
I thought I'd run this past people on this list before I spent the two weeks that this would take me to figure out how to implement it!
This is motivated by experience packaging for Arch. Install scriptlets are written assuming /bin/sh is bash, which is true on a default system. But some people want to change their /bin/sh to (e.g.) dash. As pacman uses the default shell (as given by /bin/sh) to run install scriptlets, pointing /bin/sh at dash may cause failures when bash specific features are used.
So I thought, why not manually specify the shell for install scriptlets in pacman.conf. Something like "INSTALL_SHELL=/bin/sh" by default. Then _alpm_runscriptlet would call something like "<shell> -c ". <scriptlet path> && <function>" (which works for bash, dash, zsh, pdksh).
Comments?
Allan
Hi Allan, can't we use shebangs instead of inventing our own which-shell-to-use implementation? (#!/bin/sh, #!/bin/bash, ..) 2 other notes: 1) do we actually _need_ bashims? are install scripts too complex to be done in just posix sh? 2) I think we should make /bin/sh a posix sh compliant shell. (ie. dash. yes i know strictly speaking there is one variable missing to make it really posix compliant or something, but that's a detail) Dieter
On 28/03/10 22:12, Dieter Plaetinck wrote:
On Sun, 28 Mar 2010 21:44:28 +1000 Allan McRae<allan@archlinux.org> wrote:
Hi,
I thought I'd run this past people on this list before I spent the two weeks that this would take me to figure out how to implement it!
This is motivated by experience packaging for Arch. Install scriptlets are written assuming /bin/sh is bash, which is true on a default system. But some people want to change their /bin/sh to (e.g.) dash. As pacman uses the default shell (as given by /bin/sh) to run install scriptlets, pointing /bin/sh at dash may cause failures when bash specific features are used.
So I thought, why not manually specify the shell for install scriptlets in pacman.conf. Something like "INSTALL_SHELL=/bin/sh" by default. Then _alpm_runscriptlet would call something like "<shell> -c ".<scriptlet path> && <function>" (which works for bash, dash, zsh, pdksh).
Comments?
Allan
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. Allan
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 '^#!/.*$' -- Florian Pritz -- {flo,bluewind}@server-speed.net
On Sun, Mar 28, 2010 at 8:18 AM, Florian Pritz <bluewind@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); .... }
On 29/03/10 05:03, Aaron Griffin wrote:
On Sun, Mar 28, 2010 at 8:18 AM, Florian Pritz <bluewind@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); .... }
I actually like that approach better that defining a default shell. I will look into implementing it. Allan
On Mon, Mar 29, 2010 at 12:48 AM, Allan McRae <allan@archlinux.org> wrote:
On 29/03/10 05:03, Aaron Griffin wrote:
On Sun, Mar 28, 2010 at 8:18 AM, Florian Pritz <bluewind@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); .... }
I actually like that approach better that defining a default shell. I will look into implementing it.
Did this ever get turned into a feature request at least so it doesn't get lost? -Dan
participants (5)
-
Aaron Griffin
-
Allan McRae
-
Dan McGee
-
Dieter Plaetinck
-
Florian Pritz