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

Richard W.M. Jones rjones at redhat.com
Fri Nov 22 21:07:22 UTC 2019


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.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW




More information about the Libguestfs mailing list