guix-devel
[Top][All Lists]
Advanced

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

Re: thesis: guixsd should provide /usr/bin/env


From: Ludovic Courtès
Subject: Re: thesis: guixsd should provide /usr/bin/env
Date: Mon, 29 Feb 2016 10:46:31 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

address@hidden (宋文武) skribis:

> Someone (sorry, I forget who) mentioned in #guix that we can use
> binfmt_misc to handle the shebang.
>
> I tried coding it in C, and it seems to working fine.
> Here it is: <https://github.com/iyzsong/duang>.
>
> Try it with care:
> $ sudo mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc
> $ git clone https://github.com/iyzsong/duang.git
> $ cd duang
> $ make
> $ sudo make install
> $ sudo make register
>
> This will install the handler into `/libexec/@', and register it in
> `/proc/sys/fs/binfmt_misc/duang'.  With it activated, intepreter in
> the shebang doesn't need to be absolute path, and can handle multiple
> arguments, eg: `#!emacs -Q --script'.  And when the interpreter in
> absolute path is not exist, it will fallback to be searched in the PATH,
> so `#!/usr/bin/perl -w' equals to `#!perl -w'.  On GuixSD, this means
> if we remove the `/bin/sh' symlink, the sh-scripts will fallbacked to
> use `sh' in PATH, so we can remove /bin.
>
> I dunno if it's a good idea though :-)

Nice hack!  :-)

The downside is that it requires scripts to use this feature, and
requires users to have Duang installed and registered.

I think what would be nice to handle the use case that Andy raised is a
binfmt_misc handler that simply handles /usr/bin/env (and possibly
/bin/sh), and to add an ‘operating-system’ knob to enable it.  That way,
third-party scripts would work automagically.

Thanks,
Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]