From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757810AbcFAIE6 (ORCPT ); Wed, 1 Jun 2016 04:04:58 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:37474 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757792AbcFAIEy (ORCPT ); Wed, 1 Jun 2016 04:04:54 -0400 User-Agent: K-9 Mail for Android In-Reply-To: <87lh2pj0gi.fsf@gmail.com> References: <87lh2pj0gi.fsf@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Subject: Re: script relative shebang From: Boris Date: Wed, 01 Jun 2016 09:00:10 +0100 To: Nicolai Stange CC: linux-kernel@vger.kernel.org Message-ID: <1A095838-A4DA-4215-8AB7-6ACC92802F0D@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nicolai, Yes, I think this is too ugly: #!/usr/bin/gawk {exit system("/bin/sh -c 'exec \"$(dirname \"$0\")\"/subdir/catself \"$0\"' " FILENAME);} Imagine you have that feature in your kernel would you rather use: #!{dirname}/subdir/catself You second advice involves changing root fs which is not desirable in copy-deployment apps (bring all the dependencies) This more about making kernel "user" friendly. Thank you. On 1 June 2016 00:02:05 BST, Nicolai Stange wrote: >Hi Boris, > >Boris Rybalkin writes: > >> I would like to know if any changes to parsing '#!' script header >line >> are accepted in particular having ability to run interpreter from >> relative to the script path? >> >> Something like: >> >> #!{dirname}/python/bin/python >> >> Where {dirname} is a special keyword replaced with dirname of a >script. > >Just for the record, this can already be done without any help from the >kernel: > >Assuming the following demonstration directory layout > > /subdir/catself > /relshebang > >where catself.sh is your "interpreter": > > #!/bin/sh > tail -n +2 $1 > >and relshebang is your script file invoking the toy interpreter from >its >shebang as follows: > >#!/usr/bin/gawk {exit system("/bin/sh -c 'exec \"$(dirname >\"$0\")\"/subdir/catself \"$0\"' " FILENAME);} > Hello world. > > >You don't necessarily need to use gawk here, anything being able to do >system() and taking some code snippet from its first argument will >certainly work. > >If this is too ugly, you could also write your own wrapper a la >/usr/bin/env and install that at some central location. > > >Best, > >Nicolai -- Sent from my Android device with K-9 Mail. Please excuse my brevity.