From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: thesis: guixsd should provide /usr/bin/env Date: Mon, 29 Feb 2016 10:46:31 +0100 Message-ID: <878u23kfwo.fsf@gnu.org> References: <874mgmti7b.fsf@igalia.com> <87h9ki9dmz.fsf@gnu.org> <87fv01nb8b.fsf@igalia.com> <87d1v4ixeh.fsf@gnu.org> <87ziy8ll2o.fsf@igalia.com> <87si0ryeqp.fsf@member.fsf.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aaKPV-0005Ws-Ri for guix-devel@gnu.org; Mon, 29 Feb 2016 04:46:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aaKPR-0004tD-RU for guix-devel@gnu.org; Mon, 29 Feb 2016 04:46:37 -0500 In-Reply-To: <87si0ryeqp.fsf@member.fsf.org> (=?utf-8?B?IuWui+aWh+atpiIn?= =?utf-8?B?cw==?= message of "Wed, 17 Feb 2016 15:31:42 +0800") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: =?utf-8?B?5a6L5paH5q2m?= Cc: guix-devel@gnu.org iyzsong@member.fsf.org (=E5=AE=8B=E6=96=87=E6=AD=A6) 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: . > > 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 =E2=80=98operating-system=E2=80=99 knob to enable i= t. That way, third-party scripts would work automagically. Thanks, Ludo=E2=80=99.