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

Re: Bug report -- space in env. var. VISUAL causes commits to fail (needs confirmation)

From: David Dyer-Bennet <dd-b_at_dd-b.net>
Date: Tue, 7 Dec 2010 09:30:45 -0600

On Tue, December 7, 2010 09:03, Daniel Shahaf wrote:
> David Dyer-Bennet wrote on Tue, Dec 07, 2010 at 08:44:28 -0600:
>> On Tue, December 7, 2010 04:18, Julian Foad wrote:
>> > On Tue, 2010-12-07, Daniel Shahaf wrote:
>> >> I suppose setting VISUAL="\"/path with spaces/to/editor/binary\"" is
>> the
>> >> easiest solution --- it requires no code changes so it will work with
>> >> any svn binary out there.
>> >
>> > Yes, I think that's the best solution.
>>
>> That's an interesting idea.
>>
>> Unfortunately, it doesn't seem to work. (Example from Centos 5.5
>> again):
>>
>
> The following syntaxes work for me:
>
> % SVN_EDITOR="'$HOME/pre fix/bin/vim' +%d" $svn mkdir
> file:///tmp/svn/r1/foo3
> % $svn mkdir file:///tmp/svn/r1/foo3 --editor-cmd "'$HOME/pre fix/bin/vim'
> +%d"

Having an application-specific env variable also makes this kind of
workaround more palatable -- setting SVN_EDITOR strangely shouldn't
break anything else, and if it does, it's the fault of the something
else.

> (the +%d is there both to prove to myself that it's not simply falling
> back to my default editor --- which is also vim --- and to show that
> passing argv[1] to the editor works)
>
>> sh-3.2$ export VISUAL='"/home/path with spaces/bin/emacs"'
>> sh-3.2$ echo $VISUAL
>> "/home/path with spaces/bin/emacs"
>> sh-3.2$ ls -l "/home/path with spaces/bin"
>> total 8
>> -rwxr-xr-x 1 root root 192 Dec 7 08:40 emacs
>> sh-3.2$ svn commit
>> basename: extra operand `spaces/bin/emacs'
>
> Why is basename(1) invoked here?
> ^^^
>
> (That's almost certainly something in your configuration.)

I checked; turns out that /usr/bin/emacs is a script that invokes
basename (in the standard Centos 5.5 emacs install). I copied
/usr/bin/emacs to /home/path with spaces/bin/emacs for this test.

It looks like the workaround of quoting the path with spaces in
SVN_EDITOR works, and I'm now encountering a bug in emacs (or perhaps
the Centos packaging of Emacs). (The emacs script is easily fixed to
tolerate spaces in its path, just by doing the basic obvious things
you do when shell scripting.)

>> Try `basename --help' for more information.
>> Can't find
>> svn: Commit failed (details follow):
>> svn: system('"/home/path with spaces/bin/emacs" svn-commit.tmp')
>> returned 256
>
>
>> And, in any case, VISUAL is a public interface, and I wonder how many
>> other applications would break if I put that kind of thing into
>> VISUAL.
>
> Morale: don't use paths with spaces.

Yes, that would be simpler. But as I said in my initial post, I first
discovered this on Windows under Cygwin. Avoiding "c:/Program Files"
and "c:/Documents and Settings/david.dyer-bennet/My Documents"
involves contortions and leaves you putting things in unusual places.

Linux defines spaces as valid characters in paths and filenames, so
people are going to try to use them. And Subversion does support
Windows.

(Spelling nit, no flame intended: "moral"; not "morale". They're
both real words with quite different meanings, so it's of value to
keep them distinct. And now I have no doubt guaranteed 3 basic
language mistakes of my own somewhere in this message :-) .)

-- 
David Dyer-Bennet, dd-b@dd-b.net; http://dd-b.net/
Snapshots: http://dd-b.net/dd-b/SnapshotAlbum/data/
Photos: http://dd-b.net/photography/gallery/
Dragaera: http://dragaera.info
Received on 2010-12-07 16:31:25 CET

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.