[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] $EDITOR with spaces

From: <cmpilato_at_collab.net>
Date: 2002-04-16 19:07:52 CEST

Mark Benedetto King <bking@answerfriend.com> writes:

> > This may sound ridiculous, but I'm in a ridiculous sort of mood. :-)
> > We *could* do a brute-force loop of sorts.
> >
> > command = <get command from env>
> > loop:
> > err = <run command>
> > if <err means that command wasn't found> && <command has a space in it>
> > while <command has spaces in it>
> > <prepend stuff after the last space in command to the args list>
> > <remove stuff after the last space in command from command>
> > goto loop;
> > end
> > else
> > return err;
> >
>
> This doesn't work if you have
>
> /path/to/foo
>
> and you want to have EDITOR="/path/to/foo dir/program arg1 arg2"
>
> You need an escape mechanism. Like
>
> "/path/to/foo\ dir/program arg1 arg2"
>
> for example.
>
> One way would be to make stringlist_to_array support escaped
> spaces.

You know what, I reread my algorithm, and I *do* think it works in the
case you cited:

First, Subversion would try:

  cmd="/path/to/foo dir/program arg1 arg2"
  args=( "msg.00000.12345.tmp" )

This would fail. We'd try:

  cmd="/path/to/foo dir/program arg1"
  args=( "args2", "msg.00000.12345.tmp" )

This would fail. We'd try:

  cmd="/path/to/foo dir/program"
  args=( "arg1", "arg2", "msg.00000.12345.tmp" )

This *should* succeed, unless APR or the OS simply doesn't allow it.
And sure, there are probably ways to break this algorithm, but you can
only do so much (I'm thinking about the whole "how to remove a file
whose name is `-rf' on Unix" fun...)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Apr 16 19:10:43 2002

This is an archived mail posted to the Subversion Dev mailing list.