[Libguestfs] [PATCH 3/3] customize: add globbing for --delete

Richard W.M. Jones rjones at redhat.com
Wed Feb 3 18:41:02 UTC 2016


On Wed, Feb 03, 2016 at 07:28:18PM +0100, Pino Toscano wrote:
> Support globbing in paths passed to --delete, telling glob to not
> return directories with leading slash.
> 
> This re-adds back globbing for --delete in virt-sysprep, which was
> available before the integration with common code from virt-customize.
> ---
>  customize/customize_run.ml | 2 +-
>  generator/customize.ml     | 5 +++++
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/customize/customize_run.ml b/customize/customize_run.ml
> index 84f634b..6476f6a 100644
> --- a/customize/customize_run.ml
> +++ b/customize/customize_run.ml
> @@ -191,7 +191,7 @@ exec >>%s 2>&1
>  
>      | `Delete path ->
>        message (f_"Deleting: %s") path;
> -      g#rm_rf path
> +      Array.iter g#rm_rf (g#glob_expand ~nodirectoryslash:true path)
>  
>      | `Edit (path, expr) ->
>        message (f_"Editing: %s") path;
> diff --git a/generator/customize.ml b/generator/customize.ml
> index 19aec81..5d9a19b 100644
> --- a/generator/customize.ml
> +++ b/generator/customize.ml
> @@ -115,6 +115,11 @@ Wildcards cannot be used.";
>  Delete a file from the guest.  Or delete a directory (and all its
>  contents, recursively).
>  
> +You can use shell glob characters in the specified path; note that such
> +metacharacters might require proper escape.  For example:

It's a little bit unclear -- no problem, I understand your first
language isn't English!  This seems better to me:

> You can use shell glob characters in the specified path.  Be
> careful to escape glob characters from the host shell if that
> is required.  For example:


> + virt-customize --delete '/var/log/*.log'.
> +
>  See also: I<--upload>, I<--scrub>.";
>    };

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org




More information about the Libguestfs mailing list