[Libguestfs] Shebang sh plugins (was: Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.)

Nir Soffer nsoffer at redhat.com
Fri Nov 22 23:58:02 UTC 2019


On Fri, Nov 22, 2019 at 11:07 PM Richard W.M. Jones <rjones at redhat.com> wrote:
>
> On Fri, Nov 22, 2019 at 02:55:31PM -0600, Eric Blake wrote:
> > Unrelated side topic: in your recent addition of eval.sh, you
> > wondered if we should promote it to a full-blown plugin rather than
> > just an example script.  But reading 'man nbdkit-sh-plugin', there
> > is no mention of turning an executable script into a full-blown
> > plugin via a shebang, the way that python documents it.  [I guess
> > 'man nbdkit' sort of mentions it under Shebang scripts]
>
> I believe it's not possible to do it for sh plugins.
>
> For (eg) python plugins it works like this:
>
>   #!/usr/sbin/nbdkit python
>   -> runs nbdkit python <script name>
>   -> <script name> is interpreted as magic script= parameter
>   -> the python plugin works by loading the script using
>      PyRun_SimpleFileEx which interprets the contents of the
>      script as python code
>
> However for shell it doesn't work:
>
>   #!/usr/sbin/nbdkit sh
>   -> runs nbdkit sh <script name>
>   -> <script name> is interpreted as magic script= parameter
>   -> the sh plugin works by actually executing the script
>   -> executing the script repeats the steps over from the top,
>      causing an infinite loop
>
> If you can think of a way to make this work it would be a useful
> feature IMO.

Even if we can find a way, it sounds too complicated, and I don't see
the use case.

Nir





More information about the Libguestfs mailing list