[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: thesis: guixsd should provide /usr/bin/env
From: |
宋文武 |
Subject: |
Re: thesis: guixsd should provide /usr/bin/env |
Date: |
Wed, 17 Feb 2016 15:31:42 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
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:
--8<---------------cut here---------------start------------->8---
$ 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
--8<---------------cut here---------------end--------------->8---
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 :-)
- Re: thesis: guixsd should provide /usr/bin/env,
宋文武 <=