From mboxrd@z Thu Jan 1 00:00:00 1970 From: iyzsong@member.fsf.org (=?utf-8?B?5a6L5paH5q2m?=) Subject: Re: thesis: guixsd should provide /usr/bin/env Date: Wed, 17 Feb 2016 15:31:42 +0800 Message-ID: <87si0ryeqp.fsf@member.fsf.org> References: <874mgmti7b.fsf@igalia.com> <87h9ki9dmz.fsf@gnu.org> <87fv01nb8b.fsf@igalia.com> <87d1v4ixeh.fsf@gnu.org> <87ziy8ll2o.fsf@igalia.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVwar-0006xG-EP for guix-devel@gnu.org; Wed, 17 Feb 2016 02:32:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVwam-0001gS-Ko for guix-devel@gnu.org; Wed, 17 Feb 2016 02:32:13 -0500 Received: from smtp25.openmailbox.org ([62.4.1.59]:55884) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVwam-0001gG-FA for guix-devel@gnu.org; Wed, 17 Feb 2016 02:32:08 -0500 In-Reply-To: <87ziy8ll2o.fsf@igalia.com> (Andy Wingo's message of "Fri, 20 Nov 2015 15:58:07 +0000") 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: guix-devel@gnu.org 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: --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 :-)