[Libguestfs] [libnbd PATCH] nbdsh: Simplify the script

Nir Soffer nsoffer at redhat.com
Tue Jun 22 19:29:14 UTC 2021


On Tue, Jun 22, 2021 at 9:20 PM Martin Kletzander <mkletzan at redhat.com> wrote:
>
> There is no need for any hacks if we just do what execution of the module would
> have done.
>
> Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
> ---
>  sh/nbdsh.in | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/sh/nbdsh.in b/sh/nbdsh.in
> index d10f0c1b6b26..f66e2918d304 100644
> --- a/sh/nbdsh.in
> +++ b/sh/nbdsh.in
> @@ -1,4 +1,4 @@
> -#!/bin/sh -
> +#!/usr/bin/env @PYTHON@

Do we really care about specific @PYTHON@?

If not we can use:

    #!/usr/bin/python3

>  # Copyright (C) 2011-2019 Red Hat Inc.
>  #
>  # @configure_input@
> @@ -17,10 +17,6 @@
>  # License along with this library; if not, write to the Free Software
>  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>
> -# Test if /bin/sh supports exec -a option (only supported in bash 4.2
> -# and above, and not part of POSIX).
> -if /bin/sh -c 'exec -a test true' 2>/dev/null; then
> -    exec -a nbdsh @PYTHON@ -mnbd "$@"
> -else
> -    exec          @PYTHON@ -mnbd "$@"
> -fi
> +import nbdsh
> +
> +nbdsh.shell()
> --
> 2.32.0
>
> _______________________________________________
> Libguestfs mailing list
> Libguestfs at redhat.com
> https://listman.redhat.com/mailman/listinfo/libguestfs
>




More information about the Libguestfs mailing list