All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Rockai <prockai@redhat.com>
To: lvm-devel@redhat.com
Subject: [RFC][PATCH 1/5] support command string with space
Date: Wed, 30 Sep 2009 22:24:36 +0200	[thread overview]
Message-ID: <878wfwdvuj.fsf@twilight.int.mornfall.net.> (raw)
In-Reply-To: <4AC2A619.50404@redhat.com> (Takahiro Yasui's message of "Tue, 29 Sep 2009 20:28:09 -0400")

Takahiro Yasui <tyasui@redhat.com> writes:

> Support escaped space by backslash in the command line string passed
> through lvm2 command interface, lvm2_run(). This is used to handle
> "--config" option which contains multiple parameters.
>
> e.g. lvconvert --repair --use-policies --config \
>      devices{ignore_suspended_devices=1\ filter=[...]} vg/lv
>
>
> Signed-off-by: Takahiro Yasui <tyasui@redhat.com>
> ---
>  tools/lvmcmdline.c |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> Index: LVM2.02.54-20090928/tools/lvmcmdline.c
> ===================================================================
> --- LVM2.02.54-20090928.orig/tools/lvmcmdline.c
> +++ LVM2.02.54-20090928/tools/lvmcmdline.c
> @@ -1070,8 +1070,15 @@ int lvm_split(char *str, int *argc, char
>  			break;
>  
>  		e = b;
> -		while (*e && !isspace(*e))
> +		while (*e && !isspace(*e)) {
> +			/*
> +			 * 'backslash' is treated as a escape character
> +			 * and the string isn't split at 'backslash + space.'
> +			 */
> +			if (*e == '\\' && isspace(*(e+1)))
> +				*e++ = ' ';
>  			e++;
> +		}
>  
>  		argv[(*argc)++] = b;
>  		if (!*e)
IIUIC, the code will replace "\ " with "  " (double space) -- which may or may
not be correct, depending on where the space appears. It also breaks any code
that may have previously expected "\ " to have no special meaning, even though I
doubt any exists.

Anyway, a more correct solution would entail a lvm2_runv (or similarly named)
function, that would take char **argv -- no escaping issues to care
about. Since this just adds to the library, it should be backwards compatible
just fine.

Yours,
   Petr.



  reply	other threads:[~2009-09-30 20:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-30  0:28 [RFC][PATCH 1/5] support command string with space Takahiro Yasui
2009-09-30 20:24 ` Petr Rockai [this message]
2009-09-30 21:19   ` Takahiro Yasui
2009-10-01  5:54     ` Petr Rockai
2009-10-16 19:00       ` Takahiro Yasui
2009-10-06 11:47   ` Alasdair G Kergon

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=878wfwdvuj.fsf@twilight.int.mornfall.net. \
    --to=prockai@redhat.com \
    --cc=lvm-devel@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.