From: Nicolai Stange <nicstange@gmail.com>
To: Boris Rybalkin <ribalkin@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: script relative shebang
Date: Wed, 01 Jun 2016 01:02:05 +0200 [thread overview]
Message-ID: <87lh2pj0gi.fsf@gmail.com> (raw)
In-Reply-To: <CADcVQYsccqYkN9YbC3YXADtZ6MFyoninyeftkMH=K7SZ5CJpoA@mail.gmail.com> (Boris Rybalkin's message of "Tue, 31 May 2016 22:47:52 +0100")
Hi Boris,
Boris Rybalkin <ribalkin@gmail.com> 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
<some_test_dir>/subdir/catself
<some_test_dir>/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
next prev parent reply other threads:[~2016-05-31 23:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-31 21:47 script relative shebang Boris Rybalkin
2016-05-31 23:02 ` Nicolai Stange [this message]
2016-06-01 8:00 ` Boris
2016-06-01 12:12 ` Bernd Petrovitsch
2016-06-01 15:38 ` Austin S. Hemmelgarn
2016-06-02 0:04 ` Boris Rybalkin
2016-06-02 4:19 ` Ken Moffat
2016-06-02 22:41 ` Boris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lh2pj0gi.fsf@gmail.com \
--to=nicstange@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ribalkin@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox